Skip to content

Commit ade191c

Browse files
committed
Small improvement for Ord implementation of integers
1 parent 0414dfa commit ade191c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/libcore/cmp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1015,8 +1015,8 @@ mod impls {
10151015
// The order here is important to generate more optimal assembly.
10161016
// See <https://github.com/rust-lang/rust/issues/63758> for more info.
10171017
if *self < *other { Less }
1018-
else if *self > *other { Greater }
1019-
else { Equal }
1018+
else if *self == *other { Equal }
1019+
else { Greater }
10201020
}
10211021
}
10221022
)*)

src/test/codegen/integer-cmp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::cmp::Ordering;
1111
#[no_mangle]
1212
pub fn cmp_signed(a: i64, b: i64) -> Ordering {
1313
// CHECK: icmp slt
14-
// CHECK: icmp sgt
14+
// CHECK: icmp ne
1515
// CHECK: zext i1
1616
// CHECK: select i1
1717
a.cmp(&b)
@@ -21,7 +21,7 @@ pub fn cmp_signed(a: i64, b: i64) -> Ordering {
2121
#[no_mangle]
2222
pub fn cmp_unsigned(a: u32, b: u32) -> Ordering {
2323
// CHECK: icmp ult
24-
// CHECK: icmp ugt
24+
// CHECK: icmp ne
2525
// CHECK: zext i1
2626
// CHECK: select i1
2727
a.cmp(&b)

0 commit comments

Comments
 (0)