* [PATCH] Fix ICE in rtl_for_decl_init on const vector initializers (PR debug/32914)
@ 2007-08-20 10:57 Jakub Jelinek
2007-09-09 19:13 ` Mark Mitchell
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2007-08-20 10:57 UTC (permalink / raw)
To: gcc-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix ICE in rtl_for_decl_init on const vector initializers (PR debug/32914)
2007-08-20 10:57 [PATCH] Fix ICE in rtl_for_decl_init on const vector initializers (PR debug/32914) Jakub Jelinek
@ 2007-09-09 19:13 ` Mark Mitchell
0 siblings, 0 replies; 2+ messages in thread
From: Mark Mitchell @ 2007-09-09 19:13 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
Jakub Jelinek wrote:
> 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.
OK.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-09-09 19:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-20 10:57 [PATCH] Fix ICE in rtl_for_decl_init on const vector initializers (PR debug/32914) Jakub Jelinek
2007-09-09 19:13 ` Mark Mitchell
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).