1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
4 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
8 define void @test_loop_add_rec_used_in_adjacent_loop(i8 %len.n, i16 %a) {
9 ; CHECK-LABEL: @test_loop_add_rec_used_in_adjacent_loop(
11 ; CHECK-NEXT: [[LEN:%.*]] = zext i8 [[LEN_N:%.*]] to i16
12 ; CHECK-NEXT: [[LEN_NEG:%.*]] = icmp uge i16 [[LEN]], [[A:%.*]]
13 ; CHECK-NEXT: br i1 [[LEN_NEG]], label [[EXIT:%.*]], label [[LOOP_1_PH:%.*]]
15 ; CHECK-NEXT: br label [[LOOP_1:%.*]]
17 ; CHECK-NEXT: [[IV:%.*]] = phi i16 [ 0, [[LOOP_1_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP_1]] ]
18 ; CHECK-NEXT: [[C_0:%.*]] = icmp eq i16 [[IV]], [[A]]
19 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i16 [[IV]], 1
20 ; CHECK-NEXT: br i1 [[C_0]], label [[LOOP_2_HEADER:%.*]], label [[LOOP_1]]
21 ; CHECK: loop.2.header:
22 ; CHECK-NEXT: [[IV_2:%.*]] = phi i16 [ [[IV]], [[LOOP_1]] ], [ [[IV]], [[LOOP_2_LATCH:%.*]] ]
23 ; CHECK-NEXT: [[C:%.*]] = icmp eq i16 [[IV_2]], [[LEN]]
24 ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]]
26 ; CHECK-NEXT: [[T_2:%.*]] = icmp ult i16 [[IV_2]], [[A]]
27 ; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]]
28 ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_2_LATCH]], label [[EXIT]]
29 ; CHECK: loop.2.latch:
30 ; CHECK-NEXT: call void @use(i16 [[IV_2]])
31 ; CHECK-NEXT: br label [[LOOP_2_HEADER]]
33 ; CHECK-NEXT: ret void
36 %len = zext i8 %len.n to i16
37 %len.neg = icmp uge i16 %len, %a
38 br i1 %len.neg, label %exit, label %loop.1.ph
44 %iv = phi i16 [ 0, %loop.1.ph ], [ %iv.next, %loop.1 ]
45 %c.0 = icmp eq i16 %iv, %a
46 %iv.next = add nuw nsw i16 %iv, 1
47 br i1 %c.0, label %loop.2.header, label %loop.1
50 %iv.2 = phi i16 [ %iv, %loop.1 ], [ %iv, %loop.2.latch ]
51 %c = icmp eq i16 %iv.2, %len
52 br i1 %c, label %exit, label %for.body
55 %t.1 = icmp uge i16 %iv.2, 0
56 %t.2 = icmp ult i16 %iv.2, %a
57 %and = and i1 %t.1, %t.2
58 br i1 %and, label %loop.2.latch, label %exit
61 call void @use(i16 %iv.2)
62 br label %loop.2.header
68 define void @test_adjacen_loops_pointer_iv_crash() {
69 ; CHECK-LABEL: @test_adjacen_loops_pointer_iv_crash(
71 ; CHECK-NEXT: br label [[LOOP_1:%.*]]
73 ; CHECK-NEXT: [[IV_1:%.*]] = phi ptr [ null, [[ENTRY:%.*]] ], [ [[IV_1_NEXT:%.*]], [[LOOP_1]] ]
74 ; CHECK-NEXT: [[IV_1_NEXT]] = getelementptr ptr, ptr [[IV_1]], i32 1
75 ; CHECK-NEXT: br i1 false, label [[LOOP_1]], label [[LOOP_2:%.*]]
77 ; CHECK-NEXT: [[__FIRST_ADDR_1_LCSSA:%.*]] = phi ptr [ [[IV_1]], [[LOOP_1]] ], [ [[IV_1]], [[LOOP_2_LATCH:%.*]] ]
78 ; CHECK-NEXT: [[CMP7:%.*]] = icmp eq ptr [[__FIRST_ADDR_1_LCSSA]], null
79 ; CHECK-NEXT: br i1 [[CMP7]], label [[IF_THEN8:%.*]], label [[LOOP_2_LATCH]]
81 ; CHECK-NEXT: ret void
82 ; CHECK: loop.2.latch:
83 ; CHECK-NEXT: br label [[LOOP_2]]
89 %iv.1 = phi ptr [ null, %entry ], [ %iv.1.next, %loop.1 ]
90 %iv.1.next = getelementptr ptr, ptr %iv.1, i32 1
91 br i1 false, label %loop.1, label %loop.2
94 %__first.addr.1.lcssa = phi ptr [ %iv.1, %loop.1 ], [ %iv.1, %loop.2.latch ]
95 %cmp7 = icmp eq ptr %__first.addr.1.lcssa, null
96 br i1 %cmp7, label %if.then8, label %loop.2.latch
98 if.then8: ; preds = %do.body