-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Emit the enum range assumption if the range only contains one element #83020
Conversation
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
Naive question, but couldn't it be turned into a constant instead if there can only be a single value? |
This needs a codegen test to make sure the desired optimization takes place. The |
651f59b
to
e96b5dc
Compare
Now it's look like: .section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 7
.globl _index
.p2align 4, 0x90
_index:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
movl (%rdi), %eax
popq %rbp
retq
.cfi_endproc
.subsections_via_symbols
|
This comment has been minimized.
This comment has been minimized.
test: add test case make tidy happy
e96b5dc
to
d180f91
Compare
I think it's ready for review. |
this does seem fine to me, would it be possible to instead emit a constant if edit: ah, that was already asked in #83020 (comment) |
That would be possible, but maybe not worth the bother to special case it? LLVM will end up replacing the value with a constant based on the assumption, so I don't think it will make much of a difference. |
in this case @bors r+ |
📌 Commit d180f91 has been approved by |
Emit the enum range assumption if the range only contains one element close rust-lang#82871
Rollup of 6 pull requests Successful merges: - rust-lang#82984 (Simplify ast block lowering) - rust-lang#83012 (Update Clippy) - rust-lang#83020 (Emit the enum range assumption if the range only contains one element) - rust-lang#83037 (Support merge_functions option in NewPM since LLVM >= 12) - rust-lang#83052 (updated vulnerable deps) - rust-lang#83059 (Allow configuring `rustdoc --disable-minification` in config.toml) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
close #82871