[InstCombine] fold mask op into casted shift (PR46013)
authorSanjay Patel <spatel@rotateright.com>
Sun, 7 Jun 2020 13:03:45 +0000 (09:03 -0400)
committerSanjay Patel <spatel@rotateright.com>
Sun, 7 Jun 2020 13:33:18 +0000 (09:33 -0400)
commit2552f65183ebb43cdd6de951c63a3dcbfa021b5e
tree5bb66e5aa5f15ef465e67517e6e0461aee7ae6d1
parentc6719d0b47086b7c8560b8641ab574ec8e208000
[InstCombine] fold mask op into casted shift (PR46013)

https://rise4fun.com/Alive/Qply8

  Pre: C2 == (-1 u>> zext(C1))
  %a = ashr %x, C1
  %s = sext %a to i16
  %r = and i16 %s, C2
    =>
  %s2 = sext %x to i16
  %r = lshr i16 %s2, zext(C1)

https://bugs.llvm.org/show_bug.cgi?id=46013
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/and.ll