+2018-01-13 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
+ * tree-vect-loop.c (vect_estimate_min_profitable_iters): Make sure
+ min_profitable_iters doesn't go negative.
+
2018-01-13 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
if ((scalar_single_iter_cost * assumed_vf) > (int) vec_inside_cost)
{
- if (vec_outside_cost <= 0)
+ min_profitable_iters = ((vec_outside_cost - scalar_outside_cost)
+ * assumed_vf
+ - vec_inside_cost * peel_iters_prologue
+ - vec_inside_cost * peel_iters_epilogue);
+
+ if (min_profitable_iters <= 0)
min_profitable_iters = 0;
else
- {
- min_profitable_iters = ((vec_outside_cost - scalar_outside_cost)
- * assumed_vf
- - vec_inside_cost * peel_iters_prologue
- - vec_inside_cost * peel_iters_epilogue)
- / ((scalar_single_iter_cost * assumed_vf)
- - vec_inside_cost);
+ {
+ min_profitable_iters /= ((scalar_single_iter_cost * assumed_vf)
+ - vec_inside_cost);
if ((scalar_single_iter_cost * assumed_vf * min_profitable_iters)
<= (((int) vec_inside_cost * min_profitable_iters)
+ (((int) vec_outside_cost - scalar_outside_cost)
* assumed_vf)))
min_profitable_iters++;
- }
+ }
}
/* vector version will never be profitable. */
else