-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed as not planned
Closed as not planned
Copy link
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillaloopoptimobsoleteIssues with old (unsupported) versions of LLVMIssues with old (unsupported) versions of LLVM
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;
}
}
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillaloopoptimobsoleteIssues with old (unsupported) versions of LLVMIssues with old (unsupported) versions of LLVM