tree-ssa-pre.c (phi_translate_1): Avoid re-allocating the operands vector in most...
authorRichard Biener <rguenther@suse.de>
Mon, 1 Sep 2014 13:37:53 +0000 (13:37 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 1 Sep 2014 13:37:53 +0000 (13:37 +0000)
2014-09-01  Richard Biener  <rguenther@suse.de>

* tree-ssa-pre.c (phi_translate_1): Avoid re-allocating the
operands vector in most cases.  Remove redundant code.

From-SVN: r214794

gcc/ChangeLog
gcc/tree-ssa-pre.c

index 390c89eae73b726a90f8460cfc58a7087ac2e0de..5516577f7096130be6aafbe88007846ff5d431b6 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-01  Richard Biener  <rguenther@suse.de>
+
+       * tree-ssa-pre.c (phi_translate_1): Avoid re-allocating the
+       operands vector in most cases.  Remove redundant code.
+
 2014-09-01  Olivier Hainque  <hainque@adacore.com>
 
        * config/vxworksae.h (VXWORKSAE_TARGET_DIR): Rely on
index 7acf25f41194ceee589f39ab95465997455441ef..399777c2d15064ab8be9c4e52d871ddfdccad3ac 100644 (file)
@@ -1536,12 +1536,11 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
        tree newvuse = vuse;
        vec<vn_reference_op_s> newoperands = vNULL;
        bool changed = false, same_valid = true;
-       unsigned int i, j, n;
+       unsigned int i, n;
        vn_reference_op_t operand;
        vn_reference_t newref;
 
-       for (i = 0, j = 0;
-            operands.iterate (i, &operand); i++, j++)
+       for (i = 0; operands.iterate (i, &operand); i++)
          {
            pre_expr opresult;
            pre_expr leader;
@@ -1585,6 +1584,8 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
                newoperands.release ();
                return NULL;
              }
+           if (!changed)
+             continue;
            if (!newoperands.exists ())
              newoperands = operands.copy ();
            /* We may have changed from an SSA_NAME to a constant */
@@ -1594,36 +1595,14 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
            newop.op0 = op[0];
            newop.op1 = op[1];
            newop.op2 = op[2];
-           /* If it transforms a non-constant ARRAY_REF into a constant
-              one, adjust the constant offset.  */
-           if (newop.opcode == ARRAY_REF
-               && newop.off == -1
-               && TREE_CODE (op[0]) == INTEGER_CST
-               && TREE_CODE (op[1]) == INTEGER_CST
-               && TREE_CODE (op[2]) == INTEGER_CST)
-             {
-               offset_int off = ((wi::to_offset (op[0])
-                                  - wi::to_offset (op[1]))
-                                 * wi::to_offset (op[2]));
-               if (wi::fits_shwi_p (off))
-                 newop.off = off.to_shwi ();
-             }
-           newoperands[j] = newop;
-           /* If it transforms from an SSA_NAME to an address, fold with
-              a preceding indirect reference.  */
-           if (j > 0 && op[0] && TREE_CODE (op[0]) == ADDR_EXPR
-               && newoperands[j - 1].opcode == MEM_REF)
-             vn_reference_fold_indirect (&newoperands, &j);
-         }
-       if (i != operands.length ())
-         {
-           newoperands.release ();
-           return NULL;
+           newoperands[i] = newop;
          }
+       gcc_checking_assert (i == operands.length ());
 
        if (vuse)
          {
-           newvuse = translate_vuse_through_block (newoperands,
+           newvuse = translate_vuse_through_block (newoperands.exists ()
+                                                   ? newoperands : operands,
                                                    ref->set, ref->type,
                                                    vuse, phiblock, pred,
                                                    &same_valid);
@@ -1641,7 +1620,8 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
 
            tree result = vn_reference_lookup_pieces (newvuse, ref->set,
                                                      ref->type,
-                                                     newoperands,
+                                                     newoperands.exists ()
+                                                     ? newoperands : operands,
                                                      &newref, VN_WALK);
            if (result)
              newoperands.release ();
@@ -1700,11 +1680,13 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
                  }
                else
                  new_val_id = ref->value_id;
+               if (!newoperands.exists ())
+                 newoperands = operands.copy ();
                newref = vn_reference_insert_pieces (newvuse, ref->set,
                                                     ref->type,
                                                     newoperands,
                                                     result, new_val_id);
-               newoperands.create (0);
+               newoperands = vNULL;
                PRE_EXPR_REFERENCE (expr) = newref;
                constant = fully_constant_expression (expr);
                if (constant != expr)