[llvm] [InstCombine] Simplify `(add/sub (sub/add) (sub/add))` irrelivant of use-count (PR #105866)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 25 02:32:07 PDT 2024
================
@@ -2008,6 +2008,30 @@ static bool shouldMergeGEPs(GEPOperator &GEP, GEPOperator &Src) {
return true;
}
+Instruction *InstCombinerImpl::foldAddLike(Value *LHS, Value *RHS, bool NSW,
----------------
nikic wrote:
I'd also add `foldAddLikeCommutative()` which is invoked with both LHS/RHS orders, as most add folds with non-constant RHS will want to check both orders.
Then your pattern here will reduce down to:
```
if (match(LHS, m_Sub(m_Value(A), m_Value(B))) &&
match(RHS, m_Sub(m_Value(C), m_Specific(A)))) {
```
https://github.com/llvm/llvm-project/pull/105866
More information about the llvm-commits
mailing list