1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -aa-pipeline=basic-aa -passes=loop-versioning -S %s | FileCheck %s
4 %struct.foo = type { [32000 x double], [32000 x double] }
6 @global = external global %struct.foo, align 32
8 define void @bound_check_partially_known_1(i32 %N) {
9 ; CHECK-LABEL: define void @bound_check_partially_known_1
10 ; CHECK-SAME: (i32 [[N:%.*]]) {
11 ; CHECK-NEXT: loop.lver.check:
12 ; CHECK-NEXT: [[N_EXT:%.*]] = zext i32 [[N]] to i64
13 ; CHECK-NEXT: [[TMP0:%.*]] = shl nuw nsw i64 [[N_EXT]], 3
14 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr @global, i64 [[TMP0]]
15 ; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[N_EXT]], 4
16 ; CHECK-NEXT: [[SCEVGEP1:%.*]] = getelementptr i8, ptr @global, i64 [[TMP1]]
17 ; CHECK-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP0]], 256000
18 ; CHECK-NEXT: [[SCEVGEP2:%.*]] = getelementptr i8, ptr @global, i64 [[TMP2]]
19 ; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult ptr @global, [[SCEVGEP1]]
20 ; CHECK-NEXT: [[BOUND0:%.*]] = icmp ult ptr [[SCEVGEP]], [[SCEVGEP2]]
21 ; CHECK-NEXT: [[BOUND13:%.*]] = icmp ult ptr getelementptr inbounds ([[STRUCT_FOO:%.*]], ptr @global, i64 0, i32 1, i64 0), [[SCEVGEP1]]
22 ; CHECK-NEXT: [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND13]]
23 ; CHECK-NEXT: br i1 [[FOUND_CONFLICT]], label [[LOOP_PH_LVER_ORIG:%.*]], label [[LOOP_PH:%.*]]
24 ; CHECK: loop.ph.lver.orig:
25 ; CHECK-NEXT: br label [[LOOP_LVER_ORIG:%.*]]
26 ; CHECK: loop.lver.orig:
27 ; CHECK-NEXT: [[IV_LVER_ORIG:%.*]] = phi i64 [ 0, [[LOOP_PH_LVER_ORIG]] ], [ [[IV_NEXT_LVER_ORIG:%.*]], [[LOOP_LVER_ORIG]] ]
28 ; CHECK-NEXT: [[GEP_0_IV_LVER_ORIG:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr @global, i64 0, i32 0, i64 [[IV_LVER_ORIG]]
29 ; CHECK-NEXT: [[L_0_LVER_ORIG:%.*]] = load double, ptr [[GEP_0_IV_LVER_ORIG]], align 8
30 ; CHECK-NEXT: [[GEP_1_IV_LVER_ORIG:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr @global, i64 0, i32 1, i64 [[IV_LVER_ORIG]]
31 ; CHECK-NEXT: [[L_1_LVER_ORIG:%.*]] = load double, ptr [[GEP_1_IV_LVER_ORIG]], align 8
32 ; CHECK-NEXT: [[ADD_LVER_ORIG:%.*]] = fadd double [[L_0_LVER_ORIG]], [[L_1_LVER_ORIG]]
33 ; CHECK-NEXT: [[IV_N_LVER_ORIG:%.*]] = add nuw nsw i64 [[IV_LVER_ORIG]], [[N_EXT]]
34 ; CHECK-NEXT: [[GEP_0_IV_N_LVER_ORIG:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr @global, i64 0, i32 0, i64 [[IV_N_LVER_ORIG]]
35 ; CHECK-NEXT: store double [[ADD_LVER_ORIG]], ptr [[GEP_0_IV_N_LVER_ORIG]], align 8
36 ; CHECK-NEXT: [[IV_NEXT_LVER_ORIG]] = add nuw nsw i64 [[IV_LVER_ORIG]], 1
37 ; CHECK-NEXT: [[EXITCOND_LVER_ORIG:%.*]] = icmp eq i64 [[IV_NEXT_LVER_ORIG]], [[N_EXT]]
38 ; CHECK-NEXT: br i1 [[EXITCOND_LVER_ORIG]], label [[EXIT_LOOPEXIT:%.*]], label [[LOOP_LVER_ORIG]]
40 ; CHECK-NEXT: br label [[LOOP:%.*]]
42 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[LOOP_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
43 ; CHECK-NEXT: [[GEP_0_IV:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr @global, i64 0, i32 0, i64 [[IV]]
44 ; CHECK-NEXT: [[L_0:%.*]] = load double, ptr [[GEP_0_IV]], align 8, !alias.scope !0
45 ; CHECK-NEXT: [[GEP_1_IV:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr @global, i64 0, i32 1, i64 [[IV]]
46 ; CHECK-NEXT: [[L_1:%.*]] = load double, ptr [[GEP_1_IV]], align 8, !alias.scope !3
47 ; CHECK-NEXT: [[ADD:%.*]] = fadd double [[L_0]], [[L_1]]
48 ; CHECK-NEXT: [[IV_N:%.*]] = add nuw nsw i64 [[IV]], [[N_EXT]]
49 ; CHECK-NEXT: [[GEP_0_IV_N:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr @global, i64 0, i32 0, i64 [[IV_N]]
50 ; CHECK-NEXT: store double [[ADD]], ptr [[GEP_0_IV_N]], align 8, !alias.scope !5, !noalias !7
51 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
52 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], [[N_EXT]]
53 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[EXIT_LOOPEXIT4:%.*]], label [[LOOP]]
54 ; CHECK: exit.loopexit:
55 ; CHECK-NEXT: br label [[EXIT:%.*]]
56 ; CHECK: exit.loopexit4:
57 ; CHECK-NEXT: br label [[EXIT]]
59 ; CHECK-NEXT: ret void
62 %N.ext = zext i32 %N to i64
66 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
67 %gep.0.iv = getelementptr inbounds %struct.foo, ptr @global, i64 0, i32 0, i64 %iv
68 %l.0 = load double, ptr %gep.0.iv, align 8
69 %gep.1.iv = getelementptr inbounds %struct.foo, ptr @global, i64 0, i32 1, i64 %iv
70 %l.1 = load double, ptr %gep.1.iv, align 8
71 %add = fadd double %l.0, %l.1
72 %iv.N = add nuw nsw i64 %iv, %N.ext
73 %gep.0.iv.N = getelementptr inbounds %struct.foo, ptr @global, i64 0, i32 0, i64 %iv.N
74 store double %add, ptr %gep.0.iv.N, align 8
75 %iv.next = add nuw nsw i64 %iv, 1
76 %exitcond = icmp eq i64 %iv.next, %N.ext
77 br i1 %exitcond, label %exit, label %loop