aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2006-07-07 16:30:36 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2006-07-07 16:30:36 +0000
commitbfabddb6c0307307e963bf1388fcad0b8a00ba5c (patch)
tree6a1baa8ebb8584cddfcf0a2c3567372718ab3933 /gcc/tree.c
parentc6d0959c4b87ca27e45d827baf9b53071513a00b (diff)
downloadgcc-bfabddb6c0307307e963bf1388fcad0b8a00ba5c.zip
gcc-bfabddb6c0307307e963bf1388fcad0b8a00ba5c.tar.gz
gcc-bfabddb6c0307307e963bf1388fcad0b8a00ba5c.tar.bz2
re PR middle-end/28268 (ICE with simple vector operations)
2006-07-07 Richard Guenther <rguenther@suse.de> PR middle-end/28268 * tree.h (build_one_cst): Declare. * tree.c (build_one_cst): New function. * tree-ssa-math-opts.c (get_constant_one): Remove. (insert_reciprocals): Use build_one_cst. * fold-const.c (fold_plusminus_mult): Likewise. * gcc.dg/torture/pr28268.c: New testcase. From-SVN: r115263
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index f3889e2..1c2a33d 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1161,6 +1161,47 @@ build_complex (tree type, tree real, tree imag)
return t;
}
+/* Return a constant of arithmetic type TYPE which is the
+ multiplcative identity of the set TYPE. */
+
+tree
+build_one_cst (tree type)
+{
+ switch (TREE_CODE (type))
+ {
+ case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
+ case POINTER_TYPE: case REFERENCE_TYPE:
+ case OFFSET_TYPE:
+ return build_int_cst (type, 1);
+
+ case REAL_TYPE:
+ return build_real (type, dconst1);
+
+ case VECTOR_TYPE:
+ {
+ tree scalar, cst;
+ int i;
+
+ scalar = build_one_cst (TREE_TYPE (type));
+
+ /* Create 'vect_cst_ = {cst,cst,...,cst}' */
+ cst = NULL_TREE;
+ for (i = TYPE_VECTOR_SUBPARTS (type); --i >= 0; )
+ cst = tree_cons (NULL_TREE, scalar, cst);
+
+ return build_vector (type, cst);
+ }
+
+ case COMPLEX_TYPE:
+ return build_complex (type,
+ build_one_cst (TREE_TYPE (type)),
+ fold_convert (TREE_TYPE (type), integer_zero_node));
+
+ default:
+ gcc_unreachable ();
+ }
+}
+
/* Build a BINFO with LEN language slots. */
tree