[InstCombine] Improve folding of mul + icmp
authorAlexander Shaposhnikov <ashaposhnikov@google.com>
Fri, 22 Jul 2022 22:08:47 +0000 (22:08 +0000)
committerAlexander Shaposhnikov <ashaposhnikov@google.com>
Fri, 22 Jul 2022 22:08:53 +0000 (22:08 +0000)
commit2ebfda2417e9cead344b020c1b1b7d3344893291
treec7289acfb8e9b997641420e2c413550c09451078
parent8f0c901c1a172313a32bc06a1fcface76cd1220f
[InstCombine] Improve folding of mul + icmp

This diff adds folds for patterns like X * A < B
where A, B are constants and "mul" has either "nsw" or "nuw".
(to address https://github.com/llvm/llvm-project/issues/56563).

Test plan:
1/ ninja check-llvm check-clang
2/ Bootstrapped LLVM/Clang pass tests

Differential revision: https://reviews.llvm.org/D130039
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Analysis/ValueTracking/known-power-of-two-urem.ll
llvm/test/Transforms/InstCombine/icmp-mul.ll