From ade191c70a51f6699b64423e0bc8e0f307de9ecd Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Aug 2019 03:52:18 +0000 Subject: [PATCH] Small improvement for Ord implementation of integers --- src/libcore/cmp.rs | 4 ++-- src/test/codegen/integer-cmp.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 167a9dd1c3620..607427a85d67a 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -1015,8 +1015,8 @@ mod impls { // The order here is important to generate more optimal assembly. // See for more info. if *self < *other { Less } - else if *self > *other { Greater } - else { Equal } + else if *self == *other { Equal } + else { Greater } } } )*) diff --git a/src/test/codegen/integer-cmp.rs b/src/test/codegen/integer-cmp.rs index 1373b12e3721c..8ada3cf09d073 100644 --- a/src/test/codegen/integer-cmp.rs +++ b/src/test/codegen/integer-cmp.rs @@ -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)