Hi,
When calling get_shiftadd_cost, the mult_op is stripped at caller places.
We should look into unnecessary conversion in op1 before checking equality,
otherwise it computes wrong shiftadd cost.  This patch picks this small
issue up.

Bootstrap and test on x86_64 and aarch64 along with other patches.  Is it
OK?

Thanks,
bin

2015-08-31  Bin Cheng  <bin.ch...@arm.com>

        * tree-ssa-loop-ivopts.c (get_shiftadd_cost): Look into
        unnecessary type conversion for OP1.
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c  (revision 227163)
+++ gcc/tree-ssa-loop-ivopts.c  (working copy)
@@ -3884,12 +4038,14 @@ get_shiftadd_cost (tree expr, machine_mode mode, c
   int m = exact_log2 (int_cst_value (cst));
   int maxm = MIN (BITS_PER_WORD, GET_MODE_BITSIZE (mode));
   int as_cost, sa_cost;
-  bool mult_in_op1;
+  bool mult_in_op1 = false;
 
   if (!(m >= 0 && m < maxm))
     return false;
 
-  mult_in_op1 = operand_equal_p (op1, mult, 0);
+  if (operand_equal_p (op1, mult, 0)
+      || operand_equal_p (STRIP_NOPS (op1), mult, 0))
+    mult_in_op1 = true;
 
   as_cost = add_cost (speed, mode) + shift_cost (speed, mode, m);
 

Reply via email to