[InstCombine] improve matching for sext-lshr-trunc patterns
authorSanjay Patel <spatel@rotateright.com>
Mon, 8 Jun 2020 15:37:43 +0000 (11:37 -0400)
committerSanjay Patel <spatel@rotateright.com>
Mon, 8 Jun 2020 15:55:30 +0000 (11:55 -0400)
commit42f488b63a04fdaa931315bdadecb6d23e20529a
tree90c6ca15c4f2f1ebecb35f048c7aec1e6bf9042d
parent8b529e311a9052ee7a0676a1b517728efa44a3ba
[InstCombine] improve matching for sext-lshr-trunc patterns

This is intended to preserve the logic of the existing transform,
but remove unnecessary restrictions on uses and types.

https://rise4fun.com/Alive/pYfR

  Pre: C1 <= width(C1) - 8
  %B = sext i8 %A
  %C = lshr %B, C1
  %r = trunc %C to i8
   =>
  %r = ashr i8 %A, trunc(umin(C1, 7))
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/test/Transforms/InstCombine/cast.ll