[PATCH] D159203: [InstCombine] Fold (A/-B)==(A/B) to (A/B)==0
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 19 18:37:24 PDT 2023
goldstein.w.n added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:5239
+ if (match(Op0, m_OneUse(m_SDiv(m_Value(A), m_OneUse(m_Neg(m_Value(B)))))) &&
+ match(Op1, m_SDiv(m_Specific(A), m_Specific(B)))) {
+ // Check if A is known to be != INT_MIN
----------------
goldstein.w.n wrote:
> This is a commutative pattern. Think should either put in a lambda so you can pass op0,op1 then op1,op0 or `m_c_ICmp(Pred, Pattern0, Pattern1)`.
Actually probably easier is something like:
```
if(match(Op0, S_Div(m_Value(A), m_Value(B))) && match(Op1, S_Div(m_Specific(A), m_Value(C))) {
D = nullptr;
if(match(B, m_Neg(m_Specific(C)) && Op0->hasOneUse()) {
D = B;
}
else if(match(C, m_Neg(m_Specific(B)) && Op1->hasOneUse()) {
D = C;
}
if(D) {
...
}
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D159203/new/
https://reviews.llvm.org/D159203
More information about the llvm-commits
mailing list