56d343
2016-02-26  Jakub Jelinek  <jakub@redhat.com>
56d343
	    Eric Botcazou  <ebotcazou@adacore.com>
56d343
56d343
	PR rtl-optimization/69891
56d343
	* dse.c (scan_insn): If we can't figure out memset arguments
56d343
	or they are non-constant, call clear_rhs_from_active_local_stores.
56d343
56d343
--- gcc/testsuite/gcc.target/i386/pr69891.c	(nonexistent)
56d343
+++ gcc/testsuite/gcc.target/i386/pr69891.c	(revision 238137)
56d343
@@ -0,0 +1,30 @@
56d343
+/* PR rtl-optimization/69891 */
56d343
+/* { dg-do run } */
56d343
+/* { dg-options "-O -fno-tree-fre -mstringop-strategy=libcall -Wno-psabi" } */
56d343
+/* { dg-additional-options "-mno-sse" { target ia32 } } */
56d343
+
56d343
+typedef unsigned short A;
56d343
+typedef unsigned short B __attribute__ ((vector_size (32)));
56d343
+typedef unsigned int C;
56d343
+typedef unsigned int D __attribute__ ((vector_size (32)));
56d343
+typedef unsigned long long E;
56d343
+typedef unsigned long long F __attribute__ ((vector_size (32)));
56d343
+
56d343
+__attribute__((noinline, noclone)) unsigned
56d343
+foo(D a, B b, D c, F d)
56d343
+{
56d343
+  b /= (B) {1, -c[0]} | 1;
56d343
+  c[0] |= 7;
56d343
+  a %= c | 1;
56d343
+  c ^= c;
56d343
+  return a[0] + b[15] + c[0] + d[3];
56d343
+}
56d343
+
56d343
+int
56d343
+main ()
56d343
+{
56d343
+  unsigned x = foo ((D) {}, (B) {}, (D) {}, (F) {});
56d343
+  if (x != 0)
56d343
+    __builtin_abort ();
56d343
+  return 0;
56d343
+}
56d343
--- gcc/dse.c	(revision 238136)
56d343
+++ gcc/dse.c	(revision 238137)
56d343
@@ -2582,6 +2582,8 @@
56d343
 		      active_local_stores = insn_info;
56d343
 		    }
56d343
 		}
56d343
+	      else
56d343
+		clear_rhs_from_active_local_stores ();
56d343
 	    }
56d343
 	}
56d343