[clang] [llvm] [clang][NVPTX] Add support for mixed-precision FP arithmetic (PR #168359)

Alex MacLean via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 1 09:18:47 PST 2025


================
@@ -1443,15 +1445,31 @@ let TargetPrefix = "nvvm" in {
   // Add
   //
   let IntrProperties = [IntrNoMem, IntrSpeculatable, Commutative] in {
-    foreach rnd = ["rn", "rz", "rm", "rp"] in {
-      foreach ftz = ["", "_ftz"] in
-        def int_nvvm_add_ # rnd # ftz # _f : NVVMBuiltin,
-          DefaultAttrsIntrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty]>;
-
-      def int_nvvm_add_ # rnd # _d : NVVMBuiltin,
+    foreach rnd = ["_rn", "_rz", "_rm", "_rp"] in {
+      foreach ftz = ["", "_ftz"] in {
+        foreach sat = ["", "_sat"] in {
+          def int_nvvm_add # rnd # ftz # sat # _f : NVVMBuiltin,
+            DefaultAttrsIntrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty]>;
+        } // sat
+      } // ftz
+      def int_nvvm_add # rnd # _d : NVVMBuiltin,
           DefaultAttrsIntrinsic<[llvm_double_ty], [llvm_double_ty, llvm_double_ty]>;
-    }
+    } // rnd
   }
+  
+  //
+  // Sub
+  //
+  foreach rnd = ["_rn", "_rz", "_rm", "_rp"] in {
+    foreach ftz = ["", "_ftz"] in {
+      foreach sat = ["", "_sat"] in {
+        def int_nvvm_sub # rnd # ftz # sat # _f : NVVMBuiltin,
----------------
AlexMaclean wrote:

Is there a motivating case for sub intrinsics? Can we just fold the add variants with fneg? Given that intrinsics are pretty easy to add and very difficult to remove, I'm generally in favor of being conservative since each intrinsic needs documentation, constant folding, ect. 

https://github.com/llvm/llvm-project/pull/168359


More information about the cfe-commits mailing list