[PATCH] Reassociate GEP operands for loop invariant code motion
Sanjoy Das
sanjoy at playingwithpointers.com
Mon Apr 20 19:09:06 PDT 2015
This looks like it is sharing intent with the loop strength reduction pass. I don't know if that is intentional, just pointing it out.
E.g. `-loop-reduce` does this to `gep_with_const`:
define void @gep_with_const(i32* %input, i32* %output, i64 %a) {
entry:
%0 = add i64 %a, 1234
%scevgep = getelementptr i32, i32* %input, i64 %0
br label %loop
loop: ; preds = %loop, %entry
%lsr.iv1 = phi i32* [ %scevgep2, %loop ], [ %scevgep, %entry ]
%lsr.iv = phi i64 [ %lsr.iv.next, %loop ], [ 1000000, %entry ]
%1 = load i32, i32* %lsr.iv1
store i32 %1, i32* %output
%lsr.iv.next = add nsw i64 %lsr.iv, -1
%scevgep2 = getelementptr i32, i32* %lsr.iv1, i64 1
%exitcond = icmp eq i64 %lsr.iv.next, 0
br i1 %exitcond, label %loop.exit, label %loop
loop.exit: ; preds = %loop
ret void
}
REPOSITORY
rL LLVM
http://reviews.llvm.org/D9136
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list