1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
5 declare void @clobber()
8 define void @test_unreachable_latch(ptr %start, ptr %b) {
9 ; CHECK-LABEL: define void @test_unreachable_latch
10 ; CHECK-SAME: (ptr [[START:%.*]], ptr [[B:%.*]]) {
12 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
14 ; CHECK-NEXT: [[NODE_1:%.*]] = phi ptr [ [[START]], [[ENTRY:%.*]] ], [ null, [[LOOP_LATCH:%.*]] ]
15 ; CHECK-NEXT: [[C_0:%.*]] = icmp ne ptr [[NODE_1]], null
16 ; CHECK-NEXT: br i1 [[C_0]], label [[THEN:%.*]], label [[EXIT:%.*]]
18 ; CHECK-NEXT: call void @clobber()
19 ; CHECK-NEXT: br label [[LOOP_HEADER]]
21 ; CHECK-NEXT: [[C_2:%.*]] = icmp ne ptr [[B]], null
22 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_2]], [[C_0]]
23 ; CHECK-NEXT: br i1 [[AND]], label [[THEN]], label [[EXIT]]
25 ; CHECK-NEXT: call void @clobber()
26 ; CHECK-NEXT: br label [[EXIT]]
28 ; CHECK-NEXT: ret void
34 %node.1 = phi ptr [ %start, %entry ], [ null, %loop.latch ]
35 %c.0 = icmp ne ptr %node.1, null
36 br i1 %c.0, label %then, label %exit
38 loop.latch: ; No predecessors!
43 %c.2 = icmp ne ptr %b, null
44 %and = and i1 %c.2, %c.0
45 br i1 %and, label %then, label %exit
55 define void @test_cond_multi_use_with_one_use_simplified_before_adding_ne_fact(ptr %start, ptr %b) {
56 ; CHECK-LABEL: define void @test_cond_multi_use_with_one_use_simplified_before_adding_ne_fact
57 ; CHECK-SAME: (ptr [[START:%.*]], ptr [[B:%.*]]) {
59 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
61 ; CHECK-NEXT: [[NODE_1:%.*]] = phi ptr [ [[START]], [[ENTRY:%.*]] ], [ null, [[LOOP_LATCH:%.*]] ]
62 ; CHECK-NEXT: [[C_0:%.*]] = icmp ne ptr [[NODE_1]], null
63 ; CHECK-NEXT: br i1 [[C_0]], label [[LOOP_LATCH]], label [[EXIT:%.*]]
65 ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond()
66 ; CHECK-NEXT: br i1 [[C_1]], label [[IF:%.*]], label [[LOOP_HEADER]]
68 ; CHECK-NEXT: [[C_2:%.*]] = icmp ne ptr [[B]], null
69 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_2]], true
70 ; CHECK-NEXT: br i1 [[AND]], label [[THEN:%.*]], label [[EXIT]]
72 ; CHECK-NEXT: call void @clobber()
73 ; CHECK-NEXT: br label [[EXIT]]
75 ; CHECK-NEXT: ret void
81 %node.1 = phi ptr [ %start, %entry ], [ null, %loop.latch ]
82 %c.0 = icmp ne ptr %node.1, null
83 br i1 %c.0, label %loop.latch, label %exit
86 %c.1 = call i1 @cond()
87 br i1 %c.1, label %if, label %loop.header
90 %c.2 = icmp ne ptr %b, null
91 %and = and i1 %c.2, %c.0
92 br i1 %and, label %then, label %exit