OSDN Git Service

[InstCombine] narrow width of rotate patterns, part 2 (PR39624)
authorSanjay Patel <spatel@rotateright.com>
Mon, 12 Nov 2018 22:11:09 +0000 (22:11 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 12 Nov 2018 22:11:09 +0000 (22:11 +0000)
commit772bdfc7825d23fdf2233ffdc9b6a8268d5751d8
tree7ebf1541ca74ffb38ca920eac5c793bcdda5c9ce
parent4606305565453e29d6637d76f5502e4e59ccd4b8
[InstCombine] narrow width of rotate patterns, part 2 (PR39624)

The sub-pattern for the shift amount in a rotate can take on
several different forms, and there's apparently no way to
canonicalize those without seeing the entire rotate sequence.

This is the form noted in:
https://bugs.llvm.org/show_bug.cgi?id=39624

https://rise4fun.com/Alive/qnT

  %zx = zext i8 %x to i32
  %maskedShAmt = and i32 %shAmt, 7
  %shl = shl i32 %zx, %maskedShAmt
  %negShAmt = sub i32 0, %shAmt
  %maskedNegShAmt = and i32 %negShAmt, 7
  %shr = lshr i32 %zx, %maskedNegShAmt
  %rot = or i32 %shl, %shr
  %r = trunc i32 %rot to i8
  =>
  %truncShAmt = trunc i32 %shAmt to i8
  %maskedShAmt2 = and i8 %truncShAmt, 7
  %shl2 = shl i8 %x, %maskedShAmt2
  %negShAmt2 = sub i8 0, %truncShAmt
  %maskedNegShAmt2 = and i8 %negShAmt2, 7
  %shr2 = lshr i8 %x, %maskedNegShAmt2
  %r = or i8 %shl2, %shr2

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346713 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineCasts.cpp
test/Transforms/InstCombine/rotate.ll