This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR79971


Bootstrapped and tested on x86_64-unknown-linux-gnu,
tested with a cross to arm, applied.

Richard.

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.

Index: gcc/gimple-expr.c
===================================================================
--- gcc/gimple-expr.c	(revision 245987)
+++ gcc/gimple-expr.c	(working copy)
@@ -124,7 +124,7 @@
   /* 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: gcc/testsuite/gcc.dg/fixed-point/pr79971.c
===================================================================
--- gcc/testsuite/gcc.dg/fixed-point/pr79971.c	(revision 0)
+++ gcc/testsuite/gcc.dg/fixed-point/pr79971.c	(working copy)
@@ -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)
+	;
+    }
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]