On Fri, 11 Apr 2014, Richard Biener wrote:

> 
> Both premature (can't find or think of an existing place that would
> rely on those) and bogus, - (4 /[fl] 5) isn't equal to (4 /[fl] -5).
> Removing and not trying to fold into 4 /[cl] -5 as we have no good
> way of creating testcases (that also include the negation).
> 
> Bootstrap / regtest on x86_64-unknown-linux-gnu pending.
> 
> Ok for trunk? (not a regression AFAIK)

With testcase now.

Richard.

2014-04-11  Richard Biener  <rguent...@suse.de>

        PR middle-end/55022
        * fold-const.c (negate_expr_p): Don't negate directional rounding
        division.
        (fold_negate_expr): Likewise.

        * gcc.dg/graphite/pr55022.c: New testcase.

Index: gcc/fold-const.c
===================================================================
*** gcc/fold-const.c    (revision 209292)
--- gcc/fold-const.c    (working copy)
*************** negate_expr_p (tree t)
*** 484,491 ****
  
      case TRUNC_DIV_EXPR:
      case ROUND_DIV_EXPR:
-     case FLOOR_DIV_EXPR:
-     case CEIL_DIV_EXPR:
      case EXACT_DIV_EXPR:
        /* In general we can't negate A / B, because if A is INT_MIN and
         B is 1, we may turn this into INT_MIN / -1 which is undefined
--- 484,489 ----
*************** fold_negate_expr (location_t loc, tree t
*** 682,689 ****
  
      case TRUNC_DIV_EXPR:
      case ROUND_DIV_EXPR:
-     case FLOOR_DIV_EXPR:
-     case CEIL_DIV_EXPR:
      case EXACT_DIV_EXPR:
        /* In general we can't negate A / B, because if A is INT_MIN and
         B is 1, we may turn this into INT_MIN / -1 which is undefined
--- 680,685 ----
Index: gcc/testsuite/gcc.dg/graphite/pr55022.c
===================================================================
*** gcc/testsuite/gcc.dg/graphite/pr55022.c     (revision 0)
--- gcc/testsuite/gcc.dg/graphite/pr55022.c     (working copy)
***************
*** 0 ****
--- 1,27 ----
+ /* { dg-do run } */
+ /* { dg-options "-O2 -fgraphite-identity" } */
+ 
+ extern void abort (void);
+ 
+ void __attribute__((noinline,noclone))
+ f(int *limit, int minLen, int maxLen)
+ {
+   int i;
+ 
+   for (i = minLen; i <= maxLen; i++) {
+       limit[i] = i;
+   }
+ }
+ 
+ int main()
+ {
+   int limit[256], i;
+   f (limit, 0, 255);
+   for (i = 0; i < 256; ++i)
+     {
+       if (limit[i] != i)
+       abort ();
+       __asm__ volatile ("" : : : "memory");
+     }
+   return 0;
+ }

Reply via email to