PPC: Optimize rldicl generation for masked shifts
authorHal Finkel <hfinkel@anl.gov>
Wed, 20 Nov 2013 01:10:15 +0000 (01:10 +0000)
committerHal Finkel <hfinkel@anl.gov>
Wed, 20 Nov 2013 01:10:15 +0000 (01:10 +0000)
commiteda8f6708dabe00783297063f72a5a677e20f43f
tree920a09cfa5c378ccd5ed355aa7b7893c2986b0eb
parent9259787e4f3b36d1712c821eead62e7faad3ecd4
PPC: Optimize rldicl generation for masked shifts

Masking operations (where only some number of the low bits are being kept) are
selected to rldicl(x, 0, mb). If x is a logical right shift (which would become
rldicl(y, 64-n, n)), we might be able to fold the two instructions together:

  rldicl(rldicl(x, 64-n, n), 0, mb) -> rldicl(x, 64-n, mb) for n <= mb

The right shift is really a left rotate followed by a mask, and if the explicit
mask is a more-restrictive sub-mask of the mask implied by the shift, only one
rldicl is needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195185 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCISelDAGToDAG.cpp
test/CodeGen/PowerPC/srl-mask.ll [new file with mode: 0644]