[llvm] [X86] Truncates i64 add arithmetic to i32 when known zeroes in upper 33 bits (PR #191619)

Takashi Idobe via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 06:16:05 PDT 2026


================
@@ -59434,6 +59435,34 @@ static SDValue combineAdd(SDNode *N, SelectionDAG &DAG,
   if (SDValue IFMA52 = matchVPMADD52(N, DAG, DL, VT, Subtarget))
     return IFMA52;
 
+  // If upper 33 bits of operands are 0, truncates opcode from i64 to i32.
+  if (VT == MVT::i64) {
+    APInt Mask = APInt::getHighBitsSet(64, 33);
+    if (DAG.MaskedValueIsZero(Op0, Mask) && DAG.MaskedValueIsZero(Op1, Mask)) {
+      // Guard to check if one of the  operand is constant.
----------------
Takashiidobe wrote:

Nit: I see an extra space here. 
```suggestion
      // Guard to check if one of the operand is constant.
```

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


More information about the llvm-commits mailing list