aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2015-02-06 11:17:46 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2015-02-06 11:17:46 +0000
commit9fb87eb0bb346faced57e1f7ea0f9d7f4b9dd472 (patch)
tree4a6525f3942b6ce4873f4432f6de86d0e1892563
parent9f9ab303f713366fd57c338802735b86dcebf110 (diff)
downloadgcc-9fb87eb0bb346faced57e1f7ea0f9d7f4b9dd472.zip
gcc-9fb87eb0bb346faced57e1f7ea0f9d7f4b9dd472.tar.gz
gcc-9fb87eb0bb346faced57e1f7ea0f9d7f4b9dd472.tar.bz2
re PR target/62631 (gcc.dg/tree-ssa/ivopts-lt-2.c FAILs)
PR target/62631 * tree-ssa-loop-ivopts.c (get_shiftadd_cost): Use the mininum of costs of shift-add and (add + shift) operations. Rename local variable. From-SVN: r220473
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/tree-ssa-loop-ivopts.c18
2 files changed, 17 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4d84df7..7cf5049 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-06 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR target/62631
+ * tree-ssa-loop-ivopts.c (get_shiftadd_cost): Use the mininum of costs
+ of shift-add and (add + shift) operations. Rename local variable.
+
2015-02-05 Jeff Law <law@redhat.com>
PR target/17306
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index bde68e7..a701636 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -3597,22 +3597,26 @@ get_shiftadd_cost (tree expr, machine_mode mode, comp_cost cost0,
tree multop = TREE_OPERAND (mult, 0);
int m = exact_log2 (int_cst_value (cst));
int maxm = MIN (BITS_PER_WORD, GET_MODE_BITSIZE (mode));
- int sa_cost;
- bool equal_p = false;
+ int as_cost, sa_cost;
+ bool mult_in_op1;
if (!(m >= 0 && m < maxm))
return false;
- if (operand_equal_p (op1, mult, 0))
- equal_p = true;
+ mult_in_op1 = operand_equal_p (op1, mult, 0);
+ as_cost = add_cost (speed, mode) + shift_cost (speed, mode, m);
+
+ /* If the target has a cheap shift-and-add or shift-and-sub instruction,
+ use that in preference to a shift insn followed by an add insn. */
sa_cost = (TREE_CODE (expr) != MINUS_EXPR
? shiftadd_cost (speed, mode, m)
- : (equal_p
+ : (mult_in_op1
? shiftsub1_cost (speed, mode, m)
: shiftsub0_cost (speed, mode, m)));
- res = new_cost (sa_cost, 0);
- res = add_costs (res, equal_p ? cost0 : cost1);
+
+ res = new_cost (MIN (as_cost, sa_cost), 0);
+ res = add_costs (res, mult_in_op1 ? cost0 : cost1);
STRIP_NOPS (multop);
if (!is_gimple_val (multop))