[clang] [llvm] [HLSL] implement the `isinf` intrinsic (PR #84927)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 14 10:47:09 PDT 2024
================
@@ -18050,6 +18050,21 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
/*ReturnType=*/Op0->getType(), Intrinsic::dx_frac,
ArrayRef<Value *>{Op0}, nullptr, "dx.frac");
}
+ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
+ Value *Op0 = EmitScalarExpr(E->getArg(0));
+ llvm::Type *Xty = Op0->getType();
+ llvm::Type *retType = llvm::Type::getInt1Ty(this->getLLVMContext());
+ if (Xty->isVectorTy()) {
+ auto *XVecTy = E->getArg(0)->getType()->getAs<VectorType>();
+ retType = llvm::VectorType::get(
+ retType, ElementCount::getFixed(XVecTy->getNumElements()));
+ }
+ if (!E->getArg(0)->getType()->hasFloatingRepresentation())
+ llvm_unreachable("isinf operand must have a float representation");
+ return Builder.CreateIntrinsic(
+ /*ReturnType=*/retType, Intrinsic::dx_isinf, ArrayRef<Value *>{Op0},
----------------
bogner wrote:
I see that this is just following the rest of the file so I guess no change needed, but it seems odd to tag "/*ReturnType=*/" here specifically - we usually only do that for bools and things that are ambiguous, where this is literally passing an argument called `retType`.
https://github.com/llvm/llvm-project/pull/84927
More information about the llvm-commits
mailing list