[PATCH] D114279: [InstSimplify] Fold X {lshr,udiv} C <u X --> true for nonzero X, non-identity C
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 22 10:51:58 PST 2021
spatel added inline comments.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:2950-2951
+ // If x is nonzero:
+ // x >> C <u x --> true for C > 0.
+ // x udiv C <u x --> true for C > 1.
+ // TODO: allow non-constant shift amount/divisor
----------------
Spell out the other preds/patterns for completeness? Might want to improve the comments on the block above here while we're at it to show the transform instead of just matched pattern.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:2952
+ // x udiv C <u x --> true for C > 1.
+ // TODO: allow non-constant shift amount/divisor
+ const APInt *C;
----------------
Is that TODO feasible? The lshr half could use isKnownNonZero, but how would we deal with ">1" for udiv?
================
Comment at: llvm/test/Transforms/InstSimplify/compare.ll:581
define i1 @lshr_nonzero1(i32 %x) {
; CHECK-LABEL: @lshr_nonzero1(
----------------
Put the predicate in the test name rather than incrementing the '1' suffix. That makes it clearer that we're cycling through the preds. Add a couple of negative tests for signed preds?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114279/new/
https://reviews.llvm.org/D114279
More information about the llvm-commits
mailing list