• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -loop-interchange -loop-interchange-threshold=-10 -S %s | FileCheck %s
3
4; The test contains a GEP with an operand that is not SCEV-able. Make sure
5; loop-interchange does not crash.
6define void @test([256 x float]* noalias %src, float* %dst) {
7; CHECK-LABEL: @test(
8; CHECK-NEXT:  entry:
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:%.*]]
17; CHECK:       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], [256 x float]* [[SRC:%.*]], <2 x i64> <i64 0, i64 1>, i64 [[J]]
22; CHECK-NEXT:    [[SRC_0:%.*]] = extractelement <2 x float*> [[SRC_GEP]], i32 0
23; CHECK-NEXT:    [[LV_0:%.*]] = load float, float* [[SRC_0]], align 4
24; CHECK-NEXT:    [[ADD_0:%.*]] = fadd float [[LV_0]], 1.000000e+00
25; CHECK-NEXT:    [[DST_GEP:%.*]] = getelementptr inbounds float, float* [[DST:%.*]], i64 [[J]]
26; CHECK-NEXT:    store float [[ADD_0]], float* [[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]]
30; CHECK:       inner.split:
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]]
34; CHECK:       outer.latch:
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]]
38; CHECK:       exit:
39; CHECK-NEXT:    ret void
40;
41entry:
42  br label %outer.header
43
44outer.header:
45  %i = phi i32 [ %i.next, %outer.latch ], [ 0, %entry ]
46  br label %inner
47
48inner:
49  %j = phi i64 [ 0, %outer.header ], [ %j.next, %inner ]
50  %src.gep = getelementptr inbounds [256 x float], [256 x float]* %src, <2 x i64> <i64 0, i64 1>, i64 %j
51  %src.0 = extractelement <2 x float*> %src.gep, i32 0
52  %lv.0 = load float, float* %src.0
53  %add.0 = fadd float %lv.0, 1.0
54  %dst.gep = getelementptr inbounds float, float* %dst, i64 %j
55  store float %add.0, float* %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
59
60outer.latch:
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
64
65exit:
66  ret void
67}
68