Closed as not planned
Closed as not planned
Description
Bugzilla Link | 18646 |
Version | trunk |
OS | Linux |
Attachments | test.c, test.ll |
Reporter | LLVM Bugzilla Contributor |
CC | @hfinkel |
Extended Description
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;
}
}