@@ -18960,67 +18960,41 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
1896018960 E->getArg(1)->getType()->hasUnsignedIntegerRepresentation() &&
1896118961 E->getArg(2)->getType()->hasUnsignedIntegerRepresentation()) &&
1896218962 "asuint operands types mismatch");
18963-
1896418963 Value *Op0 = EmitScalarExpr(E->getArg(0));
1896518964 const HLSLOutArgExpr *OutArg1 = dyn_cast<HLSLOutArgExpr>(E->getArg(1));
1896618965 const HLSLOutArgExpr *OutArg2 = dyn_cast<HLSLOutArgExpr>(E->getArg(2));
1896718966
18968- auto emitSplitDouble =
18969- [](CGBuilderTy *Builder, llvm::Intrinsic::ID intrId, llvm::Value *arg,
18970- llvm::Type *retType) -> std::pair<Value *, Value *> {
18971- CallInst *CI =
18972- Builder->CreateIntrinsic(retType, intrId,
18973- {arg}, nullptr, "hlsl.asuint");
18974-
18975- Value *arg0 = Builder->CreateExtractValue(CI, 0);
18976- Value *arg1 = Builder->CreateExtractValue(CI, 1);
18977-
18978- return std::make_pair(arg0, arg1);
18979- };
18980-
1898118967 CallArgList Args;
1898218968 auto [Op1BaseLValue, Op1TmpLValue] =
1898318969 EmitHLSLOutArgExpr(OutArg1, Args, OutArg1->getType());
1898418970 auto [Op2BaseLValue, Op2TmpLValue] =
1898518971 EmitHLSLOutArgExpr(OutArg2, Args, OutArg2->getType());
1898618972
18987- llvm::StructType *retType = llvm::StructType::get(Int32Ty, Int32Ty);
18973+ if (CGM.getTarget().getTriple().getArch() == llvm::Triple::dxil) {
1898818974
18989- if (!Op0->getType()->isVectorTy()) {
18990- auto [arg0, arg1] = emitSplitDouble(&Builder, CGM.getHLSLRuntime().getSplitdoubleIntrinsic(), Op0, retType);
18991-
18992- Builder.CreateStore(arg0, Op1TmpLValue.getAddress());
18993- auto *s = Builder.CreateStore(arg1, Op2TmpLValue.getAddress());
18994-
18995- EmitWritebacks(*this, Args);
18996- return s;
18997- }
18975+ llvm::StructType *retType = llvm::StructType::get(Int32Ty, Int32Ty);
1899818976
18999- auto *Op0VecTy = E->getArg(0)->getType()->getAs<VectorType>();
18977+ if (Op0->getType()->isVectorTy()) {
18978+ auto *Op0VecTy = E->getArg(0)->getType()->getAs<VectorType>();
1900018979
19001- llvm::VectorType *i32VecTy = llvm::VectorType::get(
19002- Int32Ty, ElementCount::getFixed(Op0VecTy->getNumElements()));
18980+ llvm::VectorType *i32VecTy = llvm::VectorType::get(
18981+ Int32Ty, ElementCount::getFixed(Op0VecTy->getNumElements()));
18982+ retType = llvm::StructType::get(i32VecTy, i32VecTy);
18983+ }
1900318984
19004- std::pair<Value *, Value *> inserts = std::make_pair(nullptr, nullptr);
18985+ CallInst *CI =
18986+ Builder.CreateIntrinsic(retType, Intrinsic::dx_splitdouble, {Op0},
18987+ nullptr, "hlsl.splitdouble");
1900518988
19006- for (uint64_t idx = 0; idx < Op0VecTy->getNumElements(); idx++) {
19007- Value *op = Builder.CreateExtractElement(Op0, idx );
18989+ Value *arg0 = Builder.CreateExtractValue(CI, 0);
18990+ Value *arg1 = Builder.CreateExtractValue(CI, 1 );
1900818991
19009- auto [arg0, arg1] = emitSplitDouble(&Builder, CGM.getHLSLRuntime().getSplitdoubleIntrinsic(), op, retType);
18992+ Builder.CreateStore(arg0, Op1TmpLValue.getAddress());
18993+ auto *s = Builder.CreateStore(arg1, Op2TmpLValue.getAddress());
1901018994
19011- if (idx == 0) {
19012- inserts.first = Builder.CreateInsertElement(i32VecTy, arg0, idx);
19013- inserts.second = Builder.CreateInsertElement(i32VecTy, arg1, idx);
19014- } else {
19015- inserts.first = Builder.CreateInsertElement(inserts.first, arg0, idx);
19016- inserts.second = Builder.CreateInsertElement(inserts.second, arg1, idx);
19017- }
18995+ EmitWritebacks(*this, Args);
18996+ return s;
1901818997 }
19019-
19020- Builder.CreateStore(inserts.first, Op1TmpLValue.getAddress());
19021- auto *s = Builder.CreateStore(inserts.second, Op2TmpLValue.getAddress());
19022- EmitWritebacks(*this, Args);
19023- return s;
1902418998 }
1902518999 }
1902619000 return nullptr;
0 commit comments