[llvm] Add subtraction support for setLimitsForBinOp (PR #143618)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 13 03:06:20 PDT 2025


================
@@ -9576,6 +9576,60 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower,
   unsigned Width = Lower.getBitWidth();
   const APInt *C;
   switch (BO.getOpcode()) {
+  case Instruction::Sub:
+    if (match(BO.getOperand(1), m_APInt(C)) && !C->isZero()) {
----------------
dtcxzyw wrote:

We always canonicalize `sub X, C -> add X, -C`. I don't think this path is valuable.


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


More information about the llvm-commits mailing list