-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify match based on the cast result of IntToInt
#127324
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
[WIP] Simplify match based on the cast result of `IntToInt` Even though the current method has become simpler and clearer, I should still add more comprehensive tests. r? ghost
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (b60a81d): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 2.6%, secondary -0.7%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary -0.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 734.204s -> 754.142s (2.72%) |
Sorry, bors, I forgot to enable it. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
[WIP] Simplify match based on the cast result of `IntToInt` Even though the current method has become simpler and clearer, I should still add more comprehensive tests. r? ghost
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (ef695de): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -0.9%, secondary -2.0%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary 0.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (primary 0.0%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 699.885s -> 699.501s (-0.05%) |
12e5738
to
2ae25d5
Compare
IntToInt
IntToInt
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
@@ -248,7 +627,8 @@ enum EnumAi128 { | |||
// EMIT_MIR matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff | |||
fn match_i128_u128(i: EnumAi128) -> u128 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's necessary to add i128
or u128
tests anymore.
EnumAu16::u65280_0xff00 => 0, | ||
EnumAu16::u65407_0xff7f => 127, | ||
EnumAu16::u65408_0xff80 => 128, | ||
EnumAu16::u65535_0xffff => 127, // failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Truncation disregards the sign, so I don't have any good negative test cases. :(
} | ||
}; | ||
cast_scalar == target_scalar | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code does not exactly match what the interpreter does in cast_from_int_like
. Should we reuse similar code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
When I read this part of the code earlier, I tried to call it directly, which seemed a bit difficult. I copied part of the code. Maybe I should put such code in rustc_middle
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rustc_const_eval
is accessible from this crate, so putting is there is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, I have squashed them into two commits.
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
ping? :) |
r? cjgillot |
☔ The latest upstream changes (presumably #125443) made this pull request unmergeable. Please resolve the merge conflicts. |
8300db0
to
715558d
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #128461) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors r+ rollup=never |
☀️ Test successful - checks-actions |
Finished benchmarking commit (bbf60c8): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -1.9%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary 1.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (primary 0.0%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 760.453s -> 758.56s (-0.25%) |
Continue to complete #124150. The condition in #120614 is wrong, e.g.
-1i8
cannot be converted to255i16
. I've rethought the issue and simplified the conditional judgment for a more straightforward approach. The new approach is to check if the case value after theIntToInt
conversion equals the target value.In different types,
IntToInt
uses different casting methods. This rule is as follows:i8
/u8
toi8
/u8
: do nothing.i8
toi16
/u16
: sign extension.u8
toi16
/u16
: zero extension.i16
/u16
toi8
/u8
: truncate to the target size.The previous error was a mix of zext and sext.
r? mir-opt