1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -loop-vectorize -force-vector-width=2 %s -S | FileCheck %s
4 ; Test case for PR47343. Make sure LCSSA phis are create correctly when
5 ; expanding the memory runtime checks.
7 @f.e = external global i32, align 1
8 @d = external global i8*, align 1
15 ; CHECK-NEXT: br label [[OUTER_HEADER:%.*]]
16 ; CHECK: outer.header:
17 ; CHECK-NEXT: [[TMP0:%.*]] = load i8*, i8** @d, align 1
18 ; CHECK-NEXT: [[C_0:%.*]] = call i1 @cond()
19 ; CHECK-NEXT: br i1 [[C_0]], label [[OUTER_EXIT_0:%.*]], label [[INNER_1_HEADER_PREHEADER:%.*]]
20 ; CHECK: inner.1.header.preheader:
21 ; CHECK-NEXT: br label [[INNER_1_HEADER:%.*]]
22 ; CHECK: inner.1.header:
23 ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond()
24 ; CHECK-NEXT: br i1 [[C_1]], label [[INNER_1_LATCH:%.*]], label [[OUTER_LATCH:%.*]]
25 ; CHECK: inner.1.latch:
26 ; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond()
27 ; CHECK-NEXT: br i1 [[C_2]], label [[OUTER_EXIT_1:%.*]], label [[INNER_1_HEADER]]
29 ; CHECK-NEXT: br label [[OUTER_HEADER]]
30 ; CHECK: outer.exit.0:
31 ; CHECK-NEXT: [[DOTLCSSA:%.*]] = phi i8* [ [[TMP0]], [[OUTER_HEADER]] ]
32 ; CHECK-NEXT: br label [[LOOP_PREHEADER:%.*]]
33 ; CHECK: outer.exit.1:
34 ; CHECK-NEXT: [[DOTLCSSA1:%.*]] = phi i8* [ [[TMP0]], [[INNER_1_LATCH]] ]
35 ; CHECK-NEXT: br label [[LOOP_PREHEADER]]
36 ; CHECK: loop.preheader:
37 ; CHECK-NEXT: [[TMP1:%.*]] = phi i8* [ [[DOTLCSSA]], [[OUTER_EXIT_0]] ], [ [[DOTLCSSA1]], [[OUTER_EXIT_1]] ]
38 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_MEMCHECK:%.*]]
39 ; CHECK: vector.memcheck:
40 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[TMP1]], i64 1
41 ; CHECK-NEXT: [[BOUND0:%.*]] = icmp ult i8* bitcast (i32* @f.e to i8*), [[SCEVGEP]]
42 ; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult i8* [[TMP1]], bitcast (i32* getelementptr inbounds (i32, i32* @f.e, i64 1) to i8*)
43 ; CHECK-NEXT: [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]]
44 ; CHECK-NEXT: [[MEMCHECK_CONFLICT:%.*]] = and i1 [[FOUND_CONFLICT]], true
45 ; CHECK-NEXT: br i1 [[MEMCHECK_CONFLICT]], label [[SCALAR_PH]], label [[VECTOR_PH:%.*]]
47 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
49 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
50 ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[INDEX]], 0
51 ; CHECK-NEXT: store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
52 ; CHECK-NEXT: store i32 0, i32* @f.e, align 1, !alias.scope !0, !noalias !3
53 ; CHECK-NEXT: store i8 10, i8* [[TMP0]], align 1
54 ; CHECK-NEXT: store i8 10, i8* [[TMP0]], align 1
55 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 2
56 ; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[INDEX_NEXT]], 500
57 ; CHECK-NEXT: br i1 [[TMP3]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP5:![0-9]+]]
58 ; CHECK: middle.block:
59 ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i32 500, 500
60 ; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[SCALAR_PH]]
62 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i32 [ 500, [[MIDDLE_BLOCK]] ], [ 0, [[LOOP_PREHEADER]] ], [ 0, [[VECTOR_MEMCHECK]] ]
63 ; CHECK-NEXT: br label [[LOOP:%.*]]
65 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[IV_NEXT:%.*]], [[LOOP]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
66 ; CHECK-NEXT: [[CONV6_US_US_US:%.*]] = zext i1 false to i32
67 ; CHECK-NEXT: store i32 [[CONV6_US_US_US]], i32* @f.e, align 1
68 ; CHECK-NEXT: store i8 10, i8* [[TMP1]], align 1
69 ; CHECK-NEXT: [[IV_NEXT]] = add nsw i32 [[IV]], 1
70 ; CHECK-NEXT: [[EC:%.*]] = icmp eq i32 [[IV_NEXT]], 500
71 ; CHECK-NEXT: br i1 [[EC]], label [[EXIT]], label [[LOOP]], !llvm.loop [[LOOP7:![0-9]+]]
73 ; CHECK-NEXT: ret void
76 br label %outer.header
78 outer.header: ; preds = %cleanup, %entry
79 %0 = load i8*, i8** @d, align 1
80 %c.0 = call i1 @cond()
81 br i1 %c.0, label %outer.exit.0, label %inner.1.header
83 inner.1.header: ; preds = %if.end, %for.body3.lr.ph.outer
84 %c.1 = call i1 @cond()
85 br i1 %c.1, label %inner.1.latch, label %outer.latch
87 inner.1.latch: ; preds = %land.end
88 %c.2 = call i1 @cond()
89 br i1 %c.2, label %outer.exit.1, label %inner.1.header
91 outer.latch: ; preds = %land.end
92 br label %outer.header
95 outer.exit.0: ; preds = %if.end, %if.end.us.us.us
98 outer.exit.1: ; preds = %if.end, %if.end.us.us.us
101 loop: ; preds = %if.end.us.us.us, %for.body3.lr.ph.outer
102 %iv = phi i32 [ %iv.next, %loop ], [ 0, %outer.exit.0 ], [ 0, %outer.exit.1 ]
103 %conv6.us.us.us = zext i1 false to i32
104 store i32 %conv6.us.us.us, i32* @f.e, align 1
105 store i8 10, i8* %0, align 1
106 %iv.next = add nsw i32 %iv, 1
107 %ec = icmp eq i32 %iv.next, 500
108 br i1 %ec, label %exit, label %loop