-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Codegen and const eval evaluates -1.0 % -1.0
to 0 with different signs
#109567
Comments
IEEE 754-2019 §5.3.1 says
So
rust/compiler/rustc_apfloat/src/lib.rs Lines 321 to 325 in f421586
|
I think it's optimized, https://rust.godbolt.org/z/Eqae9xPKE example::f:
sub rsp, 24
mov rax, qword ptr [rip + core::hint::black_box@GOTPCREL]
mov qword ptr [rsp], rax
movsd xmm0, qword ptr [rip + .LCPI7_0]
movsd qword ptr [rsp + 8], xmm0
call rax
mov rax, qword ptr [rsp]
movaps xmm1, xmm0
movsd xmm0, qword ptr [rsp + 8]
movsd qword ptr [rsp + 16], xmm1
call rax
movaps xmm1, xmm0
movsd xmm0, qword ptr [rsp + 16]
mov rax, qword ptr [rip + fmod@GOTPCREL]
call rax
add rsp, 24
ret
example::g:
xorps xmm0, xmm0
ret |
Not by LLVM.
|
it's done by rustc +dev --edition 2021 ./p/debug3.rs -Z mir-opt-level=0 I'm still investigating the specific line of code, but it seems in part of |
The line of code is here:
|
This looks to me like a duplicate of #102403? |
Yes it's the same root cause. Although the reproduction here requires only stable rust |
Closing as a duplicate of #102403, then. |
Not sure whether
-1.0 % -1.0
should be0
or-0
according to IEEE 754, but codegen (with black box) and const eval (without blackbox) should produce the same resultMeta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: