[PATCH] D36644: [x86] fold the mask op on 8- and 16-bit rotates

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 12 07:18:51 PDT 2017


spatel created this revision.
Herald added a subscriber: mcrosier.

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


https://reviews.llvm.org/D36644

Files:
  lib/Target/X86/X86InstrCompiler.td
  test/CodeGen/X86/rotate4.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36644.110835.patch
Type: text/x-patch
Size: 5009 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170812/699187dc/attachment.bin>


More information about the llvm-commits mailing list