r229422 - in /trunk/gcc: ChangeLog match.pd tes...

rsandifo@gcc.gnu.org rsandifo@gcc.gnu.org
Tue Oct 27 11:51:00 GMT 2015


Author: rsandifo
Date: Tue Oct 27 11:51:43 2015
New Revision: 229422

URL: https://gcc.gnu.org/viewcvs?rev=229422&root=gcc&view=rev
Log:
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.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/builtin-sqrt-cmp-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/match.pd
    trunk/gcc/testsuite/ChangeLog



More information about the Gcc-cvs mailing list