[llvm] [ConstraintElim] decompose nsw subtract with guard as precondition (PR #209615)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 06:10:50 PDT 2026


================
@@ -662,6 +662,17 @@ static Decomposition decompose(Value *V,
     return V;
   }
 
+  // A `sub nsw Op0, Op1` equals Op0 - Op1 in the unsigned system as long as the
+  // result is non-negative (Op1 <= Op0), which is recorded as a precondition.
+  if (match(V, m_NSWSub(m_Value(Op0), m_Value(Op1)))) {
----------------
antoniofrighetto wrote:

Do we need nsw here? https://alive2.llvm.org/ce/z/oKU_uC

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


More information about the llvm-commits mailing list