[PATCH] D47735: [DAGCombiner] Create rotates more aggressively

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 20 15:42:11 PST 2019


spatel added a comment.

In D47735#1404861 <https://reviews.llvm.org/D47735#1404861>, @kparzysz wrote:

> One goal was to be able to generate rol-and-accumulate instruction (on Hexagon), specifically for the accumulate operation being | (see `f11` in rotate.ll).  For the C code we still don't generate it:
>
>   unsigned blah(unsigned s, unsigned x) {
>     return s | (x << 27) | (x >> 5);
>   }
>


We need reassociation to happen in the IR optimizer if we want to recognize this as rotate (there could be any number of intermediate ops separating the 2 halves of the rotate):

  define i32 @blah(i32 %x, i32 %s) {
    %shl = shl i32 %x, 27
    %or = or i32 %shl, %s
    %shr = lshr i32 %x, 5
    %or1 = or i32 %or, %shr <--- the 1st 'or' is between the rotated halves
    ret i32 %or1
  }

D45842 <https://reviews.llvm.org/D45842> was hoping to do something like that too. Note also that we don't currently canonicalize shl/shr/or with a constant shift amount to a rotate because that wasn't noted as a problem case, but this example suggests that we should do that.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D47735/new/

https://reviews.llvm.org/D47735





More information about the llvm-commits mailing list