[llvm-bugs] [Bug 36854] New: [LSR] Bad code generation from LSR
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Wed Mar 21 09:20:19 PDT 2018
    
    
  
https://bugs.llvm.org/show_bug.cgi?id=36854
            Bug ID: 36854
           Summary: [LSR] Bad code generation from LSR
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: junbuml at codeaurora.org
                CC: llvm-bugs at lists.llvm.org
For the C code below, the transformation done by LSR cause bad code generation
on AArch64. 
int isTrue();
void test(int M, int *P, int *P2, int *P3, int *P4) {
  int t = 0;
  for (int k = 1; k <= M; ++k) {
    P[k] = P2[k-1] + P[k-1];
    P3[k] = P2[k-1] + P3[k-1];
    if (isTrue()) {
      P4[k] = P[k] + P2[k];
    }
  }
}
# Current code generation  -----------------------------------------
.LBB0_2:
        ldr     w8, [x19]
        ldur    w9, [x20, #-4]
        add     w8, w9, w8
        str     w8, [x20]
        ldr     w8, [x19]
        ldur    w9, [x21, #-4]
        add     w8, w9, w8
        str     w8, [x21]
        bl      isTrue
        cbz     w0, .LBB0_4
// %bb.3:                               // %if.then
        ldr     w8, [x20]
        ldr     w9, [x19, #4]
        add     w8, w9, w8
        str     w8, [x23]
.LBB0_4:                                // %for.inc
                                        //   in Loop: Header=BB0_2 Depth=1
        subs    x22, x22, #1            // =1
        add     x20, x20, #4            // =4
        add     x21, x21, #4            // =4
        add     x23, x23, #4            // =4
        add     x19, x19, #4            // =4
        b.ne    .LBB0_2
#Code when skipping LSR --------------------------------------------------
.LBB0_2:                                // %for.body
                                        // =>This Inner Loop Header: Depth=1
        lsl     x25, x24, #2
        sub     x8, x25, #4             // =4
        ldr     w9, [x21, x8]
        ldr     w10, [x22, x8]
        add     w9, w10, w9
        str     w9, [x22, x25]
        ldr     w9, [x21, x8]
        ldr     w8, [x20, x8]
        add     w8, w8, w9
        str     w8, [x20, x25]
        bl      isTrue
        cbz     w0, .LBB0_4
// %bb.3:                               // %if.then
                                        //   in Loop: Header=BB0_2 Depth=1
        ldr     w8, [x22, x25]
        ldr     w9, [x21, x25]
        add     w8, w9, w8
        str     w8, [x19, x25]
.LBB0_4:                                // %for.inc
                                        //   in Loop: Header=BB0_2 Depth=1
        add     x24, x24, #1            // =1
        cmp     x24, x23
        b.ne    .LBB0_2
-- 
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/20180321/d48f0f11/attachment.html>
    
    
More information about the llvm-bugs
mailing list