[InstSimplify] fold icmp with mul nsw and constant operands
authorSanjay Patel <spatel@rotateright.com>
Wed, 5 Aug 2020 18:37:05 +0000 (14:37 -0400)
committerSanjay Patel <spatel@rotateright.com>
Wed, 5 Aug 2020 18:38:39 +0000 (14:38 -0400)
commite8760bb9a8a3a22fe22302ffe1932c13c3fcff8e
tree05a7702adc3a40a2e19727f1325a54c357819a9e
parentfcb0d8163a4f3090cb85d77b459887cf1f84cc7e
[InstSimplify] fold icmp with mul nsw and constant operands

https://rise4fun.com/Alive/slvl

  Name: mul nsw with icmp eq
  Pre: (C2 % C1) != 0
  %a = mul nsw i8 %x, C1
  %r = icmp eq i8 %a, C2
    =>
  %r = false

  Name: mul nsw with icmp ne
  Pre: (C2 % C1) != 0
  %a = mul nsw i8 %x, C1
  %r = icmp ne i8 %a, C2
    =>
  %r = true

Follow-up to the 'nuw' variation added with:
rGf879c9b79621
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstCombine/icmp-mul.ll
llvm/test/Transforms/InstSimplify/icmp-constant.ll