Commit 9c99fe75 by Richard Sandiford Committed by Richard Sandiford

Remove undefined behaviour from builtins-20.c

builtins-20.c had:

      if (cos((y*=2, -fabs(tan(x/-y)))) != cos((y*=2,tan(x/y))))
        link_error ();

which is undefined behaviour.  The test expected that y had the same
value in x/y and x/-y, but gimplification actually implements the
"obvious" interpretation, multiplying y by 2, using it for one cos call,
then multiplying it by 2 again and using it for the other cos call.

The file has other (valid) tests that side-effects don't block
optimisation, such as:

      if (cosf((y*=3, -x)) != cosf((y*=3,x)))
        link_error ();

so this patch simply removes this instance.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/testsuite/
	* gcc.dg/builtins-20.c: Remove undefined behavior.

From-SVN: r228963
parent 613743a2
2015-10-19 Richard Sandiford <richard.sandiford@arm.com>
* gcc.dg/builtins-20.c: Remove undefined behavior.
2015-10-18 Mikael Morin <mikael@gcc.gnu.org> 2015-10-18 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/67758 PR fortran/67758
......
...@@ -122,7 +122,7 @@ void test2(double x, double y) ...@@ -122,7 +122,7 @@ void test2(double x, double y)
if (cos((y*=3, -x)) != cos((y*=3,x))) if (cos((y*=3, -x)) != cos((y*=3,x)))
link_error (); link_error ();
if (cos((y*=2, -fabs(tan(x/-y)))) != cos((y*=2,tan(x/y)))) if (cos(-fabs(tan(x/-y))) != cos(tan(x/y)))
link_error (); link_error ();
if (cos(copysign(x,y)) != cos(x)) if (cos(copysign(x,y)) != cos(x))
...@@ -350,7 +350,7 @@ void test2f(float x, float y) ...@@ -350,7 +350,7 @@ void test2f(float x, float y)
if (cosf((y*=3, -x)) != cosf((y*=3,x))) if (cosf((y*=3, -x)) != cosf((y*=3,x)))
link_error (); link_error ();
if (cosf((y*=2, -fabsf(tanf(x/-y)))) != cosf((y*=2,tanf(x/y)))) if (cosf(-fabsf(tanf(x/-y))) != cosf(tanf(x/y)))
link_error (); link_error ();
if (cosf(copysignf(x,y)) != cosf(x)) if (cosf(copysignf(x,y)) != cosf(x))
...@@ -577,7 +577,7 @@ void test2l(long double x, long double y) ...@@ -577,7 +577,7 @@ void test2l(long double x, long double y)
if (cosl((y*=3, -x)) != cosl((y*=3,x))) if (cosl((y*=3, -x)) != cosl((y*=3,x)))
link_error (); link_error ();
if (cosl((y*=2, -fabsl(tanl(x/-y)))) != cosl((y*=2,tanl(x/y)))) if (cosl(-fabsl(tanl(x/-y))) != cosl(tanl(x/y)))
link_error (); link_error ();
if (cosl(copysignl(x,y)) != cosl(x)) if (cosl(copysignl(x,y)) != cosl(x))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment