[llvm-bugs] [Bug 37421] New: [AArch64] Generated code for rotate-lefts has an unnecessary extra and

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 11 12:17:00 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37421

            Bug ID: 37421
           Summary: [AArch64] Generated code for rotate-lefts has an
                    unnecessary extra and
           Product: libraries
           Version: 6.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedbugs at nondot.org
          Reporter: fabiang at radgametools.com
                CC: llvm-bugs at lists.llvm.org

void rotateInLoop2(unsigned int *arr, const bool *control, int count, int rot0,
int rot1)
{
    for (int i = 0; i < count; ++i)
    {
        int rot = control[i] ? rot1 : rot0;
        arr[i] = (arr[i] << (rot & 31)) | (arr[i] >> (-rot & 31));
    }
}

clang 6.0 "clang -O2 -fno-tree-vectorize -target aarch64-linux-android"
produces for the main loop:

.LBB1_2: // =>This Inner Loop Header: Depth=1
  ldrb w9, [x1], #1
  ldr w10, [x0]
  cmp w9, #0 // =0
  csel w9, w3, w4, eq
  neg w9, w9
  and w9, w9, #0x1f // <-- this is unnecessary
  ror w9, w10, w9
  subs x8, x8, #1 // =1
  str w9, [x0], #4
  b.ne .LBB1_2

Probably related to https://bugs.llvm.org/show_bug.cgi?id=27582
The conditional select for the "rot" is to work around the issue with shift
counts hoisted outside the loop mentioned in
https://bugs.llvm.org/show_bug.cgi?id=37387

-fno-tree-vectorize because with vectorization on, the loop gets unrolled 2x
(presumably to use ldp/stp?)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180511/f22f4147/attachment.html>


More information about the llvm-bugs mailing list