[Webkit-unassigned] [Bug 232951] Prevent fused multiply add during ParseInt
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Nov 10 11:07:18 PST 2021
https://bugs.webkit.org/show_bug.cgi?id=232951
--- Comment #4 from Mikhail R. Gadelha <mikhail at igalia.com> ---
(In reply to Yusuke Suzuki from comment #3)
> Comment on attachment 443833 [details]
> Patch
>
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=443833&action=review
>
> Commented.
>
> > Source/JavaScriptCore/ChangeLog:18
> > + When parsing the string in parseInt, a compiler can wrongfully generate
> > + a fused multiply-add instruction, causing the conversion to be wrong
> > + for some high values. An add followed by a multiply gives the correct
> > + result and it is the code generated most of the times.
> > +
> > + This patch adds a volatile qualifier to the number variable, so the
> > + compiler doesn't try to optimize it, and enables a failing test on
> > + mips.
> > +
> > + The issue was found when cross compiling to mips with gcc 8.4.0 and
> > + options -ffp-contract=off -mmadd4.
>
> This is GCC issue, and we should not use `volatile` here. We should disable
> GCC's this optimization for this function via pragma etc.
> https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Specific-Option-
> Pragmas.html#Function-Specific-Option-Pragmas
> https://stackoverflow.com/questions/34436233/fused-multiply-add-and-default-
> rounding-modes
But these pragmas disable optimization for the whole function. Are you sure we should disable optimization for the whole function? I also tried to use `#pragma STDC FP_CONTRACT` but gcc doesn't seem to accept it yet: https://stackoverflow.com/questions/43352510/difference-in-gcc-ffp-contract-options
On other platforms that I tested, the compilers already generate an unfused multiply-add, so we don't seem to be generating worse code either.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211110/e6957bee/attachment.htm>
More information about the webkit-unassigned
mailing list