[InstSimplify] Fold x*C1/C2 <= x (PR48744)
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 17 Jan 2021 14:57:53 +0000 (15:57 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 17 Jan 2021 15:02:55 +0000 (16:02 +0100)
commita13c0f62c38131ef2656b06de02d82110abaf272
treefe5f0ca06a0d0e2b1fd6f8387a16c37c1a6e1e1c
parent4bfbfb9bcb790931b97da972ff02865810f43ce8
[InstSimplify] Fold x*C1/C2 <= x (PR48744)

We can fold x*C1/C2 <= x to true if C1 <= C2. This is valid even
if the multiplication is not nuw: https://alive2.llvm.org/ce/z/vULors

The multiplication or division can be replaced by shifts. We don't
handle the case where both are shifts, as that should get folded
away by InstCombine.
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/icmp.ll