[PATCH] D151934: InstCombine: Recognize fneg when performed as bitcasted integer
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 15:41:19 PDT 2023
efriedma added a comment.
If you compile the following for x86 with -mno-sse:
void f(float *x) { *x = -*x; }
You get the following:
movl 4(%esp), %eax
flds (%eax)
fchs
fstps (%eax)
retl
This transforms snan into qnan. That's arguably incorrect, but it's what every x86 compiler has emitted since forever, so nobody has tried to fix it.
The whole thing isn't really relevant for this patch, though, because you trigger the exact same thing if you bitcast the float to an i32. (The exception is triggered on the flds which loads the register, not the fchs which actually flips the sign bit.)
-----
In any case, I'm more concerned about the UnsafeFPMath thing.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151934/new/
https://reviews.llvm.org/D151934
More information about the llvm-commits
mailing list