[llvm] [InstCombine] Simplify `(add/sub (sub/add) (sub/add))` irrelivant of use-count (PR #105866)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 24 02:01:14 PDT 2024
================
@@ -2286,6 +2289,33 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) {
}
}
+ {
+ Value *W, *Z;
+ if (match(Op0, m_AddLike(m_Value(W), m_Value(X))) &&
+ match(Op1, m_AddLike(m_Value(Y), m_Value(Z)))) {
+ Instruction *R = nullptr;
+ if (W == Y)
+ R = BinaryOperator::CreateSub(X, Z);
+ if (W == Z)
----------------
dtcxzyw wrote:
```suggestion
else if (W == Z)
```
We will create unused sub when W == Y && W == Z.
https://github.com/llvm/llvm-project/pull/105866
More information about the llvm-commits
mailing list