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 tree-data-ref.c ICE (PR tree-optimization/71872)


Hi!

As mentioned in the PR, we ICE on the following testcase, because
tree-data-ref.c for VIEW_CONVERT_EXPR<struct S>(0) attempts to create
ADDR_EXPR of INTEGER_CST, which is not really valid.

I've successfully bootstrapped/regtested earlier version of this patch
with is_gimple_constant instead of is_gimple_min_invariant on x86_64-linux
and i686-linux, ok for trunk if even this version succeeds?

2016-07-14  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/71872
	* tree-data-ref.c (get_references_in_stmt): Ignore references
	with is_gimple_constant get_base_address.

	* gcc.c-torture/compile/pr71872.c: New test.

--- gcc/tree-data-ref.c.jj	2016-07-11 22:18:08.000000000 +0200
+++ gcc/tree-data-ref.c	2016-07-14 14:03:57.902899566 +0200
@@ -3868,7 +3868,8 @@ get_references_in_stmt (gimple *stmt, ve
       if (DECL_P (op1)
 	  || (REFERENCE_CLASS_P (op1)
 	      && (base = get_base_address (op1))
-	      && TREE_CODE (base) != SSA_NAME))
+	      && TREE_CODE (base) != SSA_NAME
+	      && !is_gimple_min_invariant (base)))
 	{
 	  ref.ref = op1;
 	  ref.is_read = true;
--- gcc/testsuite/gcc.c-torture/compile/pr71872.c.jj	2016-07-14 14:14:17.132889043 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr71872.c	2016-07-14 14:14:05.000000000 +0200
@@ -0,0 +1,15 @@
+/* PR tree-optimization/71872 */
+
+struct __attribute__((may_alias)) S { int a; };
+
+void
+foo (int *x, struct S *y)
+{
+  int i;
+  for (i = 0; i < 16; i++)
+    {
+      int a = 0;
+      if (*x)
+        *(struct S *) y = *(struct S *) &a;
+    }
+}

	Jakub


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