1 ; RUN: opt < %s -passes='require<loops>,gvn' -enable-load-in-loop-pre=false -S | FileCheck %s
2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
4 ;void test1(int N, ptr G) {
6 ; for (j = 0; j < N - 1; j++)
7 ; G[j] = G[j] + G[j+1];
10 define void @test1(i32 %N, ptr nocapture %G) nounwind ssp {
11 ; CHECK-LABEL: @test1(
14 %1 = icmp sgt i32 %0, 0
15 br i1 %1, label %bb.nph, label %return
18 %tmp = zext i32 %0 to i64
22 ; CHECK-NOT: load double, ptr
26 %indvar = phi i64 [ 0, %bb.nph ], [ %tmp6, %bb ]
27 %tmp6 = add i64 %indvar, 1
28 %scevgep = getelementptr double, ptr %G, i64 %tmp6
29 %scevgep7 = getelementptr double, ptr %G, i64 %indvar
30 %2 = load double, ptr %scevgep7, align 8
31 %3 = load double, ptr %scevgep, align 8
32 %4 = fadd double %2, %3
33 store double %4, ptr %scevgep7, align 8
34 %exitcond = icmp eq i64 %tmp6, %tmp
35 br i1 %exitcond, label %return, label %bb
37 ; Both loads should remain in the loop.
39 ; CHECK: load double, ptr
40 ; CHECK: load double, ptr
41 ; CHECK: br i1 %exitcond