http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46928
Summary: data dependence analysis fails on constant array accesses Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: s...@gcc.gnu.org In this code we should be able to convert the inner loop to memset zero with ./cc1 -O3 bug.c typedef int mad_fixed_t; struct mad_pcm { unsigned int samplerate; unsigned short channels; unsigned short length; mad_fixed_t samples[2][1152]; }; struct mad_synth { mad_fixed_t filter[2][2][2][16][8]; unsigned int phase; struct mad_pcm pcm; }; void mad_synth_mute (struct mad_synth *synth); void mad_synth_mute (struct mad_synth *synth) { unsigned int ch; unsigned int s; unsigned int v; ch = 0U; while (ch < 2U) { s = 0U; while (s < 16U) { v = 0U; while (v < 8U) { synth->filter[ch][1][1][s][v] = 0; synth->filter[ch][1][0][s][v] = 0; synth->filter[ch][0][1][s][v] = 0; synth->filter[ch][0][0][s][v] = 0; v++; } s++; } ch++; } return; } When looking at the output of the dump ./cc1 -O3 -fdump-tree-ldist-details bug.c the data dependence analysis fails to analyze the overlapping iterations for s_29: (compute_affine_dependence (stmt_a = synth_7(D)->filter[ch_28][0][1][s_29][v_30] = 0; ) (stmt_b = synth_7(D)->filter[ch_28][0][0][s_29][v_30] = 0; ) (subscript_dependence_tester (analyze_overlapping_iterations (chrec_a = {0, +, 1}_3) (chrec_b = {0, +, 1}_3) (overlap_iterations_a = [0] ) (overlap_iterations_b = [0] ) ) (analyze_overlapping_iterations (chrec_a = s_29) (chrec_b = s_29) (overlap_iterations_a = not known ) (overlap_iterations_b = not known ) ) (dependence classified: scev_not_known) ) ) When we remove the s loop, we transform the following code with memset zero: ch = 0U; while (ch < 2U) { v = 0U; while (v < 8U) { synth->filter[ch][1][1][0][v] = 0; synth->filter[ch][1][0][0][v] = 0; synth->filter[ch][0][1][0][v] = 0; synth->filter[ch][0][0][0][v] = 0; v++; } ch++; }