Hi, My function is working properly for the below case -
for (i = 1; i < N ; i++) { a[i] = 1; } for (i = 1; i < N ; i++) { j = a[i]; } But I am required to add additional phi node for j in the following case - for (i = 1; i < N ; i++) { a[i] = 1; } for (i = 1; i < N ; i++) { j = j + a[i]; } I am trying to understand how it is done in create_iv. I have tried using merge_blocks() of cfghooks.c to fuse the loop headers. Using code /* The following function fuses two loops. */ void fuse_loops (struct loop *loop_a, struct loop *loop_b) { basic_block *bbs_a, *bbs_b; struct loop *new_loop; bbs_a = get_loop_body (loop_a); bbs_b = get_loop_body (loop_b); debug_loop (loop_a, 10); debug_loop (loop_b, 10); merge_blocks (bbs_b[0], bbs_a[0]); debug_loop (loop_a, 10); debug_loop (loop_b, 10); cancel_loop_tree (loop_a); } But the I get an internal compiler error - loop.c: In function 'main': loop.c:8: internal compiler error: in single_succ_edge, at basic-block.h:638 The function merge_blocks() merges blocks only with single successors and predecessors. But the blocks in loops have 2 each. Can you please suggest what is the right thing to do here? Thanks, Sandeep.