This is an archive of the discontinued LLVM Phabricator instance.

[x86] fold the mask op on 8- and 16-bit rotates
ClosedPublic

Authored by spatel on Aug 12 2017, 7:18 AM.

Details

Summary

Ref the post-commit thread for r310770:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20170807/478507.html

The motivating cases as 'C' source examples can look like this:

unsigned char rotate_right_8(unsigned char v, int shift) {
  //shift &= 7;
  v = ( v >> shift ) | ( v << ( 8 - shift ) );
  return v;
}

https://godbolt.org/g/K6rc1A

Notice that the source doesn't contain UB-safe masked shift amounts, but instcombine created those in order to produce narrow rotate patterns.
This should be the last step needed to resolve PR34046:
https://bugs.llvm.org/show_bug.cgi?id=34046

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.Aug 12 2017, 7:18 AM
This revision is now accepted and ready to land.Aug 12 2017, 12:31 PM
This revision was automatically updated to reflect the committed changes.