diff mbox

Fix PR67052

Message ID alpine.LSU.2.11.1507301318150.19642@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener July 30, 2015, 11:19 a.m. UTC
The following patch avoids folding NaN < 0 to false if -ftrapping-math
is in effect.

Bootstrap & regtest pending on x86_64-unknown-linux-gnu.

Richard.

2015-07-30  Richard Biener  <rguenther@suse.de>

	PR middle-end/67052
	* fold-const.c (fold_binary_loc): Do not fold NaN < 0 to false
	if FP math can trap.

Comments

Richard Biener July 30, 2015, 2:30 p.m. UTC | #1
On Thu, 30 Jul 2015, Richard Biener wrote:

> 
> The following patch avoids folding NaN < 0 to false if -ftrapping-math
> is in effect.
> 
> Bootstrap & regtest pending on x86_64-unknown-linux-gnu.

FAIL: gcc.dg/fold-abs-4.c scan-tree-dump-times gimple "ABS" 0
FAIL: gcc.dg/pr15784-1.c scan-tree-dump-times gimple "ABS_EXPR" 0
FAIL: gcc.dg/tree-ssa/pr20139.c scan-tree-dump-times optimized 
"link_error" 0

all cases expect the transform to happen without -fno-trapping-math.

Shall I adjust those testcases or is my patch wrong?

Thanks,
Richard.

> Richard.
> 
> 2015-07-30  Richard Biener  <rguenther@suse.de>
> 
> 	PR middle-end/67052
> 	* fold-const.c (fold_binary_loc): Do not fold NaN < 0 to false
> 	if FP math can trap.
> 
> Index: gcc/fold-const.c
> ===================================================================
> --- gcc/fold-const.c	(revision 226387)
> +++ gcc/fold-const.c	(working copy)
> @@ -11634,7 +11455,9 @@ fold_binary_loc (location_t loc,
>        /* Convert ABS_EXPR<x> < 0 to false.  */
>        strict_overflow_p = false;
>        if (code == LT_EXPR
> -	  && (integer_zerop (arg1) || real_zerop (arg1))
> +	  && (integer_zerop (arg1)
> +	      || ((! HONOR_NANS (arg0) || !flag_trapping_math)
> +		  && real_zerop (arg1)))
>  	  && tree_expr_nonnegative_warnv_p (arg0, &strict_overflow_p))
>  	{
>  	  if (strict_overflow_p)
diff mbox

Patch

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	(revision 226387)
+++ gcc/fold-const.c	(working copy)
@@ -11634,7 +11455,9 @@  fold_binary_loc (location_t loc,
       /* Convert ABS_EXPR<x> < 0 to false.  */
       strict_overflow_p = false;
       if (code == LT_EXPR
-	  && (integer_zerop (arg1) || real_zerop (arg1))
+	  && (integer_zerop (arg1)
+	      || ((! HONOR_NANS (arg0) || !flag_trapping_math)
+		  && real_zerop (arg1)))
 	  && tree_expr_nonnegative_warnv_p (arg0, &strict_overflow_p))
 	{
 	  if (strict_overflow_p)