1 ; RUN: opt %loadPolly -polly-codegen -polly-invariant-load-hoisting=true -S < %s | FileCheck %s
3 ; int f(int *A, int *B) {
4 ; // Possible aliasing between A and B but if not then *B would be
5 ; // invariant. We assume this and hoist *B but need to use a merged
6 ; // version in the return.
13 ; } while (i++ < 100);
18 ; CHECK: polly.preload.begin:
19 ; CHECK: %polly.access.B = getelementptr i32, ptr %B, i64 0
20 ; CHECK: %polly.access.B.load = load i32, ptr %polly.access.B
21 ; CHECK: store i32 %polly.access.B.load, ptr %tmp.preload.s2a
23 ; CHECK: polly.merge_new_and_old:
24 ; CHECK: %tmp.merge = phi i32 [ %tmp.final_reload, %polly.exiting ], [ %tmp, %do.cond ]
25 ; CHECK: br label %do.end
28 ; CHECK: ret i32 %tmp.merge
30 ; CHECK: polly.loop_exit:
31 ; CHECK: %tmp.final_reload = load i32, ptr %tmp.preload.s2a
33 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
35 define i32 @f(ptr %A, ptr %B) {
39 do.body: ; preds = %do.cond, %entry
40 %indvars.iv = phi i64 [ %indvars.iv.next, %do.cond ], [ 0, %entry ]
41 %tmp = load i32, ptr %B, align 4
42 %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
43 %tmp1 = load i32, ptr %arrayidx, align 4
44 %add = add nsw i32 %tmp1, %tmp
45 store i32 %add, ptr %arrayidx, align 4
48 do.cond: ; preds = %do.body
49 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
50 %exitcond = icmp ne i64 %indvars.iv.next, 101
51 br i1 %exitcond, label %do.body, label %do.end
53 do.end: ; preds = %do.cond