1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes="loop(indvars,loop-deletion)" -S < %s | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; Make sure we don't crash.
11 ; CHECK-NEXT: br label [[BB1:%.*]]
13 ; CHECK-NEXT: [[TMP9:%.*]] = and i32 undef, 1
14 ; CHECK-NEXT: [[TMP10:%.*]] = icmp eq i32 [[TMP9]], 0
15 ; CHECK-NEXT: br i1 [[TMP10]], label [[BB33_LOOPEXIT1:%.*]], label [[BB34_PREHEADER:%.*]]
16 ; CHECK: bb34.preheader:
17 ; CHECK-NEXT: br label [[BB34:%.*]]
19 ; CHECK-NEXT: [[TMP2_LCSSA12:%.*]] = phi i32 [ 11, [[BB34]] ]
20 ; CHECK-NEXT: br label [[BB33_LOOPEXIT:%.*]]
22 ; CHECK-NEXT: br label [[BB14:%.*]]
24 ; CHECK-NEXT: br i1 true, label [[BB32:%.*]], label [[BB22:%.*]]
26 ; CHECK-NEXT: br i1 false, label [[BB42:%.*]], label [[BB25:%.*]]
28 ; CHECK-NEXT: br label [[BB31:%.*]]
30 ; CHECK-NEXT: unreachable
32 ; CHECK-NEXT: ret void
33 ; CHECK: bb33.loopexit:
34 ; CHECK-NEXT: [[TMP2_LCSSA9:%.*]] = phi i32 [ [[TMP2_LCSSA12]], [[BB11:%.*]] ]
35 ; CHECK-NEXT: br label [[BB33:%.*]]
36 ; CHECK: bb33.loopexit1:
37 ; CHECK-NEXT: [[TMP2_LCSSA:%.*]] = phi i32 [ 11, [[BB1]] ]
38 ; CHECK-NEXT: br label [[BB33]]
40 ; CHECK-NEXT: [[TMP210:%.*]] = phi i32 [ [[TMP2_LCSSA]], [[BB33_LOOPEXIT1]] ], [ [[TMP2_LCSSA9]], [[BB33_LOOPEXIT]] ]
41 ; CHECK-NEXT: call void @use(i32 [[TMP210]])
42 ; CHECK-NEXT: ret void
44 ; CHECK-NEXT: br i1 false, label [[BB11]], label [[BB12:%.*]]
46 ; CHECK-NEXT: [[TMP24_LCSSA:%.*]] = phi i32 [ undef, [[BB22]] ]
47 ; CHECK-NEXT: [[TMP18_LCSSA4:%.*]] = phi i64 [ 0, [[BB22]] ]
48 ; CHECK-NEXT: store atomic i64 [[TMP18_LCSSA4]], ptr addrspace(1) undef unordered, align 8
49 ; CHECK-NEXT: call void @use(i32 [[TMP24_LCSSA]])
50 ; CHECK-NEXT: ret void
55 bb1: ; preds = %bb31, %bb
56 %tmp = phi i32 [ %tmp29, %bb31 ], [ undef, %bb ]
57 %tmp2 = phi i32 [ %tmp4, %bb31 ], [ 11, %bb ]
58 %tmp3 = add nsw i32 112, -1
59 %tmp4 = add nuw nsw i32 %tmp2, 1
60 %tmp5 = mul i32 %tmp3, %tmp3
61 %tmp6 = mul nsw i32 %tmp2, -6
62 %tmp7 = mul i32 %tmp6, %tmp5
63 %tmp8 = add i32 %tmp7, %tmp2
64 %tmp9 = and i32 undef, 1
65 %tmp10 = icmp eq i32 %tmp9, 0
66 br i1 %tmp10, label %bb33, label %bb34
69 br i1 undef, label %bb33, label %bb34
72 %tmp13 = icmp eq ptr addrspace(1) undef, null
75 bb14: ; preds = %bb25, %bb12
76 %tmp15 = phi i32 [ %tmp29, %bb25 ], [ %tmp37, %bb12 ]
77 %tmp16 = phi i64 [ undef, %bb25 ], [ %tmp41, %bb12 ]
78 %tmp17 = phi i32 [ %tmp26, %bb25 ], [ 4, %bb12 ]
79 %tmp18 = add i64 %tmp16, undef
80 %tmp19 = add i32 %tmp15, 1
81 %tmp20 = and i32 %tmp19, 1
82 %tmp21 = icmp eq i32 %tmp20, 0
83 br i1 %tmp21, label %bb32, label %bb22
86 %tmp23 = or i32 %tmp17, undef
87 %tmp24 = add i32 %tmp23, undef
88 br i1 %tmp13, label %bb42, label %bb25
91 %tmp26 = add nuw nsw i32 %tmp17, 1
92 %tmp27 = zext i32 %tmp26 to i64
93 %tmp28 = getelementptr inbounds i32, ptr addrspace(1) undef, i64 %tmp27
94 %tmp29 = add i32 %tmp15, 3
95 %tmp30 = icmp ugt i32 %tmp17, 110
96 br i1 %tmp30, label %bb31, label %bb14
101 bb32: ; preds = %bb14
104 bb33: ; preds = %bb11, %bb1
105 call void @use(i32 %tmp2)
108 bb34: ; preds = %bb11, %bb1
109 %tmp35 = phi i32 [ %tmp37, %bb11 ], [ %tmp, %bb1 ]
110 %tmp36 = xor i32 0, %tmp8
111 %tmp37 = add i32 %tmp35, 2
112 %tmp38 = add i32 %tmp36, undef
113 %tmp39 = add i32 %tmp38, undef
114 %tmp40 = sext i32 %tmp39 to i64
115 %tmp41 = add i64 undef, %tmp40
116 br i1 undef, label %bb11, label %bb12
118 bb42: ; preds = %bb22
119 store atomic i64 %tmp18, ptr addrspace(1) undef unordered, align 8
120 call void @use(i32 %tmp24)
124 declare void @use(i32)