[GCC][PATCH][mid-end] Optimize x * copysign (1.0, y) [Patch (1/2)]

Joseph Myers joseph@codesourcery.com
Mon Jun 12 16:52:00 GMT 2017


On Mon, 12 Jun 2017, Tamar Christina wrote:

> x * copysign (1.0, y) and 
> x * copysign (-1.0, y) 
> 
> to:
> 
> x ^ (y & (1 << sign_bit_position))

Note that this needs to be disabled for -fsignaling-nans, as if x is a 
signaling NaN, the multiplication converts it to a quiet NaN and raises 
"invalid".

> This is done by creating a special builtin during matching and generate the
> appropriate instructions during expand. This new builtin is called XORSIGN.

If the built-in function has a user-visible name such as __builtin_xorsign 
(as opposed to one that's not a C identifier), it needs to be documented 
as a user-visible feature.  I'd suggest not having such a user-visible 
built-in function.

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list