tree-optimization/127686 - mis-applied -O2 vector cost model heuristic
Checks
Commit Message
With -O2 and it's default very-cheap vectorizer cost model we apply
the heuristic that even when the vector loop is only executed once
vectorization should be profitable. But that is applied even when
the number of iterations is constant where we already assess
profitability over the whole run. So do not apply the former heuristic
in this case.
Bootstrapped and tested no x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/127686
* tree-vect-loop.cc (vect_analyze_loop_costing): Do not
require a single vector iteration to be profitable iff
the number of scalar iterations is constant.
---
gcc/tree-vect-loop.cc | 1 +
1 file changed, 1 insertion(+)
@@ -1926,6 +1926,7 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo,
things are probably too close to call, and the conservative thing
would be to stick with the scalar code. */
if (loop_cost_model (loop) == VECT_COST_MODEL_VERY_CHEAP
+ && !LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
&& min_profitable_estimate > (int) vect_vf_for_cost (loop_vinfo))
{
if (dump_enabled_p ())