https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105940
Bug ID: 105940 Summary: suggested_unroll_factor applying place looks wrong Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: linkw at gcc dot gnu.org Target Milestone: --- I tried to evaluate if we can get some performance gains by setting suggested_unroll_factor on Power, but met one ICE coming from the line: cached_vf_per_mode[last_mode_i] = exact_div (LOOP_VINFO_VECT_FACTOR (loop_vinfo), loop_vinfo->suggested_unroll_factor); With below simple hacking in rs6000 backend: diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index d7a7cfe860f..dcf2e8fc0ba 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -5490,6 +5490,8 @@ rs6000_cost_data::finish_cost (const vector_costs *scalar_costs) && LOOP_VINFO_VECT_FACTOR (loop_vinfo) == 2 && LOOP_REQUIRES_VERSIONING (loop_vinfo)) m_costs[vect_body] += 10000; + + m_suggested_unroll_factor = 4; } vector_costs::finish_cost (scalar_costs); We can get the ICE reproduced on the below reduced test case: _Complex *a; _Complex b, e; int c, d; void f() { _Complex g; for (; d; d++) g += a[d * c] * e; b = g; } option: -Ofast -mcpu=power10