diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2015-10-27 11:51:43 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2015-10-27 11:51:43 +0000 |
commit | c53233c660496efed5115ec1f30d3009ecf716d6 (patch) | |
tree | 81cfb3c2323bef8e2dc2dea990e95e29dc92fc9d /gcc/builtins.c | |
parent | 3f8c04e73cd50d34d2b9f4128c615dbd35a6e40a (diff) | |
download | gcc-c53233c660496efed5115ec1f30d3009ecf716d6.zip gcc-c53233c660496efed5115ec1f30d3009ecf716d6.tar.gz gcc-c53233c660496efed5115ec1f30d3009ecf716d6.tar.bz2 |
Fold comparisons between sqrt and zero
The expression:
signbit(sqrt(x))
is always 0 for -ffast-math. The signbit fold first converts it to:
sqrt(x) < 0
and whether we realise that this is false depends on a race between two
folders: the sqrt comparison folder, which wants to convert it to
x < 0*0
and the generic tree_expr_nonnegative_p rule for ... < 0, which would
give the hoped-for 0.
The sqrt code already handles comparisons with negative values specially,
so this patch simply extends that idea to comparisons with zero.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* match.pd: Handle sqrt(x) cmp 0 specially.
gcc/testsuite/
* gcc.dg/torture/builtin-sqrt-cmp-1.c: New test.
From-SVN: r229422
Diffstat (limited to 'gcc/builtins.c')
0 files changed, 0 insertions, 0 deletions