1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt -S -passes="loop-mssa(simple-loop-unswitch<nontrivial>),loop(loop-unroll-full),loop-simplify,verify<scalar-evolution>" < %s | FileCheck %s
4 ; Should not caused a SCEV verification failure due to incorrect
7 define void @g(ptr %b, i32 %arg, i1 %tobool.not) {
8 ; CHECK-LABEL: define void @g(
9 ; CHECK-SAME: ptr [[B:%.*]], i32 [[ARG:%.*]], i1 [[TOBOOL_NOT:%.*]]) {
11 ; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[ENTRY_SPLIT_US:%.*]], label [[ENTRY_SPLIT:%.*]]
12 ; CHECK: entry.split.us:
13 ; CHECK-NEXT: br label [[FOR_BODY_US:%.*]]
15 ; CHECK-NEXT: br label [[LAND_END_US:%.*]]
17 ; CHECK-NEXT: store i16 0, ptr [[B]], align 1
18 ; CHECK-NEXT: br label [[FOR_END:%.*]]
20 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
21 ; CHECK: for.body.peel.begin:
22 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
23 ; CHECK: for.body.peel:
24 ; CHECK-NEXT: br label [[LAND_RHS_PEEL:%.*]]
25 ; CHECK: land.rhs.peel:
26 ; CHECK-NEXT: [[AND_PEEL:%.*]] = and i32 -1, [[ARG]]
27 ; CHECK-NEXT: [[TOBOOL2_PEEL:%.*]] = icmp ne i32 [[AND_PEEL]], 0
28 ; CHECK-NEXT: [[DOTPRE_PEEL:%.*]] = load i32, ptr [[B]], align 1
29 ; CHECK-NEXT: br label [[LAND_END_PEEL:%.*]]
30 ; CHECK: land.end.peel:
31 ; CHECK-NEXT: [[IV2_PEEL:%.*]] = phi i32 [ [[DOTPRE_PEEL]], [[LAND_RHS_PEEL]] ]
32 ; CHECK-NEXT: [[IV3_PEEL:%.*]] = phi i1 [ [[TOBOOL2_PEEL]], [[LAND_RHS_PEEL]] ]
33 ; CHECK-NEXT: [[LAND_EXT_PEEL:%.*]] = zext i1 [[IV3_PEEL]] to i16
34 ; CHECK-NEXT: [[CMP3_PEEL:%.*]] = icmp ne i16 0, [[LAND_EXT_PEEL]]
35 ; CHECK-NEXT: [[CONV4_PEEL:%.*]] = zext i1 [[CMP3_PEEL]] to i16
36 ; CHECK-NEXT: store i16 [[LAND_EXT_PEEL]], ptr [[B]], align 1
37 ; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp slt i32 [[IV2_PEEL]], 0
38 ; CHECK-NEXT: br i1 [[CMP_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_END_SPLIT:%.*]]
39 ; CHECK: for.body.peel.next:
40 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT1:%.*]]
41 ; CHECK: for.body.peel.next1:
42 ; CHECK-NEXT: br label [[ENTRY_SPLIT_PEEL_NEWPH:%.*]]
43 ; CHECK: entry.split.peel.newph:
44 ; CHECK-NEXT: [[TOBOOL2:%.*]] = icmp ne i32 [[ARG]], 0
45 ; CHECK-NEXT: [[LAND_EXT:%.*]] = zext i1 [[TOBOOL2]] to i16
46 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
48 ; CHECK-NEXT: br label [[LAND_RHS:%.*]]
50 ; CHECK-NEXT: [[DOTPRE:%.*]] = load i32, ptr [[B]], align 1
51 ; CHECK-NEXT: br label [[LAND_END:%.*]]
53 ; CHECK-NEXT: store i16 [[LAND_EXT]], ptr [[B]], align 1
54 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[DOTPRE]], 0
55 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END_SPLIT_LOOPEXIT:%.*]], !llvm.loop [[LOOP0:![0-9]+]]
56 ; CHECK: for.end.split.loopexit:
57 ; CHECK-NEXT: br label [[FOR_END_SPLIT]]
58 ; CHECK: for.end.split:
59 ; CHECK-NEXT: br label [[FOR_END]]
61 ; CHECK-NEXT: ret void
66 for.body: ; preds = %land.end, %entry
67 %iv1 = phi i16 [ 0, %entry ], [ %trunc, %land.end ]
68 br i1 %tobool.not, label %land.end, label %land.rhs
70 land.rhs: ; preds = %for.body
71 %and = and i32 -1, %arg
72 %tobool2 = icmp ne i32 %and, 0
73 %.pre = load i32, ptr %b, align 1
76 land.end: ; preds = %land.rhs, %for.body
77 %iv2 = phi i32 [ 0, %for.body ], [ %.pre, %land.rhs ]
78 %iv3 = phi i1 [ false, %for.body ], [ %tobool2, %land.rhs ]
79 %land.ext = zext i1 %iv3 to i16
80 %cmp3 = icmp ne i16 %iv1, %land.ext
81 %conv4 = zext i1 %cmp3 to i16
82 store i16 %land.ext, ptr %b, align 1
83 %cmp = icmp slt i32 %iv2, 0
84 %trunc = trunc i32 %arg to i16
85 br i1 %cmp, label %for.body, label %for.end
87 for.end: ; preds = %land.end