1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
6 define void @test_or_ule(i4 %x, i4 %y, i4 %z, i4 %a) {
7 ; CHECK-LABEL: @test_or_ule(
9 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
10 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
11 ; CHECK-NEXT: [[OR:%.*]] = or i1 [[C_1]], [[C_2]]
12 ; CHECK-NEXT: br i1 [[OR]], label [[BB1:%.*]], label [[EXIT:%.*]]
14 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 [[X]], [[Z]]
15 ; CHECK-NEXT: call void @use(i1 [[C_3]])
16 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 [[X]], [[A:%.*]]
17 ; CHECK-NEXT: call void @use(i1 [[C_4]])
18 ; CHECK-NEXT: ret void
20 ; CHECK-NEXT: [[F_1:%.*]] = icmp ule i4 [[X]], [[Z]]
21 ; CHECK-NEXT: call void @use(i1 false)
22 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
23 ; CHECK-NEXT: call void @use(i1 [[C_5]])
24 ; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i4 [[Y]], [[Z]]
25 ; CHECK-NEXT: call void @use(i1 true)
26 ; CHECK-NEXT: [[T_2:%.*]] = icmp ugt i4 [[X]], [[Y]]
27 ; CHECK-NEXT: call void @use(i1 true)
28 ; CHECK-NEXT: [[T_3:%.*]] = icmp ugt i4 [[X]], [[Z]]
29 ; CHECK-NEXT: call void @use(i1 true)
30 ; CHECK-NEXT: ret void
33 %c.1 = icmp ule i4 %x, %y
34 %c.2 = icmp ule i4 %y, %z
35 %or = or i1 %c.1, %c.2
36 br i1 %or, label %bb1, label %exit
39 %c.3 = icmp ule i4 %x, %z
40 call void @use(i1 %c.3)
42 %c.4 = icmp ule i4 %x, %a
43 call void @use(i1 %c.4)
48 %f.1 = icmp ule i4 %x, %z
49 call void @use(i1 %f.1)
51 %c.5 = icmp ule i4 %x, %a
52 call void @use(i1 %c.5)
54 %t.1 = icmp ugt i4 %y, %z
55 call void @use(i1 %t.1)
57 %t.2 = icmp ugt i4 %x, %y
58 call void @use(i1 %t.2)
60 %t.3 = icmp ugt i4 %x, %z
61 call void @use(i1 %t.3)
66 ; The result of test_or_ule and test_or_select_ule should be same
67 define void @test_or_select_ule(i4 %x, i4 %y, i4 %z, i4 %a) {
68 ; CHECK-LABEL: @test_or_select_ule(
70 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
71 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
72 ; CHECK-NEXT: [[OR:%.*]] = select i1 [[C_1]], i1 true, i1 [[C_2]]
73 ; CHECK-NEXT: br i1 [[OR]], label [[BB1:%.*]], label [[EXIT:%.*]]
75 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 [[X]], [[Z]]
76 ; CHECK-NEXT: call void @use(i1 [[C_3]])
77 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 [[X]], [[A:%.*]]
78 ; CHECK-NEXT: call void @use(i1 [[C_4]])
79 ; CHECK-NEXT: ret void
81 ; CHECK-NEXT: [[F_1:%.*]] = icmp ule i4 [[X]], [[Z]]
82 ; CHECK-NEXT: call void @use(i1 false)
83 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
84 ; CHECK-NEXT: call void @use(i1 [[C_5]])
85 ; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i4 [[Y]], [[Z]]
86 ; CHECK-NEXT: call void @use(i1 true)
87 ; CHECK-NEXT: [[T_2:%.*]] = icmp ugt i4 [[X]], [[Y]]
88 ; CHECK-NEXT: call void @use(i1 true)
89 ; CHECK-NEXT: [[T_3:%.*]] = icmp ugt i4 [[X]], [[Z]]
90 ; CHECK-NEXT: call void @use(i1 true)
91 ; CHECK-NEXT: ret void
94 %c.1 = icmp ule i4 %x, %y
95 %c.2 = icmp ule i4 %y, %z
96 %or = select i1 %c.1, i1 true, i1 %c.2
97 br i1 %or, label %bb1, label %exit
100 %c.3 = icmp ule i4 %x, %z
101 call void @use(i1 %c.3)
103 %c.4 = icmp ule i4 %x, %a
104 call void @use(i1 %c.4)
109 %f.1 = icmp ule i4 %x, %z
110 call void @use(i1 %f.1)
112 %c.5 = icmp ule i4 %x, %a
113 call void @use(i1 %c.5)
115 %t.1 = icmp ugt i4 %y, %z
116 call void @use(i1 %t.1)
118 %t.2 = icmp ugt i4 %x, %y
119 call void @use(i1 %t.2)
121 %t.3 = icmp ugt i4 %x, %z
122 call void @use(i1 %t.3)