1
Fork 0

Small improvement for Ord implementation of integers

This commit is contained in:
Lzu Tao 2019-08-29 03:52:18 +00:00
parent 0414dfa0aa
commit ade191c70a
2 changed files with 4 additions and 4 deletions

View file

@ -1015,8 +1015,8 @@ mod impls {
// The order here is important to generate more optimal assembly.
// See <https://github.com/rust-lang/rust/issues/63758> for more info.
if *self < *other { Less }
else if *self > *other { Greater }
else { Equal }
else if *self == *other { Equal }
else { Greater }
}
}
)*)

View file

@ -11,7 +11,7 @@ use std::cmp::Ordering;
#[no_mangle]
pub fn cmp_signed(a: i64, b: i64) -> Ordering {
// CHECK: icmp slt
// CHECK: icmp sgt
// CHECK: icmp ne
// CHECK: zext i1
// CHECK: select i1
a.cmp(&b)
@ -21,7 +21,7 @@ pub fn cmp_signed(a: i64, b: i64) -> Ordering {
#[no_mangle]
pub fn cmp_unsigned(a: u32, b: u32) -> Ordering {
// CHECK: icmp ult
// CHECK: icmp ugt
// CHECK: icmp ne
// CHECK: zext i1
// CHECK: select i1
a.cmp(&b)