re PR target/79971 (ICE in const_binop, at fold-const.c:1554 on ARM target with satur...
authorRichard Biener <rguenther@suse.de>
Thu, 9 Mar 2017 13:20:50 +0000 (13:20 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 9 Mar 2017 13:20:50 +0000 (13:20 +0000)
2017-03-09  Richard Biener  <rguenther@suse.de>

PR middle-end/79971
* gimple-expr.c (useless_type_conversion_p): Preserve
TYPE_SATURATING for fixed-point types.

* gcc.dg/fixed-point/pr79971.c: New testcase.

From-SVN: r246002

gcc/ChangeLog
gcc/gimple-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/fixed-point/pr79971.c [new file with mode: 0644]

index da50ae6cd43d468bf62c87b06a9000f8e27696df..7eab04210668c9f58cc64ac853902cd501877118 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-09  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/79971
+       * gimple-expr.c (useless_type_conversion_p): Preserve
+       TYPE_SATURATING for fixed-point types.
+
 2017-03-09  Richard Biener  <rguenther@suse.de>
 
        PR ipa/79970
index 2ee87c2c4908493467e6cb50db66ab9d5be562f4..9d8034c31921976cb2bcca5738d2b481ce74442f 100644 (file)
@@ -124,7 +124,7 @@ useless_type_conversion_p (tree outer_type, tree inner_type)
   /* Fixed point types with the same mode are compatible.  */
   else if (FIXED_POINT_TYPE_P (inner_type)
           && FIXED_POINT_TYPE_P (outer_type))
-    return true;
+    return TYPE_SATURATING (inner_type) == TYPE_SATURATING (outer_type);
 
   /* We need to take special care recursing to pointed-to types.  */
   else if (POINTER_TYPE_P (inner_type)
index 78f68314db1a416dc747fe87967a0373719c0c27..3e7e15760b7219d8c7f2b7b8d84eab7fcdbb7bb7 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-09  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/79971
+       * gcc.dg/fixed-point/pr79971.c: New testcase.
+
 2017-03-09  Richard Biener  <rguenther@suse.de>
 
        PR ipa/79970
diff --git a/gcc/testsuite/gcc.dg/fixed-point/pr79971.c b/gcc/testsuite/gcc.dg/fixed-point/pr79971.c
new file mode 100644 (file)
index 0000000..cccea1f
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+void
+a ()
+{
+  unsigned _Accum b;
+  for (b = 0.1; b; b += 0.1uk)
+    {
+      _Sat unsigned _Accum b;
+      for (b = 0; b <= 0.8; b = 0.1)
+       ;
+    }
+}