> So the only question is whether or not the CEIL_MOD_EXPR and
> ROUND_MOD_EXPR bits are right.  I'm confident the change to
> FLOOR_MOD_EXPR is right.

OK.

> Do we have any reasonable way to test CEIL_MOD_EXPR & ROUND_MOD_EXPR?

Note that the patch makes the function punt on those 2 so it can do no harm.
The sign of CEIL_MOD_EXPR is predictable (opposite of that of the divisor) but 
you cannot use that in the context; and finally the sign of ROUND_MOD_EXPR 
isn't predictable.

I can add a few more comments:

Index: fold-const.c
===================================================================
--- fold-const.c        (revision 229022)
+++ fold-const.c        (working copy)
@@ -12982,11 +12982,18 @@ 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:
+       /* The sign of the remainder is the opposite of that of the divisor,
+         but this cannot be used in this context.  */
+    case ROUND_MOD_EXPR:
+      /* The sign of the remainder is not predictable.  */
     default:
       return tree_simple_nonnegative_warnv_p (code, type);
     }


-- 
Eric Botcazou

Reply via email to