]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
graphite-sese-to-poly.c (extract_affine): For casts increasing precision do not perfo...
authorRichard Biener <rguenther@suse.de>
Fri, 6 Oct 2017 07:03:51 +0000 (07:03 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 6 Oct 2017 07:03:51 +0000 (07:03 +0000)
2017-10-06  Richard Biener  <rguenther@suse.de>

* graphite-sese-to-poly.c (extract_affine): For casts increasing
precision do not perform modulo reduction.

From-SVN: r253474

gcc/ChangeLog
gcc/graphite-sese-to-poly.c

index 06aaa06f75d956c3c2e1565a04674b5a3babc65d..54ba096a161a3a60086af46815decda567fbc8a1 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-06  Richard Biener  <rguenther@suse.de>
+
+       * graphite-sese-to-poly.c (extract_affine): For casts increasing
+       precision do not perform modulo reduction.
+
 2017-10-06  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/82436
index 8611e86cc607c9db72b18d97a9bb55e20922bb76..6cd5bc7c9d9a280c51e67e1cdc0ecda3145cd467 100644 (file)
@@ -299,11 +299,18 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space)
       return res;
 
     CASE_CONVERT:
-      res = extract_affine (s, TREE_OPERAND (e, 0), space);
-      /* signed values, even if overflow is undefined, get modulo-reduced.  */
-      if (! TYPE_UNSIGNED (type))
-       res = wrap (res, TYPE_PRECISION (type) - 1);
-      break;
+      {
+       tree itype = TREE_TYPE (TREE_OPERAND (e, 0));
+       res = extract_affine (s, TREE_OPERAND (e, 0), space);
+       /* Signed values, even if overflow is undefined, get modulo-reduced.
+          But only if not all values of the old type fit in the new.  */
+       if (! TYPE_UNSIGNED (type)
+           && ((TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (e, 0)))
+                && TYPE_PRECISION (type) <= TYPE_PRECISION (itype))
+               || TYPE_PRECISION (type) < TYPE_PRECISION (itype)))
+         res = wrap (res, TYPE_PRECISION (type) - 1);
+       break;
+      }
 
     case NON_LVALUE_EXPR:
       res = extract_affine (s, TREE_OPERAND (e, 0), space);