1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
4 define i8 @scmp_1(i32 %x, i32 %y) {
5 ; CHECK-LABEL: @scmp_1(
6 ; CHECK-NEXT: [[COND:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]]
7 ; CHECK-NEXT: br i1 [[COND]], label [[TRUE:%.*]], label [[FALSE:%.*]]
11 ; CHECK-NEXT: ret i8 20
13 %cond = icmp sgt i32 %x, %y
14 br i1 %cond, label %true, label %false
16 %r = call i8 @llvm.scmp(i32 %x, i32 %y)
22 define i8 @ucmp_1(i32 %x, i32 %y) {
23 ; CHECK-LABEL: @ucmp_1(
24 ; CHECK-NEXT: [[COND:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]]
25 ; CHECK-NEXT: br i1 [[COND]], label [[TRUE:%.*]], label [[FALSE:%.*]]
27 ; CHECK-NEXT: ret i8 -1
29 ; CHECK-NEXT: ret i8 20
31 %cond = icmp ult i32 %x, %y
32 br i1 %cond, label %true, label %false
34 %r = call i8 @llvm.ucmp(i32 %x, i32 %y)
40 define i8 @scmp_2(i32 %x, i32 %y) {
41 ; CHECK-LABEL: @scmp_2(
42 ; CHECK-NEXT: [[COND:%.*]] = icmp sge i32 [[X:%.*]], [[Y:%.*]]
43 ; CHECK-NEXT: br i1 [[COND]], label [[TRUE:%.*]], label [[FALSE:%.*]]
45 ; CHECK-NEXT: ret i8 20
47 ; CHECK-NEXT: ret i8 -1
49 %cond = icmp sge i32 %x, %y
50 br i1 %cond, label %true, label %false
54 %r = call i8 @llvm.scmp(i32 %x, i32 %y)
58 define i8 @ucmp_2(i32 %x, i32 %y) {
59 ; CHECK-LABEL: @ucmp_2(
60 ; CHECK-NEXT: [[COND:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
61 ; CHECK-NEXT: br i1 [[COND]], label [[TRUE:%.*]], label [[FALSE:%.*]]
63 ; CHECK-NEXT: ret i8 20
65 ; CHECK-NEXT: ret i8 1
67 %cond = icmp ule i32 %x, %y
68 br i1 %cond, label %true, label %false
72 %r = call i8 @llvm.ucmp(i32 %x, i32 %y)
76 define i8 @scmp_3(i32 %x, i32 %y) {
77 ; CHECK-LABEL: @scmp_3(
78 ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
79 ; CHECK-NEXT: br i1 [[COND]], label [[TRUE:%.*]], label [[FALSE:%.*]]
81 ; CHECK-NEXT: ret i8 0
83 ; CHECK-NEXT: ret i8 20
85 %cond = icmp eq i32 %x, %y
86 br i1 %cond, label %true, label %false
88 %r = call i8 @llvm.scmp(i32 %x, i32 %y)
94 define i8 @ucmp_3(i32 %x, i32 %y) {
95 ; CHECK-LABEL: @ucmp_3(
96 ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
97 ; CHECK-NEXT: br i1 [[COND]], label [[TRUE:%.*]], label [[FALSE:%.*]]
99 ; CHECK-NEXT: ret i8 0
101 ; CHECK-NEXT: ret i8 20
103 %cond = icmp eq i32 %x, %y
104 br i1 %cond, label %true, label %false
106 %r = call i8 @llvm.ucmp(i32 %x, i32 %y)
112 ; Negative test: signedness mismatch
113 define i8 @scmp_4(i32 %x, i32 %y) {
114 ; CHECK-LABEL: @scmp_4(
115 ; CHECK-NEXT: [[COND:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]]
116 ; CHECK-NEXT: br i1 [[COND]], label [[TRUE:%.*]], label [[FALSE:%.*]]
118 ; CHECK-NEXT: ret i8 20
120 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.scmp.i8.i32(i32 [[X]], i32 [[Y]])
121 ; CHECK-NEXT: ret i8 [[R]]
123 %cond = icmp ugt i32 %x, %y
124 br i1 %cond, label %true, label %false
128 %r = call i8 @llvm.scmp(i32 %x, i32 %y)
132 define i8 @ucmp_4(i32 %x, i32 %y) {
133 ; CHECK-LABEL: @ucmp_4(
134 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[X:%.*]], [[Y:%.*]]
135 ; CHECK-NEXT: br i1 [[COND]], label [[TRUE:%.*]], label [[FALSE:%.*]]
137 ; CHECK-NEXT: ret i8 20
139 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.ucmp.i8.i32(i32 [[X]], i32 [[Y]])
140 ; CHECK-NEXT: ret i8 [[R]]
142 %cond = icmp slt i32 %x, %y
143 br i1 %cond, label %true, label %false
147 %r = call i8 @llvm.ucmp(i32 %x, i32 %y)