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 PR66894


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2015-07-16  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/66894
	* tree-vrp.c (register_edge_assert_for_2): Fix bad assumption
	about deriving NE_EXPR from truncated values.

	* gcc.dg/torture/pr66894.c: New testcase.

Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c	(revision 225860)
+++ gcc/tree-vrp.c	(working copy)
@@ -5382,13 +5382,11 @@ register_edge_assert_for_2 (tree name, e
 	    }
 	  else if (CONVERT_EXPR_CODE_P (code))
 	    {
-	      /* For truncating conversions require that the constant
-	         fits in the truncated type if we are going to record
+	      /* For truncating conversions we cannot record
 		 an inequality.  */
 	      if (comp_code == NE_EXPR
 		  && (TYPE_PRECISION (TREE_TYPE (name2))
-		      < TYPE_PRECISION (TREE_TYPE (name)))
-		  && ! int_fits_type_p (val, TREE_TYPE (name2)))
+		      < TYPE_PRECISION (TREE_TYPE (name))))
 		continue;
 	      cst = fold_convert (TREE_TYPE (name2), val);
 	    }
Index: gcc/testsuite/gcc.dg/torture/pr66894.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr66894.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr66894.c	(working copy)
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+
+short a, b;
+
+int
+main ()
+{
+  for (; a != 1; a += 3)
+    {
+      int c = 0;
+      for (; c < 2; c++)
+	if (a)
+	  {
+	    char d = a;
+	    b = d ? 1 / d : 0; 
+	  }
+	else
+	  break;
+    }
+  return 0;
+}


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