[llvm] [AMDGPU] selecting v_sat_pk instruction, version 2 (PR #123297)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 21 05:09:11 PST 2025


================
@@ -817,11 +817,33 @@ SITargetLowering::SITargetLowering(const TargetMachine &TM,
                          Custom);
     }
 
-    // Avoid true 16 instruction
-    if (!Subtarget->hasTrue16BitInsts() || !Subtarget->useRealTrue16Insts()) {
-      // MVT::v2i16 for src type check in foldToSaturated
-      // MVT::v2i8 for dst type check in CustomLowerNode
-      setOperationAction(ISD::TRUNCATE_SSAT_U, {MVT::v2i16, MVT::v2i8}, Custom);
+    // True 16 instruction is current not supported
+    // FIXME: Add support for true 16 when supported
+    if (!(Subtarget->hasTrue16BitInsts() && Subtarget->useRealTrue16Insts())) {
+      // MVT::vNi16 for src type check in foldToSaturated
+      // MVT::vNi8 for dst type check in CustomLowerNode
+      setOperationAction(ISD::TRUNCATE_SSAT_U,
+                         {
+                             MVT::v2i16,
----------------
Shoreshen wrote:

Hi @arsenm , for truncate_ssat_u to be folded `TLI.isOperationLegalOrCustom` function has pass.

We didn't hook this function, so it goes default and will check `getOperationAction(Op, SrcVT) == Custom`, which will look up `OpActions[(unsigned)VT.getSimpleVT().SimpleTy][Op]`, and this is set here.

If we do not set the vNi16 (source type), the truncat_ssat_u will not be created.

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


More information about the llvm-commits mailing list