[clang] [HLSL] Make memory representation of boolean vectors in HLSL, vectors of i32. Add support for boolean swizzling. (PR #123977)
Sarah Spall via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 3 13:12:07 PST 2025
================
@@ -1984,6 +1984,15 @@ llvm::Constant *ConstantEmitter::emitForMemory(CodeGenModule &CGM,
return Res;
}
+ // In HLSL bool vectors are stored in memory as a vector of i32
+ if (destType->isExtVectorBoolType() && CGM.getContext().getLangOpts().HLSL) {
+ llvm::Type *boolVecTy = CGM.getTypes().ConvertTypeForMem(destType);
----------------
spall wrote:
I don't believe so. This code is necessary for HLSL because the constant 'C' is a <2 x i1> but HLSL needs it to be a <2 x i32> hence the zero extension. For non HLSL vectors the expected form would be <2 x i1> so nothing needs to be done.
https://hlsl.godbolt.org/z/nsb6jd1vn
https://github.com/llvm/llvm-project/pull/123977
More information about the cfe-commits
mailing list