------- Comment #4 from jakub at gcc dot gnu dot org 2007-11-20 10:59 ------- The testcase is wrong, static unsigned char sbox[] = {}; means zero sized array. But using sbox[256] makes the testcase valid and the problem is still there. This looks like a bug in can_convert_to_perfect_nest, this loop (at least unless earlier passes don't realize that sbox[i] == 0 for any i) can't be converted into a perfect nest. The basic block which is after the inner loop is:
<bb 5>: # t_30 = PHI <t_16(4)> D.1558_19 = (unsigned char) i_39; t_20 = t_30 + D.1558_19; i_21 = i_39 + 1; if (i_21 <= 15) goto <bb 6>; else goto <bb 8>; <bb 6>: <bb 7>: # i_39 = PHI <0(2), i_21(6)> # SMT.4_10 = PHI <SMT.4_26(D)(2), SMT.4_28(6)> # t_29 = PHI <0(2), t_20(6)> goto <bb 4>; can_convert_to_perfect_nest walks the statements of these bbs and is satisfied with all of them, the first two stmts in bb5 are satisfied by: 2234 tree step = evolution_part_in_loop_num (scev, loop->num); 2235 if (step && step != chrec_dont_know 2236 && TREE_CODE (step) == INTEGER_CST) 2237 continue; - step is for both integer_one_node, the third stmt is of course correctly a stmt_is_bumper_for_loop and the last one is exit_condition. But nothing scans the PHIs which are relevant here. # t_30 = PHI <t_16(4)> in bb5 sets t_30 to t_16, which is computed by inner loop. And # t_29 = PHI <0(2), t_20(6)> in bb7 sets t_29 used in the inner loop to t_20 set in bb5 (i.e. in the bb which prevents perfect nest). Should the PHIs be walked similarly to how stmts are walked? -- jakub at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dberlin at gcc dot gnu dot | |org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34123