[InstSimplify] fold icmp with mul nuw and constant operands
authorSanjay Patel <spatel@rotateright.com>
Wed, 5 Aug 2020 17:41:05 +0000 (13:41 -0400)
committerSanjay Patel <spatel@rotateright.com>
Wed, 5 Aug 2020 18:32:17 +0000 (14:32 -0400)
commitf879c9b796210d0b2407d022e216cc4d907818a3
tree5c9ceb2871cdcbfc5423d2dd8f9f634cbb9dfea1
parenta569a0af0d96512e1d914f2e966453391f4b9561
[InstSimplify] fold icmp with mul nuw and constant operands

https://rise4fun.com/Alive/pZEr

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

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

There are potentially several other transforms we need to add based on:
D51625
...but it doesn't look like there was follow-up to that patch.
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstCombine/icmp-mul.ll
llvm/test/Transforms/InstSimplify/icmp-constant.ll