[llvm] [ConstraintElim] Do not allow overflows in `Decomposition` (PR #140541)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed May 21 07:47:46 PDT 2025
================
@@ -534,20 +536,21 @@ static Decomposition decompose(Value *V,
}
if (match(V, m_NSWAdd(m_Value(Op0), m_Value(Op1))))
- return MergeResults(Op0, Op1, IsSigned);
+ if (auto Decomp = MergeResults(Op0, Op1, IsSigned))
+ return *Decomp;
if (match(V, m_NSWSub(m_Value(Op0), m_Value(Op1)))) {
auto ResA = decompose(Op0, Preconditions, IsSigned, DL);
auto ResB = decompose(Op1, Preconditions, IsSigned, DL);
- ResA.sub(ResB);
- return ResA;
+ if (!ResA.sub(ResB))
+ return ResA;
----------------
dtcxzyw wrote:
Yes. It may miss some optimizations. But it looks unlikely to happen in real-world cases.
https://github.com/llvm/llvm-project/pull/140541
More information about the llvm-commits
mailing list