tree-complex.c: fix some_nonzerop test over reals (and a bug fix)
Laurent Thevenoux
laurent.thevenoux@inria.fr
Thu Oct 5 14:41:00 GMT 2017
Hello,
This patch improves the some_nonzerop(tree t) function from tree-complex.c file (the function is only used there).
This function returns true if a tree as a parameter is not the constant 0 (or +0.0 only for reals when !flag_signed_zeros ). The former result is then used to determine if some simplifications are possible for complex expansions (addition, multiplication, and division).
Unfortunately, if the tree is a real constant, the function always return true, even for +0.0 because of the explicit test on flag_signed_zeros (so if your system enables signed zeros you cannot benefit from those simplifications). To avoid this behavior and allow complex expansion simplifications, I propose the following patch, which test for the sign of the real constant 0.0 instead of checking the flag.
This first fix reveals a bug (thanks to c-c++-common/torture/complex-sign-add.c ) in the simplification section of expand_complex_addition (also fixed in the patch).
The patch has passed bootstrap and testing on x86_64-pc-linux-gnu .
Best regards,
Laurent Thévenoux
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-some_nonzerop.patch
Type: text/x-patch
Size: 1579 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20171005/869bdae1/attachment.bin>
More information about the Gcc-patches
mailing list