[llvm] [DirectX] Implement `llvm.is.fpclass` lowering for the fcNegZero FPClassTest and the `IsNaN`, `IsInf`, `IsFinite`, `IsNormal` DXIL ops (PR #138048)
Deric C. via llvm-commits
llvm-commits at lists.llvm.org
Wed May 7 19:51:34 PDT 2025
================
@@ -739,6 +739,50 @@ class OpLowerer {
});
}
+ [[nodiscard]] bool lowerIsFPClass(Function &F) {
+ IRBuilder<> &IRB = OpBuilder.getIRB();
+ Type *RetTy = IRB.getInt1Ty();
+
+ return replaceFunction(F, [&](CallInst *CI) -> Error {
+ IRB.SetInsertPoint(CI);
+ SmallVector<Value *> Args;
+ Value *Fl = CI->getArgOperand(0);
+ Args.push_back(Fl);
+
+ dxil::OpCode OpCode;
+ Value *T = CI->getArgOperand(1);
+ auto *TCI = dyn_cast<ConstantInt>(T);
+ switch (TCI->getZExtValue()) {
+ case FPClassTest::fcInf:
+ OpCode = dxil::OpCode::IsInf;
----------------
Icohedron wrote:
Yes, both the dx_isinf intrinsic and the llvm.is.fpclass intrinsic can lower to the IsInf DXIL op. Their lowerings are independent of each other.
Once the other dx_ intrinsics are defined, they can be mapped to their respective DXIL ops using `intrinsics = [IntrinSelect<int_dx_*>]`.
https://github.com/llvm/llvm-project/pull/138048
More information about the llvm-commits
mailing list