[llvm] f20640b - [X86] PromoteMaskArithmetic - use similar code for LHS/RHS trunc pattern. NFC. (#157426)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 8 04:44:00 PDT 2025


Author: Simon Pilgrim
Date: 2025-09-08T11:43:56Z
New Revision: f20640b536fd47c39ba4bad8af1ecb2e85604381

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

LOG: [X86] PromoteMaskArithmetic - use similar code for LHS/RHS trunc pattern. NFC. (#157426)

Make it more obvious that LHS/RHS truncation patterns are the same.

Noticed while working on #157425

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 cdc97faf394ca..15b59afabc61f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -50957,15 +50957,13 @@ static SDValue PromoteMaskArithmetic(SDValue N, const SDLoc &DL, EVT VT,
   if (SDValue NN0 = PromoteMaskArithmetic(N0, DL, VT, DAG, Depth + 1))
     N0 = NN0;
   else {
-    // The left side has to be a trunc.
-    if (N0.getOpcode() != ISD::TRUNCATE)
-      return SDValue();
-
-    // The type of the truncated inputs.
-    if (N0.getOperand(0).getValueType() != VT)
+    // The left side has to be a 'trunc'.
+    bool LHSTrunc = N0.getOpcode() == ISD::TRUNCATE &&
+                    N0.getOperand(0).getValueType() == VT;
+    if (LHSTrunc)
+      N0 = N0.getOperand(0);
+    else
       return SDValue();
-
-    N0 = N0.getOperand(0);
   }
 
   if (SDValue NN1 = PromoteMaskArithmetic(N1, DL, VT, DAG, Depth + 1))


        


More information about the llvm-commits mailing list