Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CGHLSLBuiltins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,12 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
Value *OpTrue =
RValTrue.isScalar()
? RValTrue.getScalarVal()
: RValTrue.getAggregatePointer(E->getArg(1)->getType(), *this);
: Builder.CreateLoad(RValTrue.getAggregateAddress(), "true_val");
RValue RValFalse = EmitAnyExpr(E->getArg(2));
Value *OpFalse =
RValFalse.isScalar()
? RValFalse.getScalarVal()
: RValFalse.getAggregatePointer(E->getArg(2)->getType(), *this);
: Builder.CreateLoad(RValFalse.getAggregateAddress(), "false_val");
if (auto *VTy = E->getType()->getAs<VectorType>()) {
if (!OpTrue->getType()->isVectorTy())
OpTrue =
Expand Down
6 changes: 4 additions & 2 deletions clang/test/CodeGenHLSL/builtins/select.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ int test_select_bool_int(bool cond0, int tVal, int fVal) {

struct S { int a; };
// CHECK-LABEL: test_select_infer
// CHECK: [[SELECT:%.*]] = select i1 {{%.*}}, ptr {{%.*}}, ptr {{%.*}}
// CHECK: store ptr [[SELECT]]
// CHECK: [[TRUE_VAL:%.*]] = load %struct.S, ptr {{%.*}}, align 1
// CHECK: [[FALSE_VAL:%.*]] = load %struct.S, ptr {{%.*}}, align 1
// CHECK: [[SELECT:%.*]] = select i1 {{%.*}}, %struct.S [[TRUE_VAL]], %struct.S [[FALSE_VAL]]
// CHECK: store %struct.S [[SELECT]], ptr {{%.*}}, align 1
// CHECK: ret void
struct S test_select_infer(bool cond0, struct S tVal, struct S fVal) {
return select(cond0, tVal, fVal);
Expand Down
Loading