public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@adacore.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: gcc-patches@gcc.gnu.org, Jeff Law <law@redhat.com>,
	Joseph Myers <joseph@codesourcery.com>
Subject: Re: [patch] Fix failure of ACATS c45503c at -O2
Date: Wed, 21 Oct 2015 13:15:00 -0000	[thread overview]
Message-ID: <2100616.AKovr9yibX@polaris> (raw)
In-Reply-To: <CAFiYyc3Ne8pLSYoOm6=8paXv6MUur8M0rdaUt4p8+-RkU+nw3Q@mail.gmail.com>

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

> Maybe add the comments to tree.def instead.

Good idea, revised patch attached.


	* tree.def (CEIL_DIV_EXPR, FLOOR_DIV_EXPR, ROUND_DIV_EXPR): Tweak
	comments.
	(TRUNC_MOD_EXPR, CEIL_MOD_EXPR, FLOOR_MOD_EXPR, ROUND_MOD_EXPR):
	Add comments on sign of the result.
        * 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: p.diff --]
[-- Type: text/x-patch, Size: 2259 bytes --]

Index: tree.def
===================================================================
--- tree.def	(revision 229123)
+++ tree.def	(working copy)
@@ -685,19 +685,27 @@ DEFTREECODE (MULT_HIGHPART_EXPR, "mult_h
 /* Division for integer result that rounds the quotient toward zero.  */
 DEFTREECODE (TRUNC_DIV_EXPR, "trunc_div_expr", tcc_binary, 2)
 
-/* Division for integer result that rounds the quotient toward infinity.  */
+/* Division for integer result that rounds it toward plus infinity.  */
 DEFTREECODE (CEIL_DIV_EXPR, "ceil_div_expr", tcc_binary, 2)
 
-/* Division for integer result that rounds toward minus infinity.  */
+/* Division for integer result that rounds it toward minus infinity.  */
 DEFTREECODE (FLOOR_DIV_EXPR, "floor_div_expr", tcc_binary, 2)
 
-/* Division for integer result that rounds toward nearest integer.  */
+/* Division for integer result that rounds it toward nearest integer.  */
 DEFTREECODE (ROUND_DIV_EXPR, "round_div_expr", tcc_binary, 2)
 
-/* Four kinds of remainder that go with the four kinds of division.  */
+/* Four kinds of remainder that go with the four kinds of division:  */
+
+/* The sign of the remainder is that of the dividend.  */
 DEFTREECODE (TRUNC_MOD_EXPR, "trunc_mod_expr", tcc_binary, 2)
+
+/* The sign of the remainder is the opposite of that of the divisor.  */
 DEFTREECODE (CEIL_MOD_EXPR, "ceil_mod_expr", tcc_binary, 2)
+
+/* The sign of the remainder is that of the divisor.  */
 DEFTREECODE (FLOOR_MOD_EXPR, "floor_mod_expr", tcc_binary, 2)
+
+/* The sign of the remainder is not predictable.  */
 DEFTREECODE (ROUND_MOD_EXPR, "round_mod_expr", tcc_binary, 2)
 
 /* Division for real result.  */
Index: fold-const.c
===================================================================
--- fold-const.c	(revision 229123)
+++ fold-const.c	(working copy)
@@ -12929,11 +12929,13 @@ 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:
       return RECURSE (op0);
 
+    case FLOOR_MOD_EXPR:
+      return RECURSE (op1);
+
+    case CEIL_MOD_EXPR:
+    case ROUND_MOD_EXPR:
     default:
       return tree_simple_nonnegative_warnv_p (code, type);
     }

  reply	other threads:[~2015-10-21 13:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20 16:38 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2100616.AKovr9yibX@polaris \
    --to=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=law@redhat.com \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).