Skip to content

[DirectX] Pointer type bitcast must be have same size. #139013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
farzonl opened this issue May 8, 2025 · 0 comments
Open

[DirectX] Pointer type bitcast must be have same size. #139013

farzonl opened this issue May 8, 2025 · 0 comments
Assignees

Comments

@farzonl
Copy link
Member

farzonl commented May 8, 2025

DXILPrepare.cpp adds NoOp bitcasts that are causing problems in the validator

// Emtting NoOp bitcast instructions allows the ValueEnumerator to be
// unmodified as it reserves instruction IDs during contruction.
if (auto LI = dyn_cast<LoadInst>(&I)) {
if (Value *NoOpBitcast = maybeGenerateBitcast(
Builder, PointerTypes, I, LI->getPointerOperand(),
LI->getType())) {
LI->replaceAllUsesWith(
Builder.CreateLoad(LI->getType(), NoOpBitcast));
LI->eraseFromParent();
}
continue;
}
if (auto SI = dyn_cast<StoreInst>(&I)) {
if (Value *NoOpBitcast = maybeGenerateBitcast(
Builder, PointerTypes, I, SI->getPointerOperand(),
SI->getValueOperand()->getType())) {
SI->replaceAllUsesWith(
Builder.CreateStore(SI->getValueOperand(), NoOpBitcast));
SI->eraseFromParent();
}
continue;
}
if (auto GEP = dyn_cast<GetElementPtrInst>(&I)) {
if (Value *NoOpBitcast = maybeGenerateBitcast(
Builder, PointerTypes, I, GEP->getPointerOperand(),
GEP->getSourceElementType()))
GEP->setOperand(0, NoOpBitcast);
continue;
}

It is changing

store float 2.000000e+00, ptr addrspace(3) getelementptr (float, ptr addrspace(3) @arrayofVecData.scalarized.1dim, i32 1), align 4

to:

%2 = bitcast ptr addrspace(3) getelementptr (float, ptr addrspace(3) @arrayofVecData.scalarized.1dim, i32 1) to ptr addrspace(3)
store float 2.000000e+00, ptr addrspace(3) %2, align 4

commenting out these no ops resolves all 848 ptr bitcast errors.

@farzonl farzonl moved this to Planning in HLSL Support May 8, 2025
@bogner bogner moved this from Planning to Ready in HLSL Support May 8, 2025
@bogner bogner moved this from Ready to Active in HLSL Support May 8, 2025
@farzonl farzonl moved this from Active to Planning in HLSL Support May 12, 2025
@damyanp damyanp moved this from Planning to Active in HLSL Support May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Active
Development

No branches or pull requests

1 participant