This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix failure of ACATS c45503c at -O2
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Jeff Law <law at redhat dot com>, Joseph Myers <joseph at codesourcery dot com>
- Date: Wed, 21 Oct 2015 15:06:33 +0200
- Subject: Re: [patch] Fix failure of ACATS c45503c at -O2
- Authentication-results: sourceware.org; auth=none
- References: <1990513 dot tXxA4OvBVE at polaris> <1514366 dot LKDlpZBPto at polaris> <CAFiYyc3Ne8pLSYoOm6=8paXv6MUur8M0rdaUt4p8+-RkU+nw3Q at mail dot gmail dot com>
> 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
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);
}