public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix ICE in rtl_for_decl_init on const vector initializers (PR debug/32914)
Date: Mon, 20 Aug 2007 10:57:00 -0000	[thread overview]
Message-ID: <20070820105650.GV2063@devserv.devel.redhat.com> (raw)

Hi!

This is a P1 regression caused by
http://gcc.gnu.org/ml/gcc-patches/2006-03/msg01567.html
on 4.2 branch and on the trunk.
For some cases this has been fixed by
http://gcc.gnu.org/PR28692
but not for all.

The problem here is that a VECTOR_TYPE CONSTRUCTOR will be
expand_expr (... EXPAND_INITIALIZER)
to a MEM.  The following patch fixes that by using
the same thing as gimplify_init_constructor does on such
VECTOR_TYPE CONSTRUCTOR initializers - creates a VECTOR_CST
from it.

Ok for trunk/4.2?

2007-08-20  Jakub Jelinek  <jakub@redhat.com>

	PR debug/32914
	* dwarf2out.c (rtl_for_decl_init): If vector decl has CONSTRUCTOR
	initializer, use build_vector_from_ctor if possible to create
	VECTOR_CST out of it.  If vector initializer is not VECTOR_CST
	even after this, return NULL.

	* d++.dg/debug/const3.C: New test.
	* d++.dg/debug/const4.C: New test.
	* d++.dg/debug/dwarf2/const1.C: New test.
	* d++.dg/debug/dwarf2/const2.C: New test.
	* d++.dg/debug/dwarf2/const2b.C: New test.

--- gcc/dwarf2out.c.jj	2007-08-20 09:49:24.000000000 +0200
+++ gcc/dwarf2out.c	2007-08-20 12:04:21.000000000 +0200
@@ -10402,6 +10402,43 @@ rtl_for_decl_init (tree init, tree type)
   else if (initializer_constant_valid_p (init, type)
 	   && ! walk_tree (&init, reference_to_unused, NULL, NULL))
     {
+      /* Convert vector CONSTRUCTOR initializers to VECTOR_CST if
+	 possible.  */
+      if (TREE_CODE (type) == VECTOR_TYPE)
+	switch (TREE_CODE (init))
+	  {
+	  case VECTOR_CST:
+	    break;
+	  case CONSTRUCTOR:
+	    if (TREE_CONSTANT (init))
+	      {
+		VEC(constructor_elt,gc) *elts = CONSTRUCTOR_ELTS (init);
+		bool constant_p = true;
+		tree value;
+		unsigned HOST_WIDE_INT ix;
+
+		/* Even when ctor is constant, it might contain non-*_CST
+		   elements (e.g. { 1.0/0.0 - 1.0/0.0, 0.0 }) and those don't
+		   belong into VECTOR_CST nodes.  */
+		FOR_EACH_CONSTRUCTOR_VALUE (elts, ix, value)
+		  if (!CONSTANT_CLASS_P (value))
+		    {
+		      constant_p = false;
+		      break;
+		    }
+
+		if (constant_p)
+		  {
+		    init = build_vector_from_ctor (type, elts);
+		    break;
+		  }
+	      }
+	    /* FALLTHRU */
+
+	  default:
+	    return NULL;
+	  }
+
       rtl = expand_expr (init, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
 
       /* If expand_expr returns a MEM, it wasn't immediate.  */
--- gcc/testsuite/g++.dg/debug/const3.C.jj	2007-08-20 12:07:16.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/const3.C	2007-08-20 12:07:29.000000000 +0200
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+typedef float FloatVect __attribute__((__vector_size__(16)));
+const FloatVect Foo = { 250000000.0, 0.0, 0.0, 0.0 };
--- gcc/testsuite/g++.dg/debug/const4.C.jj	2007-08-20 12:07:42.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/const4.C	2007-08-20 12:11:20.000000000 +0200
@@ -0,0 +1,2 @@
+/* { dg-do compile } */
+const __complex__ int x = 2i;
--- gcc/testsuite/g++.dg/debug/dwarf2/const1.C.jj	2007-08-20 12:08:54.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/const1.C	2007-08-20 12:18:17.000000000 +0200
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O -gdwarf-2 -dA" } */
+/* { dg-final { scan-assembler "DW_AT_const_value" } } */
+
+extern void x ();
+void (* const f) () = x;
--- gcc/testsuite/g++.dg/debug/dwarf2/const2.C.jj	2007-08-20 12:08:57.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/const2.C	2007-08-20 12:09:24.000000000 +0200
@@ -0,0 +1,6 @@
+/* { dg-do compile { target powerpc_altivec_ok } } */
+/* { dg-options "-O -gdwarf-2 -dA -maltivec" } */
+/* { dg-final { scan-assembler "DW_AT_const_value" } } */
+
+typedef float FloatVect __attribute__((__vector_size__(16)));
+const FloatVect Foo = { 250000000.0, 0.0, 0.0, 0.0 };
--- gcc/testsuite/g++.dg/debug/dwarf2/const2b.C.jj	2007-08-20 12:09:00.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/const2b.C	2007-08-20 12:09:31.000000000 +0200
@@ -0,0 +1,6 @@
+/* { dg-do compile { target i386*-*-* } } */
+/* { dg-options "-O -gdwarf-2 -dA -msse" } */
+/* { dg-final { scan-assembler "DW_AT_const_value" } } */
+
+typedef float FloatVect __attribute__((__vector_size__(16)));
+const FloatVect Foo = { 250000000.0, 0.0, 0.0, 0.0 };

	Jakub

             reply	other threads:[~2007-08-20 10:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-20 10:57 Jakub Jelinek [this message]
2007-09-09 19:13 ` Mark Mitchell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070820105650.GV2063@devserv.devel.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).