This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFC: PATCH to vector handling for middle-end/28915
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 10 Oct 2006 14:30:58 -0400
- Subject: RFC: PATCH to vector handling for middle-end/28915
Pinski fixed a lot of the problem with the vectorizer result, but we
still had the problem with gimplifying a TREE_CONSTANT vector ctor into
one that isn't properly TREE_CONSTANT.
I think the proper solution is just not to touch a TREE_CONSTANT vector
ctor. If we leave it alone, we eventually end up with a constant vector
just like the one produced by the vectorizer. If we gimplify the
elements, even if we fix the crash we can no longer treat it as a
constant and have to build up the vector within the function. I believe
that this doesn't cost us much, since we deal with vectors as a whole,
but I'm interested in feedback from people with more experience of the
vector code. Thoughts before I check this in?
2006-10-10 Jason Merrill <jason@redhat.com>
Andrew Pinski <pinskia@physics.uc.edu>
PR middle-end/28915
* gimplify.c (gimplify_init_constructor): Don't reduce TREE_CONSTANT
vector ctors.
* tree-cfg.c (verify_expr): Don't look into TREE_CONSTANT
vector ctors.
* expmed.c (make_tree): Handle CONST, SYMBOL_REF. Correct element
type in CONST_VECTOR case.
* tree.c (build_vector): Handle non-_CST elements.
Index: tree.c
===================================================================
*** tree.c (revision 117464)
--- tree.c (working copy)
*************** build_vector (tree type, tree vals)
*** 970,975 ****
--- 970,979 ----
{
tree value = TREE_VALUE (link);
+ /* Don't crash if we get an address constant. */
+ if (!CONSTANT_CLASS_P (value))
+ continue;
+
over1 |= TREE_OVERFLOW (value);
over2 |= TREE_CONSTANT_OVERFLOW (value);
}
Index: gimplify.c
===================================================================
*** gimplify.c (revision 117464)
--- gimplify.c (working copy)
*************** gimplify_init_constructor (tree *expr_p,
*** 3162,3167 ****
--- 3162,3172 ----
TREE_OPERAND (*expr_p, 1) = build_vector_from_ctor (type, elts);
break;
}
+
+ /* Don't reduce a TREE_CONSTANT vector ctor even if we can't
+ make a VECTOR_CST. It won't do anything for us, and it'll
+ prevent us from representing it as a single constant. */
+ break;
}
/* Vector types use CONSTRUCTOR all the way through gimple
Index: expmed.c
===================================================================
*** expmed.c (revision 117464)
--- expmed.c (working copy)
*************** make_tree (tree type, rtx x)
*** 4979,4984 ****
--- 4979,4985 ----
int i, units;
rtx elt;
tree t = NULL_TREE;
+ tree elttype = TREE_TYPE (type);
units = CONST_VECTOR_NUNITS (x);
*************** make_tree (tree type, rtx x)
*** 4986,4992 ****
for (i = units - 1; i >= 0; --i)
{
elt = CONST_VECTOR_ELT (x, i);
! t = tree_cons (NULL_TREE, make_tree (type, elt), t);
}
return build_vector (type, t);
--- 4987,4994 ----
for (i = units - 1; i >= 0; --i)
{
elt = CONST_VECTOR_ELT (x, i);
! t = tree_cons (NULL_TREE, make_tree (elttype, elt), t);
! gcc_assert (TREE_CONSTANT (TREE_VALUE (t)));
}
return build_vector (type, t);
*************** make_tree (tree type, rtx x)
*** 5044,5049 ****
--- 5046,5060 ----
GET_CODE (x) == ZERO_EXTEND);
return fold_convert (type, make_tree (t, XEXP (x, 0)));
+ case CONST:
+ return make_tree (type, XEXP (x, 0));
+
+ case SYMBOL_REF:
+ t = SYMBOL_REF_DECL (x);
+ if (t)
+ return fold_convert (type, build_fold_addr_expr (t));
+ /* else fall through. */
+
default:
t = build_decl (VAR_DECL, NULL_TREE, type);
Index: tree-cfg.c
===================================================================
*** tree-cfg.c (revision 117464)
--- tree-cfg.c (working copy)
*************** verify_expr (tree *tp, int *walk_subtree
*** 3422,3427 ****
--- 3422,3432 ----
CHECK_OP (1, "invalid operand to binary operator");
break;
+ case CONSTRUCTOR:
+ if (TREE_CONSTANT (t) && TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
+ *walk_subtrees = 0;
+ break;
+
default:
break;
}