-
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
Suboptimal order of tests in match
#117970
Comments
rustbot
added
the
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
label
Nov 16, 2023
@rustbot label I-slow |
rustbot
added
the
I-slow
Issue: Problems and improvements with respect to performance of generated code.
label
Nov 16, 2023
alive2 approves: https://alive2.llvm.org/ce/z/NLickb |
saethlin
added
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
and removed
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
labels
Nov 16, 2023
This could be fixed by better heuristics used by https://dl.acm.org/doi/pdf/10.1145/1411304.1411311, section 8 gives some heuristics that can be used in selecting the order of tests |
#121397 will fix this issue, but I'm not sure if it is a special case. |
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Feb 29, 2024
… r=<try> Re-enable the early otherwise branch optimization Fixes rust-lang#95162. Fixes rust-lang#119014. Fixes rust-lang#117970. An invalid enum discriminant can come from anywhere. We have to check to see if all successors contain the discriminant statement. It should not be UB that we pass in an invalid enum discriminant when calling a function, this is more like LLVM's poison value. UB only when used. Although miri would consider the following code to be UB. (It's fine for miri.) https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=18602870aaeb07cbdf7dfcd2c28961a2 I extended the scenario with scalars and the same target values. r? compiler
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 3, 2024
… r=<try> Re-enable the early otherwise branch optimization Fixes rust-lang#95162. Fixes rust-lang#119014. Fixes rust-lang#117970. An invalid enum discriminant can come from anywhere. We have to check to see if all successors contain the discriminant statement. It should not be UB that we pass in an invalid enum discriminant when calling a function, this is more like LLVM's poison value. UB only when used. Although miri would consider the following code to be UB. (It's fine for miri.) https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=18602870aaeb07cbdf7dfcd2c28961a2 I extended the scenario with scalars and the same target values. r? compiler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried this code (godbolt):
I expected to see this happen:
src
should produce assembly as efficient astgt
, since they are both equivalent on all inputs.tgt
first checksy
against10
, then checksx
against1
,2
and3
:Instead, this happened:
src
checksx
against3
, then checksy
against10
, then checksx
against2
, then checksy
against10
, then checksx
against1
, then checksy
against10
:Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: