OSDN Git Service

2006-07-07 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Jul 2006 16:30:36 +0000 (16:30 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Jul 2006 16:30:36 +0000 (16:30 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@115263 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr28268.c [new file with mode: 0644]
gcc/tree-ssa-math-opts.c
gcc/tree.c
gcc/tree.h

index 5a69352..df98b7b 100644 (file)
@@ -1,3 +1,12 @@
+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.
+
 2006-07-07  Roger Sayle  <roger@eyesopen.com>
 
        * pointer-set.c (pointer_set_destroy): Correct whitespace.
index 008310c..277bd32 100644 (file)
@@ -6727,7 +6727,7 @@ fold_plusminus_mult_expr (enum tree_code code, tree type, tree arg0, tree arg1)
   else
     {
       arg00 = arg0;
-      arg01 = fold_convert (type, integer_one_node);
+      arg01 = build_one_cst (type);
     }
   if (TREE_CODE (arg1) == MULT_EXPR)
     {
@@ -6737,7 +6737,7 @@ fold_plusminus_mult_expr (enum tree_code code, tree type, tree arg0, tree arg1)
   else
     {
       arg10 = arg1;
-      arg11 = fold_convert (type, integer_one_node);
+      arg11 = build_one_cst (type);
     }
   same = NULL_TREE;
 
index 63aa90d..6ce58b2 100644 (file)
@@ -1,3 +1,8 @@
+2006-07-07   Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/28268
+       * gcc.dg/torture/pr28268.c: New testcase.
+
 2006-07-07  Steve Ellcey  <sje@cup.hp.com>
 
        PR c++/27019
diff --git a/gcc/testsuite/gcc.dg/torture/pr28268.c b/gcc/testsuite/gcc.dg/torture/pr28268.c
new file mode 100644 (file)
index 0000000..f143c08
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+int __attribute__((vector_size(8))) a;
+
+void foo()
+{
+    a += a*a;
+}
index 950b9aa..1ff0628 100644 (file)
@@ -279,35 +279,6 @@ is_division_by (tree use_stmt, tree def)
         && TREE_OPERAND (TREE_OPERAND (use_stmt, 1), 1) == def;
 }
 
-/* Return the LHS of a RDIV_EXPR that computes a reciprocal in type TYPE.  */
-static tree
-get_constant_one (tree type)
-{
-  tree scalar, cst;
-  int i;
-
-  gcc_assert (FLOAT_TYPE_P (type));
-  switch (TREE_CODE (type))
-    {
-    case REAL_TYPE:
-      return build_real (type, dconst1);
-
-    case VECTOR_TYPE:
-      scalar = build_real (TREE_TYPE (type), dconst1);
-
-      /* 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);
-
-    default:
-      /* Complex operations have been split already.  */
-      gcc_unreachable ();
-    }
-}
-
 /* Walk the subset of the dominator tree rooted at OCC, setting the
    RECIP_DEF field to a definition of 1.0 / DEF that can be used in
    the given basic block.  The field may be left NULL, of course,
@@ -333,7 +304,7 @@ insert_reciprocals (block_stmt_iterator *def_bsi, struct occurrence *occ,
       type = TREE_TYPE (def);
       recip_def = make_rename_temp (type, "reciptmp");
       new_stmt = build2 (MODIFY_EXPR, void_type_node, recip_def,
-                        fold_build2 (RDIV_EXPR, type, get_constant_one (type),
+                        fold_build2 (RDIV_EXPR, type, build_one_cst (type),
                                      def));
   
   
index f3889e2..1c2a33d 100644 (file)
@@ -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
index a6a8f43..49b5be2 100644 (file)
@@ -3534,6 +3534,7 @@ extern tree build_constructor_single (tree, tree, tree);
 extern tree build_constructor_from_list (tree, tree);
 extern tree build_real_from_int_cst (tree, tree);
 extern tree build_complex (tree, tree, tree);
+extern tree build_one_cst (tree);
 extern tree build_string (int, const char *);
 extern tree build_tree_list_stat (tree, tree MEM_STAT_DECL);
 #define build_tree_list(t,q) build_tree_list_stat(t,q MEM_STAT_INFO)