diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-03-02 14:30:32 -0800 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-03-05 21:58:46 -0800 |
| commit | eae5ed609d8afe6c8cd7a231a1bbbb12aba331dd (patch) | |
| tree | 683b178fcd420616595e8dbbf79a39e4f3818915 /tests/mir-opt/pre-codegen | |
| parent | 1b21952f0279bf39d0f7188638f1a33dc16e5143 (diff) | |
| download | rust-eae5ed609d8afe6c8cd7a231a1bbbb12aba331dd.tar.gz rust-eae5ed609d8afe6c8cd7a231a1bbbb12aba331dd.zip | |
Make `is_le` and friends work like clang's
Diffstat (limited to 'tests/mir-opt/pre-codegen')
3 files changed, 27 insertions, 12 deletions
diff --git a/tests/mir-opt/pre-codegen/derived_ord.demo_le.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/derived_ord.demo_le.PreCodegen.after.mir index 8f47336e2a0..49314a64c3f 100644 --- a/tests/mir-opt/pre-codegen/derived_ord.demo_le.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/derived_ord.demo_le.PreCodegen.after.mir @@ -12,22 +12,23 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool { scope 4 (inlined <fn(std::cmp::Ordering) -> bool {std::cmp::Ordering::is_le} as FnOnce<(std::cmp::Ordering,)>>::call_once - shim(fn(std::cmp::Ordering) -> bool {std::cmp::Ordering::is_le})) { scope 5 (inlined std::cmp::Ordering::is_le) { let mut _13: i8; - let mut _14: bool; + scope 6 (inlined std::cmp::Ordering::as_raw) { + } } } } } - scope 6 (inlined <MultiField as PartialOrd>::partial_cmp) { + scope 7 (inlined <MultiField as PartialOrd>::partial_cmp) { let mut _6: std::option::Option<std::cmp::Ordering>; let mut _7: i8; - scope 7 { + scope 8 { } - scope 8 (inlined std::cmp::impls::<impl PartialOrd for char>::partial_cmp) { + scope 9 (inlined std::cmp::impls::<impl PartialOrd for char>::partial_cmp) { let mut _3: char; let mut _4: char; let mut _5: std::cmp::Ordering; } - scope 9 (inlined std::cmp::impls::<impl PartialOrd for i16>::partial_cmp) { + scope 10 (inlined std::cmp::impls::<impl PartialOrd for i16>::partial_cmp) { let mut _8: i16; let mut _9: i16; let mut _10: std::cmp::Ordering; @@ -78,11 +79,8 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool { bb3: { _12 = move ((_11 as Some).0: std::cmp::Ordering); StorageLive(_13); - StorageLive(_14); _13 = discriminant(_12); - _14 = Eq(copy _13, const 1_i8); - _0 = Not(move _14); - StorageDead(_14); + _0 = Le(move _13, const 0_i8); StorageDead(_13); StorageDead(_11); StorageDead(_12); diff --git a/tests/mir-opt/pre-codegen/derived_ord.rs b/tests/mir-opt/pre-codegen/derived_ord.rs index fdfa409d5f2..73ae923a6cb 100644 --- a/tests/mir-opt/pre-codegen/derived_ord.rs +++ b/tests/mir-opt/pre-codegen/derived_ord.rs @@ -1,4 +1,3 @@ -// skip-filecheck //@ compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=0 #![crate_type = "lib"] @@ -9,6 +8,24 @@ pub struct MultiField(char, i16); // Because this isn't derived by the impl, it's not on the `{impl#0}-partial_cmp`, // and thus we need to call it to see what the inlined generic one produces. pub fn demo_le(a: &MultiField, b: &MultiField) -> bool { + // CHECK-LABEL: fn demo_le + // CHECK: inlined <MultiField as PartialOrd>::le + // CHECK: inlined{{.+}}is_some_and + // CHECK: inlined <MultiField as PartialOrd>::partial_cmp + + // CHECK: [[A0:_[0-9]+]] = copy ((*_1).0: char); + // CHECK: [[B0:_[0-9]+]] = copy ((*_2).0: char); + // CHECK: Cmp(move [[A0]], move [[B0]]); + + // CHECK: [[D0:_[0-9]+]] = discriminant({{.+}}); + // CHECK: switchInt(move [[D0]]) -> [0: bb{{[0-9]+}}, otherwise: bb{{[0-9]+}}]; + + // CHECK: [[A1:_[0-9]+]] = copy ((*_1).1: i16); + // CHECK: [[B1:_[0-9]+]] = copy ((*_2).1: i16); + // CHECK: Cmp(move [[A1]], move [[B1]]); + + // CHECK: [[D1:_[0-9]+]] = discriminant({{.+}}); + // CHECK: _0 = Le(move [[D1]], const 0_i8); *a <= *b } diff --git a/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir index 5f4ec1de270..de25eebee77 100644 --- a/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir @@ -1,6 +1,6 @@ -// MIR for `<impl at $DIR/derived_ord.rs:6:10: 6:20>::partial_cmp` after PreCodegen +// MIR for `<impl at $DIR/derived_ord.rs:5:10: 5:20>::partial_cmp` after PreCodegen -fn <impl at $DIR/derived_ord.rs:6:10: 6:20>::partial_cmp(_1: &MultiField, _2: &MultiField) -> Option<std::cmp::Ordering> { +fn <impl at $DIR/derived_ord.rs:5:10: 5:20>::partial_cmp(_1: &MultiField, _2: &MultiField) -> Option<std::cmp::Ordering> { debug self => _1; debug other => _2; let mut _0: std::option::Option<std::cmp::Ordering>; |
