[llvm] 0e2c1cb - [X86] ReplaceNodeResults - always attempt to fold TRUNCATE -> PACKSS/PACKUS nodes.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 10 08:46:15 PDT 2023


Author: Simon Pilgrim
Date: 2023-08-10T16:42:10+01:00
New Revision: 0e2c1cb233294035994267e00b6ba05e5e682e19

URL: https://github.com/llvm/llvm-project/commit/0e2c1cb233294035994267e00b6ba05e5e682e19
DIFF: https://github.com/llvm/llvm-project/commit/0e2c1cb233294035994267e00b6ba05e5e682e19.diff

LOG: [X86] ReplaceNodeResults - always attempt to fold TRUNCATE -> PACKSS/PACKUS nodes.

No need to limit this to sub-128-bit cases now that matchTruncateWithPACK handles this.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index b84b408f4f66d5..4469aada96716b 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -32059,21 +32059,19 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
     unsigned WidenNumElts = WidenVT.getVectorNumElements();
     unsigned InBits = InVT.getSizeInBits();
 
-    if (128 % InBits == 0) {
-      // See if there are sufficient leading bits to perform a PACKUS/PACKSS.
-      unsigned PackOpcode;
-      if (SDValue Src =
-              matchTruncateWithPACK(PackOpcode, VT, In, dl, DAG, Subtarget)) {
-        SDValue WidenSrc =
-            widenSubVector(Src, false, Subtarget, DAG, dl,
-                           InEltVT.getSizeInBits() * WidenNumElts);
-        if (SDValue Res = truncateVectorWithPACK(PackOpcode, WidenVT, WidenSrc,
-                                                 dl, DAG, Subtarget)) {
-          Results.push_back(Res);
-          return;
-        }
+    // See if there are sufficient leading bits to perform a PACKUS/PACKSS.
+    unsigned PackOpcode;
+    if (SDValue Src =
+            matchTruncateWithPACK(PackOpcode, VT, In, dl, DAG, Subtarget)) {
+      if (SDValue Res = truncateVectorWithPACK(PackOpcode, VT, Src,
+                                               dl, DAG, Subtarget)) {
+        Res = widenSubVector(WidenVT, Res, false, Subtarget, DAG, dl);
+        Results.push_back(Res);
+        return;
       }
+    }
 
+    if (128 % InBits == 0) {
       // 128 bit and smaller inputs should avoid truncate all together and
       // just use a build_vector that will become a shuffle.
       // TODO: Widen and use a shuffle directly?


        


More information about the llvm-commits mailing list