[LLVMbugs] [Bug 18646] New: Loop reroller not able to reroll when the array base address is a derivative of the loop induction variable

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jan 28 11:35:42 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18646

            Bug ID: 18646
           Summary: Loop reroller not able to reroll when the array base
                    address is a derivative of the loop induction variable
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: opt
          Assignee: unassignedbugs at nondot.org
          Reporter: chrisj at codeaurora.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11960
  --> http://llvm.org/bugs/attachment.cgi?id=11960&action=edit
test.c

The loop reroller is not able to reroll loops of the form where the array base
address is a derivative of the loop induction variable.

$ cat test.c

void foo(int *Arr, int n) {
  for (int i = 0; i < n; i += 3) {
     Arr[0]=0;
     Arr[1]=0;
     Arr[2]=0;
     Arr+=3;
   }
}


$ clang -target -arm-none-linux-gnueabi reroll.cpp -S  -O1 -emit-llvm -o
test.ll
$ opt -loop-reroll  -S test.ll -debug-only=loop-reroll -stats

This is probably because as the array accesses are not a function of the loop
induction variable, which is the loop body form the reroller pass requires.

$ cat test.ll
..
..
for.body:                                         ; preds = %entry, %for.body
  %i.09 = phi i32 [ %add, %for.body ], [ 0, %entry ]
  %Arr.addr.08 = phi i32* [ %add.ptr, %for.body ], [ %Arr, %entry ]
  store i32 0, i32* %Arr.addr.08, align 4, !tbaa !1
..
..


The following pattern is successfully rerolled as it satisfies the requirement,

void foo(int *Arr, int n) {
  for (int i = 0; i < n; i += 3) {
     Arr[i]=0;
     Arr[i+1]=0;
     Arr[i+2]=0;
   }
}

-- 
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/20140128/398f92cf/attachment.html>


More information about the llvm-bugs mailing list