-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustc generates badly optimized for wrapping_div #34634
Comments
Not sure why LLVM doesn't optimise this more (the duplicated check of cmpl $-2147483648, %edi
jne .LBB0_2
movl $-2147483648, %eax
cmpl $-1, %esi
je .LBB0_3
.LBB0_2:
movl %edi, %eax
cltd
idivl %esi
.LBB0_3:
retq Which is what is expected. |
Currently generated code looks just fine to me. Fixed. |
Still looks fine it seems: (latest stable) cmpl $-2147483648, %edi
jne .LBB0_2
movl $-2147483648, %eax
cmpl $-1, %esi
je .LBB0_4
.LBB0_2:
testl %esi, %esi
je .LBB0_5
movl %edi, %eax
cltd
idivl %esi
.LBB0_4:
popq %rcx
retq
.LBB0_5:
leaq panic_loc.2(%rip), %rdi
callq _ZN4core9panicking5panic17hec1812dcc135e139E@PLT
|
Given this just needs a test, this could be transformed into an easy issue for newcomers. |
Triage; not aware of any test added. Still gives the good code when compiled. |
Add test for issue rust-lang#34634 Closes rust-lang#34634
Rollup of 13 pull requests Successful merges: - rust-lang#76135 (Stabilize some Option methods as const) - rust-lang#76628 (Add sample defaults for config.toml ) - rust-lang#76846 (Avoiding unnecesary allocations at rustc_errors) - rust-lang#76867 (Use intra-doc links in core/src/iter when possible) - rust-lang#76868 (Finish moving to intra doc links for std::sync) - rust-lang#76872 (Remove DeclareMethods) - rust-lang#76936 (Add non-`unsafe` `.get_mut()` for `Unsafecell`) - rust-lang#76958 (Replace manual as_nanos and as_secs_f64 reimplementations) - rust-lang#76959 (Replace write_fmt with write!) - rust-lang#76961 (Add test for issue rust-lang#34634) - rust-lang#76962 (Use const_cstr macro in consts.rs) - rust-lang#76963 (Remove unused static_assert macro) - rust-lang#77000 (update Miri) Failed merges: r? `@ghost`
Gives:
Specifically, .LBB0_7 is unreachable, but LLVM can't quite figure that out. It's probably possible to write wrapping_div in a way which avoids this problem.
The text was updated successfully, but these errors were encountered: