From patchwork Sat Jun 19 02:00:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix decompress of min_issue_delay Date: Fri, 18 Jun 2010 16:00:11 -0000 From: Jie Zhang X-Patchwork-Id: 56235 Message-Id: <4C1C24AB.9010401@codesourcery.com> To: gcc-patches@gcc.gnu.org When debugging a scheduling problem of GCC, I found min_issue_delay was not decompressed correctly, which caused weird things, like modifying a reservation changes scheduling of a sequence of instructions but none of those instructions uses that reservation. In output_min_issue_delay_table, the table is compressed with for (i = 0; i < min_issue_delay_len; i++) { size_t ci = i / cfactor; vect_el_t x = VEC_index (vect_el_t, min_issue_delay_vect, i); vect_el_t cx = VEC_index (vect_el_t, compressed_min_issue_delay_vect, ci); A==> cx |= x << (8 - (i % cfactor + 1) * (8 / cfactor)); VEC_replace (vect_el_t, compressed_min_issue_delay_vect, ci, cx); } But, take Cortex-A8 as an example, the table is decompressed in generated internal_min_issue_delay as temp = cortex_a8_min_issue_delay [(cortex_a8_translate [insn_code] + chip->cortex_a8_automaton_state * 9) / 4]; B==> temp = (temp >> (8 - (cortex_a8_translate [insn_code] % 4 + 1) * 2)) & 3; res = temp; Note it's possible that line B does not decompress out the same value which line A put into the table. The 'i' in line A is same as "(cortex_a8_translate [insn_code] + chip->cortex_a8_automaton_state * 9)". But line B uses "cortex_a8_translate [insn_code]". This patch should fix it. Bootstrapped and regression tested on x86-64. Is it OK? --- Jie Zhang CodeSourcery * genautomata.c (output_automata_list_min_issue_delay_code): Correctly decompress min_issue_delay. Index: genautomata.c =================================================================== --- genautomata.c (revision 160987) +++ genautomata.c (working copy) @@ -7854,12 +7854,15 @@ output_automata_list_min_issue_delay_cod { fprintf (output_file, ") / %d];\n", automaton->min_issue_delay_table_compression_factor); - fprintf (output_file, " %s = (%s >> (8 - (", + fprintf (output_file, " %s = (%s >> (8 - ((", TEMPORARY_VARIABLE_NAME, TEMPORARY_VARIABLE_NAME); output_translate_vect_name (output_file, automaton); + fprintf (output_file, " [%s] + ", INTERNAL_INSN_CODE_NAME); + fprintf (output_file, "%s->", CHIP_PARAMETER_NAME); + output_chip_member_name (output_file, automaton); + fprintf (output_file, " * %d)", automaton->insn_equiv_classes_num); fprintf - (output_file, " [%s] %% %d + 1) * %d)) & %d;\n", - INTERNAL_INSN_CODE_NAME, + (output_file, " %% %d + 1) * %d)) & %d;\n", automaton->min_issue_delay_table_compression_factor, 8 / automaton->min_issue_delay_table_compression_factor, (1 << (8 / automaton->min_issue_delay_table_compression_factor))