aboutsummaryrefslogtreecommitdiff
path: root/gcc/hsa-regalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/hsa-regalloc.c')
-rw-r--r--gcc/hsa-regalloc.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/hsa-regalloc.c b/gcc/hsa-regalloc.c
index 2a17254..7fc3a8a 100644
--- a/gcc/hsa-regalloc.c
+++ b/gcc/hsa-regalloc.c
@@ -42,7 +42,7 @@ along with GCC; see the file COPYING3. If not see
/* Process a PHI node PHI of basic block BB as a part of naive out-f-ssa. */
static void
-naive_process_phi (hsa_insn_phi *phi)
+naive_process_phi (hsa_insn_phi *phi, const vec<edge> &predecessors)
{
unsigned count = phi->operand_count ();
for (unsigned i = 0; i < count; i++)
@@ -55,7 +55,7 @@ naive_process_phi (hsa_insn_phi *phi)
if (!op)
break;
- e = EDGE_PRED (phi->m_bb, i);
+ e = predecessors[i];
if (single_succ_p (e->src))
hbb = hsa_bb_for_bb (e->src);
else
@@ -89,10 +89,18 @@ naive_outof_ssa (void)
hsa_bb *hbb = hsa_bb_for_bb (bb);
hsa_insn_phi *phi;
+ /* naive_process_phi can call split_edge on an incoming edge which order if
+ the incoming edges to the basic block and thus make it inconsistent with
+ the ordering of PHI arguments, so we collect them in advance. */
+ auto_vec<edge, 8> predecessors;
+ unsigned pred_count = EDGE_COUNT (bb->preds);
+ for (unsigned i = 0; i < pred_count; i++)
+ predecessors.safe_push (EDGE_PRED (bb, i));
+
for (phi = hbb->m_first_phi;
phi;
phi = phi->m_next ? as_a <hsa_insn_phi *> (phi->m_next) : NULL)
- naive_process_phi (phi);
+ naive_process_phi (phi, predecessors);
/* Zap PHI nodes, they will be deallocated when everything else will. */
hbb->m_first_phi = NULL;