OSDN Git Service

[InstCombine] narrow width of rotate patterns, part 3
authorSanjay Patel <spatel@rotateright.com>
Mon, 12 Nov 2018 22:52:25 +0000 (22:52 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 12 Nov 2018 22:52:25 +0000 (22:52 +0000)
commit2b46d375af65a93a6ff1a86848789ca9853363de
tree11383aedc2f55b72c1fa6403596147f0c664dd3a
parent56217334622780cb224f1410afcee7417123c59b
[InstCombine] narrow width of rotate patterns, part 3

This is a longer variant for the pattern handled in
rL346713
This one includes zexts.

Eventually, we should canonicalize all rotate patterns
to the funnel shift intrinsics, but we need a bit more
infrastructure to make sure the vectorizers handle those
intrinsics as well as the shift+logic ops.

https://rise4fun.com/Alive/FMn

Name: narrow rotateright
  %neg = sub i8 0, %shamt
  %rshamt = and i8 %shamt, 7
  %rshamtconv = zext i8 %rshamt to i32
  %lshamt = and i8 %neg, 7
  %lshamtconv = zext i8 %lshamt to i32
  %conv = zext i8 %x to i32
  %shr = lshr i32 %conv, %rshamtconv
  %shl = shl i32 %conv, %lshamtconv
  %or = or i32 %shl, %shr
  %r = trunc i32 %or to i8
  =>
  %maskedShAmt2 = and i8 %shamt, 7
  %negShAmt2 = sub i8 0, %shamt
  %maskedNegShAmt2 = and i8 %negShAmt2, 7
  %shl2 = lshr i8 %x, %maskedShAmt2
  %shr2 = shl i8 %x, %maskedNegShAmt2
  %r = or i8 %shl2, %shr2

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