ia32: fix overly conservative upper_bits_clean (by avoiding undefined behaviour)
[libfirm] / ir / opt / cfopt.c
index 33afb24..ee492eb 100644 (file)
@@ -675,7 +675,7 @@ static void compute_block_info(ir_node *n, void *x)
        } else if (is_Phi(n)) {
                ir_node *block = get_nodes_block(n);
                set_has_phis(block_info, block);
-       } else if (is_Jmp(n) || is_Cond(n) || is_Cmp(n) || is_Proj(n)) {
+       } else if (is_Jmp(n) || is_Cond(n) || is_Proj(n)) {
                /* ignore */
        } else {
                ir_node *block = get_nodes_block(n);
@@ -742,6 +742,19 @@ static void remove_empty_blocks(ir_node *block, void *x)
                        continue; /* this block contains operations and cannot be skipped */
                if (has_phis(env->phase,jmp_block))
                        continue; /* this block contains Phis and is not skipped */
+               if (Block_block_visited(jmp_block)) {
+                       continue;
+                       /* otherwise we could break the walker,
+                        * if block was reached via KeepAlive edge -> jmp_block -> A ---> block,
+                        * because the walker cannot handle Id nodes.
+                        *
+                        *   A      B
+                        *    \    /
+                        *   jmp_block
+                        *    /    \
+                        * block    End
+                        */
+               }
 
                /* jmp_block is an empty block and can be optimized! */