1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-interchange -cache-line-size=64 -loop-interchange-threshold=-10 -S %s | FileCheck %s
4 ; The test contains a GEP with an operand that is not SCEV-able. Make sure
5 ; loop-interchange does not crash.
6 define void @test(ptr noalias %src, ptr %dst) {
9 ; CHECK-NEXT: br label [[INNER_PREHEADER:%.*]]
10 ; CHECK: outer.header.preheader:
11 ; CHECK-NEXT: br label [[OUTER_HEADER:%.*]]
12 ; CHECK: outer.header:
13 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[OUTER_LATCH:%.*]] ], [ 0, [[OUTER_HEADER_PREHEADER:%.*]] ]
14 ; CHECK-NEXT: br label [[INNER_SPLIT1:%.*]]
15 ; CHECK: inner.preheader:
16 ; CHECK-NEXT: br label [[INNER:%.*]]
18 ; CHECK-NEXT: [[J:%.*]] = phi i64 [ [[TMP0:%.*]], [[INNER_SPLIT:%.*]] ], [ 0, [[INNER_PREHEADER]] ]
19 ; CHECK-NEXT: br label [[OUTER_HEADER_PREHEADER]]
20 ; CHECK: inner.split1:
21 ; CHECK-NEXT: [[SRC_GEP:%.*]] = getelementptr inbounds [256 x float], ptr [[SRC:%.*]], <2 x i64> <i64 0, i64 1>, i64 [[J]]
22 ; CHECK-NEXT: [[SRC_0:%.*]] = extractelement <2 x ptr> [[SRC_GEP]], i32 0
23 ; CHECK-NEXT: [[LV_0:%.*]] = load float, ptr [[SRC_0]], align 4
24 ; CHECK-NEXT: [[ADD_0:%.*]] = fadd float [[LV_0]], 1.000000e+00
25 ; CHECK-NEXT: [[DST_GEP:%.*]] = getelementptr inbounds float, ptr [[DST:%.*]], i64 [[J]]
26 ; CHECK-NEXT: store float [[ADD_0]], ptr [[DST_GEP]], align 4
27 ; CHECK-NEXT: [[J_NEXT:%.*]] = add nuw nsw i64 [[J]], 1
28 ; CHECK-NEXT: [[INNER_EXITCOND:%.*]] = icmp eq i64 [[J_NEXT]], 100
29 ; CHECK-NEXT: br label [[OUTER_LATCH]]
31 ; CHECK-NEXT: [[TMP0]] = add nuw nsw i64 [[J]], 1
32 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[TMP0]], 100
33 ; CHECK-NEXT: br i1 [[TMP1]], label [[EXIT:%.*]], label [[INNER]]
35 ; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I]], 1
36 ; CHECK-NEXT: [[OUTER_EXITCOND:%.*]] = icmp eq i32 [[I_NEXT]], 100
37 ; CHECK-NEXT: br i1 [[OUTER_EXITCOND]], label [[INNER_SPLIT]], label [[OUTER_HEADER]]
39 ; CHECK-NEXT: ret void
42 br label %outer.header
45 %i = phi i32 [ %i.next, %outer.latch ], [ 0, %entry ]
49 %j = phi i64 [ 0, %outer.header ], [ %j.next, %inner ]
50 %src.gep = getelementptr inbounds [256 x float], ptr %src, <2 x i64> <i64 0, i64 1>, i64 %j
51 %src.0 = extractelement <2 x ptr> %src.gep, i32 0
52 %lv.0 = load float, ptr %src.0
53 %add.0 = fadd float %lv.0, 1.0
54 %dst.gep = getelementptr inbounds float, ptr %dst, i64 %j
55 store float %add.0, ptr %dst.gep
56 %j.next = add nuw nsw i64 %j, 1
57 %inner.exitcond = icmp eq i64 %j.next, 100
58 br i1 %inner.exitcond, label %outer.latch, label %inner
61 %i.next = add nuw nsw i32 %i, 1
62 %outer.exitcond = icmp eq i32 %i.next, 100
63 br i1 %outer.exitcond, label %exit, label %outer.header