Skip to content

Commit 6734eed

Browse files
committed
vector swizzle boolean vectors
1 parent dd7e459 commit 6734eed

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2353,7 +2353,13 @@ RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV) {
23532353
if (!ExprVT) {
23542354
unsigned InIdx = getAccessedFieldNo(0, Elts);
23552355
llvm::Value *Elt = llvm::ConstantInt::get(SizeTy, InIdx);
2356-
return RValue::get(Builder.CreateExtractElement(Vec, Elt));
2356+
2357+
llvm::Value *Element = Builder.CreateExtractElement(Vec, Elt);
2358+
2359+
if (getLangOpts().HLSL && LV.getType()->isBooleanType())
2360+
Element = Builder.CreateTrunc(Element, ConvertType(LV.getType()));
2361+
2362+
return RValue::get(Element);
23572363
}
23582364

23592365
// Always use shuffle vector to try to retain the original program structure
@@ -2364,6 +2370,10 @@ RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV) {
23642370
Mask.push_back(getAccessedFieldNo(i, Elts));
23652371

23662372
Vec = Builder.CreateShuffleVector(Vec, Mask);
2373+
2374+
if (getLangOpts().HLSL && LV.getType()->isExtVectorBoolType())
2375+
Vec = EmitFromMemory(Vec, LV.getType());
2376+
23672377
return RValue::get(Vec);
23682378
}
23692379

0 commit comments

Comments
 (0)