@@ -18703,13 +18703,13 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
18703
18703
18704
18704
// if cond is a bool emit a select instruction
18705
18705
if (TCond->isIntegerTy(1))
18706
- return Builder.CreateSelect(OpCond, OpTrue, OpFalse);
18706
+ return Builder.CreateSelect(OpCond, OpTrue, OpFalse, "hlsl.select" );
18707
18707
18708
18708
// if cond is a vector of bools lower to a shufflevector
18709
18709
// todo check if that true and false are vectors
18710
18710
// todo check that the size of true and false and cond are the same
18711
18711
if (TCond->isVectorTy() &&
18712
- E->getArg(0)->getType()->getAs<VectorType>()->isBooleanType()) {
18712
+ E->getArg(0)->getType()->getAs<VectorType>()->getElementType()-> isBooleanType()) {
18713
18713
assert(OpTrue->getType()->isVectorTy() && OpFalse->getType()->isVectorTy() &&
18714
18714
"Select's second and third operands must be vectors if first operand is a vector.");
18715
18715
@@ -18723,15 +18723,18 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
18723
18723
assert(N == VecTyFalse->getNumElements() &&
18724
18724
N == E->getArg(0)->getType()->getAs<VectorType>()->getNumElements() &&
18725
18725
"Select requires vectors to be of the same size.");
18726
-
18727
- llvm::SmallVector< Value *> Mask ;
18726
+
18727
+ llvm::Value *Result = llvm::PoisonValue::get(llvm::FixedVectorType::get(IntTy, N)) ;
18728
18728
for (unsigned I = 0; I < N; I++) {
18729
18729
Value *Index = ConstantInt::get(IntTy, I);
18730
18730
Value *IndexBool = Builder.CreateExtractElement(OpCond, Index);
18731
- Mask.push_back(Builder.CreateSelect(IndexBool, Index, ConstantInt::get(IntTy, I + N)));
18731
+ Value *TVal = Builder.CreateExtractElement(OpTrue, Index);
18732
+ Value *FVal = Builder.CreateExtractElement(OpFalse, Index);
18733
+ Value *IndexSelect = Builder.CreateSelect(IndexBool, TVal, FVal);
18734
+ Result = Builder.CreateInsertElement(Result, IndexSelect, Index);
18732
18735
}
18733
-
18734
- return Builder.CreateShuffleVector(OpTrue, OpFalse, BuildVector(Mask)) ;
18736
+
18737
+ return Result ;
18735
18738
}
18736
18739
18737
18740
llvm_unreachable("Select requires a bool or vector of bools as its first operand.");
0 commit comments