[llvm] [NVPTX] Add support for f16 fabs (PR #116107)

Alex MacLean via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 15:08:02 PST 2024


================
@@ -864,10 +864,15 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
     AddPromotedToType(Op, MVT::bf16, MVT::f32);
   }
   for (const auto &Op : {ISD::FABS}) {
-    setOperationAction(Op, MVT::f16, Promote);
     setOperationAction(Op, MVT::f32, Legal);
     setOperationAction(Op, MVT::f64, Legal);
-    setOperationAction(Op, MVT::v2f16, Expand);
+    if (STI.getPTXVersion() >= 65) {
+      setFP16OperationAction(Op, MVT::f16, Legal, Promote);
+      setFP16OperationAction(Op, MVT::v2f16, Legal, Expand);
+    } else {
+      setOperationAction(Op, MVT::f16, Promote);
+      setOperationAction(Op, MVT::v2f16, Expand);
+    }
     setBF16OperationAction(Op, MVT::v2bf16, Legal, Expand);
     setBF16OperationAction(Op, MVT::bf16, Legal, Promote);
----------------
AlexMaclean wrote:

I don't think this is necessary, in fact I suspect this whole case can be removed. `hasBF16Math` already checks for sm_80 and since sm_80 is not supported until ptx_70 we can assume this requirement will be met as well.

https://github.com/llvm/llvm-project/blob/ec066d30e29fce388b1722971970d73ec65f14fb/llvm/lib/Target/NVPTX/NVPTXSubtarget.h#L86

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


More information about the llvm-commits mailing list