[llvm] [SelectionDAG] Prevent combination on inconsistent type in `combineCarryDiamond` (PR #84888)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 12 03:46:39 PDT 2024


================
@@ -3442,6 +3442,9 @@ static SDValue combineCarryDiamond(SelectionDAG &DAG, const TargetLowering &TLI,
     return SDValue();
   if (Opcode != ISD::UADDO && Opcode != ISD::USUBO)
     return SDValue();
+  // Guarantee identical type of CarryOut
+  if (N->getValueType(0) != Carry0.getValue(1).getValueType())
----------------
RKSimon wrote:

Most of this code implicitly assumes we're returning == MVT::i1, so maybe:
```cpp
if (N->getValueType(0) != MVT::i1 || 
    Carry0.getValue(1).getValueType() != MVT::i1 ||
    Carry1.getValue(1).getValueType() != MVT::i1)
  return SDValue();
```

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


More information about the llvm-commits mailing list