case 1:
break;
case 2:
- if (vp1->block->loop_father->header == vp1->block)
- ;
- else
+ /* When this is a PHI node subject to CSE for different blocks
+ avoid hashing the block index. */
+ if (vp1->cclhs)
break;
/* Fallthru. */
default:
case 2:
{
- /* Rule out backedges into the PHI. */
- if (vp1->block->loop_father->header == vp1->block
- || vp2->block->loop_father->header == vp2->block)
+ /* Make sure both PHIs are classified as CSEable. */
+ if (! vp1->cclhs || ! vp2->cclhs)
return false;
+ /* Rule out backedges into the PHI. */
+ gcc_checking_assert
+ (vp1->block->loop_father->header != vp1->block
+ && vp2->block->loop_father->header != vp2->block);
+
/* If the PHI nodes do not have compatible types
they are not the same. */
if (!types_compatible_p (vp1->type, vp2->type))
return false;
+ /* If the immediate dominator end in switch stmts multiple
+ values may end up in the same PHI arg via intermediate
+ CFG merges. */
basic_block idom1
= get_immediate_dominator (CDI_DOMINATORS, vp1->block);
basic_block idom2
= get_immediate_dominator (CDI_DOMINATORS, vp2->block);
- /* If the immediate dominator end in switch stmts multiple
- values may end up in the same PHI arg via intermediate
- CFG merges. */
- if (EDGE_COUNT (idom1->succs) != 2
- || EDGE_COUNT (idom2->succs) != 2)
- return false;
+ gcc_checking_assert (EDGE_COUNT (idom1->succs) == 2
+ && EDGE_COUNT (idom2->succs) == 2);
/* Verify the controlling stmt is the same. */
- gcond *last1 = safe_dyn_cast <gcond *> (last_stmt (idom1));
- gcond *last2 = safe_dyn_cast <gcond *> (last_stmt (idom2));
- if (! last1 || ! last2)
- return false;
+ gcond *last1 = as_a <gcond *> (last_stmt (idom1));
+ gcond *last2 = as_a <gcond *> (last_stmt (idom2));
bool inverted_p;
if (! cond_stmts_equal_p (last1, vp1->cclhs, vp1->ccrhs,
last2, vp2->cclhs, vp2->ccrhs,
/* Extract values of the controlling condition. */
vp1->cclhs = NULL_TREE;
vp1->ccrhs = NULL_TREE;
- basic_block idom1 = get_immediate_dominator (CDI_DOMINATORS, vp1->block);
- if (EDGE_COUNT (idom1->succs) == 2)
- if (gcond *last1 = safe_dyn_cast <gcond *> (last_stmt (idom1)))
- {
- /* ??? We want to use SSA_VAL here. But possibly not
- allow VN_TOP. */
- vp1->cclhs = vn_valueize (gimple_cond_lhs (last1));
- vp1->ccrhs = vn_valueize (gimple_cond_rhs (last1));
- }
+ if (EDGE_COUNT (vp1->block->preds) == 2
+ && vp1->block->loop_father->header != vp1->block)
+ {
+ basic_block idom1 = get_immediate_dominator (CDI_DOMINATORS, vp1->block);
+ if (EDGE_COUNT (idom1->succs) == 2)
+ if (gcond *last1 = safe_dyn_cast <gcond *> (last_stmt (idom1)))
+ {
+ /* ??? We want to use SSA_VAL here. But possibly not
+ allow VN_TOP. */
+ vp1->cclhs = vn_valueize (gimple_cond_lhs (last1));
+ vp1->ccrhs = vn_valueize (gimple_cond_rhs (last1));
+ }
+ }
vp1->hashcode = vn_phi_compute_hash (vp1);
slot = valid_info->phis->find_slot_with_hash (vp1, vp1->hashcode, NO_INSERT);
if (!slot)
/* Extract values of the controlling condition. */
vp1->cclhs = NULL_TREE;
vp1->ccrhs = NULL_TREE;
- basic_block idom1 = get_immediate_dominator (CDI_DOMINATORS, vp1->block);
- if (EDGE_COUNT (idom1->succs) == 2)
- if (gcond *last1 = safe_dyn_cast <gcond *> (last_stmt (idom1)))
- {
- /* ??? We want to use SSA_VAL here. But possibly not
- allow VN_TOP. */
- vp1->cclhs = vn_valueize (gimple_cond_lhs (last1));
- vp1->ccrhs = vn_valueize (gimple_cond_rhs (last1));
- }
+ if (EDGE_COUNT (vp1->block->preds) == 2
+ && vp1->block->loop_father->header != vp1->block)
+ {
+ basic_block idom1 = get_immediate_dominator (CDI_DOMINATORS, vp1->block);
+ if (EDGE_COUNT (idom1->succs) == 2)
+ if (gcond *last1 = safe_dyn_cast <gcond *> (last_stmt (idom1)))
+ {
+ /* ??? We want to use SSA_VAL here. But possibly not
+ allow VN_TOP. */
+ vp1->cclhs = vn_valueize (gimple_cond_lhs (last1));
+ vp1->ccrhs = vn_valueize (gimple_cond_rhs (last1));
+ }
+ }
vp1->result = result;
vp1->hashcode = vn_phi_compute_hash (vp1);