[llvm] [LLVM] Add FP instruction intrinsics (PR #193588)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat May 2 04:35:31 PDT 2026
================
@@ -1134,10 +1134,39 @@ def int_experimental_memset_pattern
NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
ImmArg<ArgIndex<3>>]>;
-// FIXME: Add version of these floating point intrinsics which allow non-default
-// rounding modes and FP exception handling.
+// Intrinsic call-form equivalents of FP instructions, allowing operand bundles
+// (e.g. "fp.control") to carry per-call FP environment flags such as
+// flush-to-zero denormal mode that cannot be attached to plain IR instructions
+// (fadd/fsub/fmul/...). Without any operand bundles these lower identically
+// to the corresponding FP instructions.
let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrNoCreateUndefOrPoison] in {
+ def int_fadd : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
+ [LLVMMatchType<0>, LLVMMatchType<0>]>;
+ def int_fsub : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
+ [LLVMMatchType<0>, LLVMMatchType<0>]>;
+ def int_fmul : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
+ [LLVMMatchType<0>, LLVMMatchType<0>]>;
+ def int_fdiv : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
+ [LLVMMatchType<0>, LLVMMatchType<0>]>;
+ def int_frem : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
+ [LLVMMatchType<0>, LLVMMatchType<0>]>;
+
+ // fptrunc/fpext: unary; result type differs from operand type
+ def int_fptrunc : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [llvm_anyfloat_ty]>;
+ def int_fpext : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [llvm_anyfloat_ty]>;
+
+ // Integer/FP conversions
+ def int_sitofp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [llvm_anyint_ty]>;
+ def int_uitofp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [llvm_anyint_ty]>;
+ def int_fptosi : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
----------------
dtcxzyw wrote:
fptosi/fptoui yields poison when the result doesn't fit in the integer type.
https://github.com/llvm/llvm-project/pull/193588
More information about the llvm-commits
mailing list