Hi, When I was investigating density_test heuristics, I noticed that the current rs6000_density_test could be used for single scalar iteration cost calculation, through the call trace: vect_compute_single_scalar_iteration_cost -> rs6000_finish_cost -> rs6000_density_test
It looks unexpected as its desriptive function comments and Bill helped to confirm this needs to be fixed (thanks!). So this patch is to check the passed data, if it's the same as the one in loop_vinfo, it indicates it's working on vector version cost calculation, otherwise just early return. Bootstrapped/regtested on powerpc64le-linux-gnu P9. Nothing remarkable was observed with SPEC2017 Power9 full run. Is it ok for trunk? BR, Kewen ------ gcc/ChangeLog: * config/rs6000/rs6000.c (rs6000_density_test): Early return if calculating single scalar iteration cost.
gcc/config/rs6000/rs6000.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 48b8efd732b..ffdf10098a9 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -5252,6 +5252,10 @@ rs6000_density_test (rs6000_cost_data *data) int vec_cost = data->cost[vect_body], not_vec_cost = 0; int i, density_pct; + /* Only care about cost of vector version, so exclude scalar version here. */ + if (LOOP_VINFO_TARGET_COST_DATA (loop_vinfo) != (void *) data) + return; + for (i = 0; i < nbbs; i++) { basic_block bb = bbs[i]; -- 2.17.1