[PATCH] D99069: [ValueTracking] Improve phi handling in isKnownNonEqual()
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 22 11:13:45 PDT 2021
nikic added inline comments.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2459
if (ConstantInt *C = dyn_cast<ConstantInt>(Start)) {
if (!C->isZero() && !C->isNegative()) {
+ BinaryOperator *BO = nullptr;
----------------
I think the matchSimpleRecurrence() check should be higher, e.g. `PN->getNumIncomingValues() == 2` is already part of it.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2461
+ BinaryOperator *BO = nullptr;
+ Value *R = nullptr, *L = nullptr;
+ if (Q.IIQ.UseInstrInfo && matchSimpleRecurrence(PN, BO, R, L)) {
----------------
I'd rename R/L to Start and Step.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2468
+ return true;
+ if (BO->getOpcode() == Instruction::Mul && !C->isOne() &&
+ (BO->hasNoUnsignedWrap() || BO->hasNoSignedWrap()) &&
----------------
Why does this exclude C = 1? `{1,*,2}<nuw>` is still non-zero. The one value is important for inequality, but here we're checking for non-zero.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2471
+ !StepCst->isNegative() && !StepCst->isZero() &&
+ !StepCst->isOne())
+ return true;
----------------
Again, this isOne() check looks unnecessary to me.
================
Comment at: llvm/test/Analysis/ValueTracking/monotonic-phi.ll:61
+exit:
+ %add = or i8 %A, %r
+ %cmp = icmp eq i8 %add, 0
----------------
Why is this or needed?
================
Comment at: llvm/test/Analysis/ValueTracking/monotonic-phi.ll:79
+ %cmp = icmp eq i8 %add, 0
+ ; CHECK-NOT: ret i1 false
+ ret i1 %cmp
----------------
Why does this return false? Isn't this supposed to be a negative test case, due to lack of `nuw`/`nsw`?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99069/new/
https://reviews.llvm.org/D99069
More information about the llvm-commits
mailing list