22//@ [DEBUG] compile-flags: -C opt-level=0
33//@ [OPTIM] compile-flags: -C opt-level=3
44//@ compile-flags: -C no-prepopulate-passes
5+ //@ min-llvm-version: 20
56
67#![ crate_type = "lib" ]
78#![ feature( core_intrinsics) ]
@@ -12,34 +13,16 @@ use std::intrinsics::three_way_compare;
1213// CHECK-LABEL: @signed_cmp
1314// CHECK-SAME: (i16{{.*}} %a, i16{{.*}} %b)
1415pub fn signed_cmp ( a : i16 , b : i16 ) -> std:: cmp:: Ordering {
15- // DEBUG: %[[GT:.+]] = icmp sgt i16 %a, %b
16- // DEBUG: %[[ZGT:.+]] = zext i1 %[[GT]] to i8
17- // DEBUG: %[[LT:.+]] = icmp slt i16 %a, %b
18- // DEBUG: %[[ZLT:.+]] = zext i1 %[[LT]] to i8
19- // DEBUG: %[[R:.+]] = sub nsw i8 %[[ZGT]], %[[ZLT]]
20-
21- // OPTIM: %[[LT:.+]] = icmp slt i16 %a, %b
22- // OPTIM: %[[NE:.+]] = icmp ne i16 %a, %b
23- // OPTIM: %[[CGE:.+]] = select i1 %[[NE]], i8 1, i8 0
24- // OPTIM: %[[CGEL:.+]] = select i1 %[[LT]], i8 -1, i8 %[[CGE]]
25- // OPTIM: ret i8 %[[CGEL]]
16+ // CHECK: %[[CMP:.+]] = call i8 @llvm.scmp.i8.i16(i16 %a, i16 %b)
17+ // CHECK-NEXT: ret i8 %[[CMP]]
2618 three_way_compare ( a, b)
2719}
2820
2921#[ no_mangle]
3022// CHECK-LABEL: @unsigned_cmp
3123// CHECK-SAME: (i16{{.*}} %a, i16{{.*}} %b)
3224pub fn unsigned_cmp ( a : u16 , b : u16 ) -> std:: cmp:: Ordering {
33- // DEBUG: %[[GT:.+]] = icmp ugt i16 %a, %b
34- // DEBUG: %[[ZGT:.+]] = zext i1 %[[GT]] to i8
35- // DEBUG: %[[LT:.+]] = icmp ult i16 %a, %b
36- // DEBUG: %[[ZLT:.+]] = zext i1 %[[LT]] to i8
37- // DEBUG: %[[R:.+]] = sub nsw i8 %[[ZGT]], %[[ZLT]]
38-
39- // OPTIM: %[[LT:.+]] = icmp ult i16 %a, %b
40- // OPTIM: %[[NE:.+]] = icmp ne i16 %a, %b
41- // OPTIM: %[[CGE:.+]] = select i1 %[[NE]], i8 1, i8 0
42- // OPTIM: %[[CGEL:.+]] = select i1 %[[LT]], i8 -1, i8 %[[CGE]]
43- // OPTIM: ret i8 %[[CGEL]]
25+ // CHECK: %[[CMP:.+]] = call i8 @llvm.ucmp.i8.i16(i16 %a, i16 %b)
26+ // CHECK-NEXT: ret i8 %[[CMP]]
4427 three_way_compare ( a, b)
4528}
0 commit comments