1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
4 define i1 @test_ult() {
5 ; CHECK-LABEL: @test_ult(
7 ; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, false
8 ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], false
9 ; CHECK-NEXT: [[RES_3:%.*]] = xor i1 [[RES_2]], true
10 ; CHECK-NEXT: ret i1 [[RES_3]]
13 %t.0 = icmp ult i8 10, 11
14 %f.0 = icmp ult i8 10, 10
15 %res.1 = xor i1 %t.0, %f.0
16 %f.1 = icmp ult i8 10, 9
17 %res.2 = xor i1 %res.1, %f.1
18 %t.1 = icmp ult i8 10, -10
19 %res.3 = xor i1 %res.2, %t.1
23 ; Test cases where lhs - rhs results in constant offset.
24 define i1 @test_ult_gep_1(ptr %base) {
25 ; CHECK-LABEL: @test_ult_gep_1(
27 ; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr inbounds i8, ptr [[BASE:%.*]], i8 1
28 ; CHECK-NEXT: [[GEP_0:%.*]] = getelementptr inbounds i8, ptr [[BASE]], i8 0
29 ; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, false
30 ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], false
31 ; CHECK-NEXT: ret i1 [[RES_2]]
34 %gep.1 = getelementptr inbounds i8, ptr %base, i8 1
35 %t.0 = icmp ult ptr %base, %gep.1
36 %gep.0 = getelementptr inbounds i8, ptr %base, i8 0
37 %f.0 = icmp ult ptr %base, %gep.0
38 %res.1 = xor i1 %t.0, %f.0
39 %f.1 = icmp ult ptr %gep.1, %base
40 %res.2 = xor i1 %res.1, %f.1
44 define i1 @test_ult_gep_2(ptr %base) {
45 ; CHECK-LABEL: @test_ult_gep_2(
46 ; CHECK-NEXT: [[GEP_SUB_1:%.*]] = getelementptr inbounds i8, ptr [[BASE:%.*]], i8 -1
47 ; CHECK-NEXT: ret i1 false
49 %gep.sub.1 = getelementptr inbounds i8, ptr %base, i8 -1
50 %c.1 = icmp ult ptr %base, %gep.sub.1
54 define i1 @test_ult_gep_3(ptr %base) {
55 ; CHECK-LABEL: @test_ult_gep_3(
56 ; CHECK-NEXT: [[GEP_1_NOINBOUNDS:%.*]] = getelementptr i8, ptr [[BASE:%.*]], i8 1
57 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult ptr [[BASE]], [[GEP_1_NOINBOUNDS]]
58 ; CHECK-NEXT: ret i1 [[C_1]]
60 %gep.1.noinbounds = getelementptr i8, ptr %base, i8 1
61 %c.1 = icmp ult ptr %base, %gep.1.noinbounds
65 define i1 @test_eq() {
66 ; CHECK-LABEL: @test_eq(
68 ; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, false
69 ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], false
70 ; CHECK-NEXT: ret i1 [[RES_2]]
73 %f.0 = icmp eq i8 10, 11
74 %t.0 = icmp eq i8 10, 10
75 %res.1 = xor i1 %t.0, %f.0
76 %f.1 = icmp eq i8 10, 9
77 %res.2 = xor i1 %res.1, %f.1
81 define i1 @test_ne() {
82 ; CHECK-LABEL: @test_ne(
84 ; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, false
85 ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], true
86 ; CHECK-NEXT: ret i1 [[RES_2]]
89 %t.0 = icmp ne i8 10, 11
90 %f.0 = icmp ne i8 10, 10
91 %res.1 = xor i1 %t.0, %f.0
92 %t.1 = icmp ne i8 10, 9
93 %res.2 = xor i1 %res.1, %t.1