1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='loop-load-elim,indvars,loop-distribute' -enable-loop-distribute -S %s | FileCheck %s
4 define void @test_pr50940(ptr %A, ptr %B) {
5 ; CHECK-LABEL: @test_pr50940(
7 ; CHECK-NEXT: br label [[OUTER_HEADER:%.*]]
9 ; CHECK-NEXT: br i1 false, label [[OUTER_LATCH:%.*]], label [[INNER_PH:%.*]]
11 ; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 4
12 ; CHECK-NEXT: [[GEP_A_3:%.*]] = getelementptr inbounds i16, ptr [[A]], i64 3
13 ; CHECK-NEXT: br label [[INNER_LVER_CHECK:%.*]]
14 ; CHECK: inner.lver.check:
15 ; CHECK-NEXT: [[UGLYGEP1:%.*]] = getelementptr i8, ptr [[A]], i64 8
16 ; CHECK-NEXT: [[UGLYGEP2:%.*]] = getelementptr i8, ptr [[B:%.*]], i64 2
17 ; CHECK-NEXT: [[BOUND0:%.*]] = icmp ult ptr [[UGLYGEP]], [[UGLYGEP2]]
18 ; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult ptr [[B]], [[UGLYGEP1]]
19 ; CHECK-NEXT: [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]]
20 ; CHECK-NEXT: br i1 [[FOUND_CONFLICT]], label [[INNER_PH3_LVER_ORIG:%.*]], label [[INNER_PH3_LDIST1:%.*]]
21 ; CHECK: inner.ph3.lver.orig:
22 ; CHECK-NEXT: br label [[INNER_LVER_ORIG:%.*]]
23 ; CHECK: inner.lver.orig:
24 ; CHECK-NEXT: [[IV_LVER_ORIG:%.*]] = phi i16 [ 0, [[INNER_PH3_LVER_ORIG]] ], [ [[IV_NEXT_LVER_ORIG:%.*]], [[INNER_LVER_ORIG]] ]
25 ; CHECK-NEXT: [[L_LVER_ORIG:%.*]] = load <2 x i16>, ptr [[UGLYGEP]], align 1
26 ; CHECK-NEXT: store i16 0, ptr [[GEP_A_3]], align 1
27 ; CHECK-NEXT: store i16 1, ptr [[B]], align 1
28 ; CHECK-NEXT: [[IV_NEXT_LVER_ORIG]] = add nuw nsw i16 [[IV_LVER_ORIG]], 1
29 ; CHECK-NEXT: [[C_1_LVER_ORIG:%.*]] = icmp ult i16 [[IV_LVER_ORIG]], 38
30 ; CHECK-NEXT: br i1 [[C_1_LVER_ORIG]], label [[INNER_LVER_ORIG]], label [[EXIT_LOOPEXIT:%.*]]
31 ; CHECK: inner.ph3.ldist1:
32 ; CHECK-NEXT: br label [[INNER_LDIST1:%.*]]
33 ; CHECK: inner.ldist1:
34 ; CHECK-NEXT: [[IV_LDIST1:%.*]] = phi i16 [ 0, [[INNER_PH3_LDIST1]] ], [ [[IV_NEXT_LDIST1:%.*]], [[INNER_LDIST1]] ]
35 ; CHECK-NEXT: [[L_LDIST1:%.*]] = load <2 x i16>, ptr [[UGLYGEP]], align 1, !alias.scope !0, !noalias !3
36 ; CHECK-NEXT: store i16 0, ptr [[GEP_A_3]], align 1, !alias.scope !0, !noalias !3
37 ; CHECK-NEXT: [[IV_NEXT_LDIST1]] = add nuw nsw i16 [[IV_LDIST1]], 1
38 ; CHECK-NEXT: [[C_1_LDIST1:%.*]] = icmp ult i16 [[IV_LDIST1]], 38
39 ; CHECK-NEXT: br i1 [[C_1_LDIST1]], label [[INNER_LDIST1]], label [[INNER_PH3:%.*]]
41 ; CHECK-NEXT: br label [[INNER:%.*]]
43 ; CHECK-NEXT: [[IV:%.*]] = phi i16 [ 0, [[INNER_PH3]] ], [ [[IV_NEXT:%.*]], [[INNER]] ]
44 ; CHECK-NEXT: store i16 1, ptr [[B]], align 1, !alias.scope !3
45 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i16 [[IV]], 1
46 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i16 [[IV]], 38
47 ; CHECK-NEXT: br i1 [[C_1]], label [[INNER]], label [[EXIT_LOOPEXIT4:%.*]]
49 ; CHECK-NEXT: br label [[OUTER_HEADER]]
50 ; CHECK: exit.loopexit:
51 ; CHECK-NEXT: br label [[EXIT:%.*]]
52 ; CHECK: exit.loopexit4:
53 ; CHECK-NEXT: br label [[EXIT]]
55 ; CHECK-NEXT: ret void
58 %gep.A.1 = getelementptr inbounds i16, ptr %A, i64 1
59 br label %outer.header
62 %gep.A.2 = getelementptr inbounds i16, ptr %gep.A.1, i64 1
63 br i1 false, label %outer.latch, label %inner.ph
65 inner.ph: ; preds = %for.body5
66 %lcssa.gep = phi ptr [ %gep.A.2, %outer.header ]
67 %gep.A.3 = getelementptr inbounds i16, ptr %A, i64 3
71 %iv = phi i16 [ 0, %inner.ph ], [ %iv.next, %inner ]
72 %l = load <2 x i16>, ptr %lcssa.gep, align 1
73 store i16 0, ptr %gep.A.3, align 1
74 store i16 1, ptr %B, align 1
75 %iv.next = add nuw nsw i16 %iv, 1
76 %c.1 = icmp ult i16 %iv, 38
77 br i1 %c.1, label %inner, label %exit
80 br label %outer.header