> On 3/14/07, Dorit Nuzman <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > We have a '{2,2}' expression (vector initializer) propagated by dom
into a
> > BIT_FIELD_REF:
> >
> > before (bug.c.105t.vrp2):
> >
> > vector long int vect_cst_.47;
> > vect_cst_.47_66 = {2, 2};
> > D.2103_79 = BIT_FIELD_REF <vect_cst_.47_66, 64, 0>;
> >
> > after (bug.c.106t.dom3):
> > "
> > Optimizing block #7
> >
> > Optimizing statement <L0>:;
> > Optimizing statement D.2102_78 = BIT_FIELD_REF
<vect_vec_iv_.48_67,
> > 64, 0>;
> > Optimizing statement D.2103_79 = BIT_FIELD_REF <vect_cst_.47_66,
64,
> > 0>;
> > Replaced 'vect_cst_.47_66' with constant '{2, 2}'
> > "
> >
> > D.2103_79 = BIT_FIELD_REF <{2, 2}, 64, 0>;
> >
> >
> > ...which causes he following ICE:
> > "
> > bug.c:8: error: invalid reference prefix
> > {2, 2}
> > bug.c:8: internal compiler error: verify_stmts failed
> > "
> >
> > Several testcases are available in the bugzilla report (PR30784).
> >
> > So, the question is - what needs to be fixed - is it copy propagation
that
> > allows propagating the initializer into a BIT_FIELD_REF? or vect_lower
pass
> > that creates these BIT_FIELD_REFs after vectorization?
>
> I think the BIT_FIELD_REF should be properly folded to a constant or
> the propagation
> not done. fold_stmt_inplace is the candidate to look at,
> propagate_rhs_into_lhs in
> tree-ssa-dom.c to reject propagation into BIT_FIELD_REF.
> fold_ternary should be
> able to fold the BIT_FIELD_REF in question, it would be interesting to
> know why it
> doesn't.
>
the problem is that for the case of BIT_FIELD_REF fold_ternary folds only
if operand 0 is VECTOR_CST. In our case it's a CONSTRUCTOR. I'm testing the
patch below (comments?).
Thanks a bunch!
dorit
(See attached file: fix.txt)
> Richard.
Index: fold-const.c
===================================================================
--- fold-const.c (revision 123159)
+++ fold-const.c (working copy)
@@ -12470,7 +12470,8 @@
gcc_unreachable ();
case BIT_FIELD_REF:
- if (TREE_CODE (arg0) == VECTOR_CST
+ if ((TREE_CODE (arg0) == VECTOR_CST
+ || (TREE_CODE (arg0) == CONSTRUCTOR && TREE_CONSTANT (arg0)))
&& type == TREE_TYPE (TREE_TYPE (arg0))
&& host_integerp (arg1, 1)
&& host_integerp (op2, 1))
@@ -12484,7 +12485,18 @@
&& (idx = idx / width)
< TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0)))
{
- tree elements = TREE_VECTOR_CST_ELTS (arg0);
+ tree elements = NULL_TREE;
+
+ if (TREE_CODE (arg0) == VECTOR_CST)
+ elements = TREE_VECTOR_CST_ELTS (arg0);
+ else
+ {
+ unsigned HOST_WIDE_INT idx;
+ tree value;
+
+ FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (arg0), idx,
value)
+ elements = tree_cons (NULL_TREE, value, elements);
+ }
while (idx-- > 0 && elements)
elements = TREE_CHAIN (elements);
if (elements)