public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Fix failure of ACATS c45503c at -O2
@ 2015-10-20 16:38 Eric Botcazou
  2015-10-20 19:04 ` Jeff Law
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Botcazou @ 2015-10-20 16:38 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 874 bytes --]

Hi,

this test started to fail recently as the result of the work of Richard S., 
but the underlying issue had been latent for a long time.  It boils down to 
this excerpt from the VRP1 dump file:

Found new range for _9: [0, 12]
marking stmt to be not simulated again

Visiting statement:
_3 = _9 %[fl] _11;
Found new range for _3: [0, +INF]

which is plain wrong since the sign of FLOOR_MOD_EXPR is the sign of the 
divisor and not that of the dividend (the latter is for TRUNC_MOD_EXPR).

I have attached a fix for mainline and another one for the 4.9/5 branches.

Tested on x86_64-suse-linux, OK for all active branches?


2015-10-20  Eric Botcazou  <ebotcazou@adacore.com>

	* fold-const.c (tree_binary_nonnegative_warnv_p) <FLOOR_MOD_EXPR>:
	Recurse on operand #1 instead of operand #0.
	<CEIL_MOD_EXPR>: Do not recurse.
	<ROUND_MOD_EXPR>: Likewise.

-- 
Eric Botcazou

[-- Attachment #2: p1.diff --]
[-- Type: text/x-patch, Size: 722 bytes --]

Index: fold-const.c
===================================================================
--- fold-const.c	(revision 229022)
+++ fold-const.c	(working copy)
@@ -12982,11 +12982,15 @@ tree_binary_nonnegative_warnv_p (enum tr
       return RECURSE (op0) && RECURSE (op1);
 
     case TRUNC_MOD_EXPR:
-    case CEIL_MOD_EXPR:
-    case FLOOR_MOD_EXPR:
-    case ROUND_MOD_EXPR:
+      /* The sign of the remainder is that of the dividend.  */
       return RECURSE (op0);
 
+    case FLOOR_MOD_EXPR:
+      /* The sign of the remainder is that of the divisor.  */
+      return RECURSE (op1);
+
+    case CEIL_MOD_EXPR:
+    case ROUND_MOD_EXPR:
     default:
       return tree_simple_nonnegative_warnv_p (code, type);
     }

[-- Attachment #3: p2.diff --]
[-- Type: text/x-patch, Size: 806 bytes --]

Index: fold-const.c
===================================================================
--- fold-const.c	(revision 228932)
+++ fold-const.c	(working copy)
@@ -14853,11 +14853,17 @@ tree_binary_nonnegative_warnv_p (enum tr
 						strict_overflow_p));
 
     case TRUNC_MOD_EXPR:
-    case CEIL_MOD_EXPR:
-    case FLOOR_MOD_EXPR:
-    case ROUND_MOD_EXPR:
+      /* The sign of the remainder is that of the dividend.  */
       return tree_expr_nonnegative_warnv_p (op0,
 					    strict_overflow_p);
+
+    case FLOOR_MOD_EXPR:
+      /* The sign of the remainder is that of the divisor.  */
+      return tree_expr_nonnegative_warnv_p (op1,
+					    strict_overflow_p);
+
+    case CEIL_MOD_EXPR:
+    case ROUND_MOD_EXPR:
     default:
       return tree_simple_nonnegative_warnv_p (code, type);
     }

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-10-21 21:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-20 16:38 [patch] Fix failure of ACATS c45503c at -O2 Eric Botcazou
2015-10-20 19:04 ` Jeff Law
2015-10-20 22:10   ` Joseph Myers
2015-10-21  5:57     ` Jeff Law
2015-10-21  7:50       ` Eric Botcazou
2015-10-21  9:56         ` Richard Biener
2015-10-21 13:15           ` Eric Botcazou
2015-10-21 13:18             ` Richard Biener
2015-10-21 21:11             ` Richard Sandiford
2015-10-20 22:30   ` Eric Botcazou
2015-10-20 22:55     ` Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).