[llvm] [SCCP] Refine trunc with nsw/nuw flags (PR #87926)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 7 07:33:11 PDT 2024


================
@@ -146,6 +146,21 @@ static bool refineInstruction(SCCPSolver &Solver,
       Inst.setNonNeg();
       Changed = true;
     }
+  } else if (TruncInst *TI = dyn_cast<TruncInst>(&Inst)) {
+    auto Range = GetRange(Inst.getOperand(0));
----------------
dtcxzyw wrote:

We can avoid computing ranges if both flags are already set. Same for `OverflowingBinaryOperator`.


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


More information about the llvm-commits mailing list