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_slt() {
5 ; CHECK-LABEL: @test_slt(
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]], false
10 ; CHECK-NEXT: [[RES_4:%.*]] = xor i1 [[RES_3]], true
11 ; CHECK-NEXT: ret i1 [[RES_4]]
14 %t.0 = icmp slt i8 10, 11
15 %f.0 = icmp slt i8 10, 10
16 %res.1 = xor i1 %t.0, %f.0
17 %f.1 = icmp slt i8 10, 9
18 %res.2 = xor i1 %res.1, %f.1
19 %f.2 = icmp slt i8 10, -10
20 %res.3 = xor i1 %res.2, %f.2
21 %t.1 = icmp slt i8 10, 11
22 %res.4 = xor i1 %res.3, %t.1
26 define i1 @test_sgt() {
27 ; CHECK-LABEL: @test_sgt(
29 ; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, false
30 ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], false
31 ; CHECK-NEXT: [[RES_3:%.*]] = xor i1 [[RES_2]], false
32 ; CHECK-NEXT: [[RES_4:%.*]] = xor i1 [[RES_3]], true
33 ; CHECK-NEXT: ret i1 [[RES_4]]
36 %t.0 = icmp sgt i8 11, 10
37 %f.0 = icmp sgt i8 10, 10
38 %res.1 = xor i1 %t.0, %f.0
39 %f.1 = icmp sgt i8 9, 10
40 %res.2 = xor i1 %res.1, %f.1
41 %f.2 = icmp sgt i8 -10, 10
42 %res.3 = xor i1 %res.2, %f.2
43 %t.1 = icmp sgt i8 -1, -2
44 %res.4 = xor i1 %res.3, %t.1
48 ; Test cases where lhs - rhs results in constant offset.
49 define i1 @test_slt_gep_1(ptr %base) {
50 ; CHECK-LABEL: @test_slt_gep_1(
52 ; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr inbounds i8, ptr [[BASE:%.*]], i8 1
53 ; CHECK-NEXT: [[T_0:%.*]] = icmp slt ptr [[BASE]], [[GEP_1]]
54 ; CHECK-NEXT: [[GEP_0:%.*]] = getelementptr inbounds i8, ptr [[BASE]], i8 0
55 ; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[T_0]], false
56 ; CHECK-NEXT: [[C_1:%.*]] = icmp slt ptr [[GEP_1]], [[BASE]]
57 ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[C_1]]
58 ; CHECK-NEXT: ret i1 [[RES_2]]
61 %gep.1 = getelementptr inbounds i8, ptr %base, i8 1
62 %t.0 = icmp slt ptr %base, %gep.1
63 %gep.0 = getelementptr inbounds i8, ptr %base, i8 0
64 %f.0 = icmp slt ptr %base, %gep.0
65 %res.1 = xor i1 %t.0, %f.0
66 %c.1 = icmp slt ptr %gep.1, %base
67 %res.2 = xor i1 %res.1, %c.1
71 define i1 @test_slt_gep_2(ptr %base) {
72 ; CHECK-LABEL: @test_slt_gep_2(
73 ; CHECK-NEXT: [[GEP_SUB_1:%.*]] = getelementptr inbounds i8, ptr [[BASE:%.*]], i8 -1
74 ; CHECK-NEXT: [[C_1:%.*]] = icmp slt ptr [[BASE]], [[GEP_SUB_1]]
75 ; CHECK-NEXT: ret i1 [[C_1]]
77 %gep.sub.1 = getelementptr inbounds i8, ptr %base, i8 -1
78 %c.1 = icmp slt ptr %base, %gep.sub.1
82 define i1 @test_slt_gep_3(ptr %base) {
83 ; CHECK-LABEL: @test_slt_gep_3(
84 ; CHECK-NEXT: [[GEP_1_NOINBOUNDS:%.*]] = getelementptr i8, ptr [[BASE:%.*]], i8 1
85 ; CHECK-NEXT: [[C_1:%.*]] = icmp slt ptr [[BASE]], [[GEP_1_NOINBOUNDS]]
86 ; CHECK-NEXT: ret i1 [[C_1]]
88 %gep.1.noinbounds = getelementptr i8, ptr %base, i8 1
89 %c.1 = icmp slt ptr %base, %gep.1.noinbounds