[PATCH] D148986: [InstSimplify] with logical ops: (X | Y) ? 0 : X --> 0
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 23 09:50:29 PDT 2023
nikic added inline comments.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4597
+ Q, MaxRecurse))
+ return V;
}
----------------
Not quite the code structure I had in mind. Rather than handling or in simplifySelectWithICmpEq, I'd expect something like this in here:
```
if (match(CmpLHS, m_Or(m_Value(X), m_Value(Y))) && match(CmpRHS, m_Zero())) {
// X | Y == 0 implies X == 0 and Y == 0.
if (Value *V = simplifySelectWithICmpEq(X, CmpRHS, TrueVal, FalseVal, Q,
MaxRecurse))
return V;
if (Value *V = simplifySelectWithICmpEq(Y, CmpRHS, TrueVal, FalseVal, Q,
MaxRecurse))
return V;
}
```
That is, we handle the straightforward equality, and then we try to handle the implied equalities from the icmp or.
================
Comment at: llvm/test/Transforms/InstSimplify/select-cmp-or.ll:2
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=instsimplify,instcombine -S | FileCheck %s
+
----------------
Why does this also run instcombine?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148986/new/
https://reviews.llvm.org/D148986
More information about the llvm-commits
mailing list