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][1/4] Fix PR87117


I believe Micha stumbled over this as well.  For stores to
string literals we miss VDEFs and loads from STRING_CSTs miss
VUSEs.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

2018-08-28  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/87117
	* tree-ssa-sccvn.c (fully_constant_vn_reference_p): Exclude
	void which is is_gimple_reg_type by checking for COMPLETE_TYPE_P.

	* gcc.dg/pr87117-1.c: New testcase.

Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c	(revision 263906)
+++ gcc/tree-ssa-sccvn.c	(working copy)
@@ -1408,6 +1408,7 @@ fully_constant_vn_reference_p (vn_refere
 
   /* Simplify reads from constants or constant initializers.  */
   else if (BITS_PER_UNIT == 8
+	   && COMPLETE_TYPE_P (ref->type)
 	   && is_gimple_reg_type (ref->type)
 	   && (!INTEGRAL_TYPE_P (ref->type)
 	       || TYPE_PRECISION (ref->type) % BITS_PER_UNIT == 0))
Index: gcc/testsuite/gcc.dg/pr87117-1.c
===================================================================
--- gcc/testsuite/gcc.dg/pr87117-1.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr87117-1.c	(working copy)
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-inline -fno-tree-dce" } */
+
+int a, b, c;
+long *d;
+void fn1()
+{
+  for (; 0 < a;)
+    a++;
+}
+void fn3()
+{
+  for (; c; c++)
+    d[c] = 0;
+}
+void fn2()
+{
+  if (b)
+    fn3();
+  fn1();
+}


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