mirror of git://gcc.gnu.org/git/gcc.git
re PR hsa/70402 (HSA: SBR instruction can be undefined)
Fix PR hsa/70402 PR hsa/70402 * hsa-gen.c (gen_hsa_insns_for_switch_stmt): Guard index value that is really in range handled by SBR instruction. * hsa-brig.c (emit_switch_insn): Do not emit unconditional jump. * hsa-dump.c (dump_hsa_insn_1): Do not dump default BB. * hsa.h (hsa_insn_sbr::m_default_bb): Remove field. From-SVN: r234707
This commit is contained in:
parent
f13355da30
commit
e8661ad6cf
|
|
@ -1,3 +1,13 @@
|
||||||
|
2016-04-04 Martin Liska <mliska@suse.cz>
|
||||||
|
|
||||||
|
PR hsa/70402
|
||||||
|
* hsa-gen.c (gen_hsa_insns_for_switch_stmt): Guard index
|
||||||
|
value that is really in range handled by SBR instruction.
|
||||||
|
* hsa-brig.c (emit_switch_insn): Do not emit unconditional
|
||||||
|
jump.
|
||||||
|
* hsa-dump.c (dump_hsa_insn_1): Do not dump default BB.
|
||||||
|
* hsa.h (hsa_insn_sbr::m_default_bb): Remove field.
|
||||||
|
|
||||||
2016-04-03 Oleg Endo <olegendo@gcc.gnu.org>
|
2016-04-03 Oleg Endo <olegendo@gcc.gnu.org>
|
||||||
|
|
||||||
PR target/70416
|
PR target/70416
|
||||||
|
|
|
||||||
|
|
@ -1577,10 +1577,6 @@ emit_switch_insn (hsa_insn_sbr *sbr)
|
||||||
|
|
||||||
brig_code.add (&repr, sizeof (repr));
|
brig_code.add (&repr, sizeof (repr));
|
||||||
brig_insn_count++;
|
brig_insn_count++;
|
||||||
|
|
||||||
/* Emit jump to default label. */
|
|
||||||
hsa_bb *hbb = hsa_bb_for_bb (sbr->m_default_bb);
|
|
||||||
emit_unconditional_jump (&hbb->m_label_ref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emit a HSA convert instruction and all necessary directives, schedule
|
/* Emit a HSA convert instruction and all necessary directives, schedule
|
||||||
|
|
|
||||||
|
|
@ -920,9 +920,6 @@ dump_hsa_insn_1 (FILE *f, hsa_insn_basic *insn, int *indent)
|
||||||
if (i != sbr->m_jump_table.length () - 1)
|
if (i != sbr->m_jump_table.length () - 1)
|
||||||
fprintf (f, ", ");
|
fprintf (f, ", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (f, "] /* default: BB %i */",
|
|
||||||
hsa_bb_for_bb (sbr->m_default_bb)->m_index);
|
|
||||||
}
|
}
|
||||||
else if (is_a <hsa_insn_arg_block *> (insn))
|
else if (is_a <hsa_insn_arg_block *> (insn))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1515,7 +1515,7 @@ hsa_insn_br::operator new (size_t)
|
||||||
|
|
||||||
hsa_insn_sbr::hsa_insn_sbr (hsa_op_reg *index, unsigned jump_count)
|
hsa_insn_sbr::hsa_insn_sbr (hsa_op_reg *index, unsigned jump_count)
|
||||||
: hsa_insn_basic (1, BRIG_OPCODE_SBR, BRIG_TYPE_B1, index),
|
: hsa_insn_basic (1, BRIG_OPCODE_SBR, BRIG_TYPE_B1, index),
|
||||||
m_width (BRIG_WIDTH_1), m_jump_table (vNULL), m_default_bb (NULL),
|
m_width (BRIG_WIDTH_1), m_jump_table (vNULL),
|
||||||
m_label_code_list (new hsa_op_code_list (jump_count))
|
m_label_code_list (new hsa_op_code_list (jump_count))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -3436,11 +3436,48 @@ get_switch_size (gswitch *s)
|
||||||
static void
|
static void
|
||||||
gen_hsa_insns_for_switch_stmt (gswitch *s, hsa_bb *hbb)
|
gen_hsa_insns_for_switch_stmt (gswitch *s, hsa_bb *hbb)
|
||||||
{
|
{
|
||||||
|
gimple_stmt_iterator it = gsi_for_stmt (s);
|
||||||
|
gsi_prev (&it);
|
||||||
|
|
||||||
|
/* Create preambule that verifies that index - lowest_label >= 0. */
|
||||||
|
edge e = split_block (hbb->m_bb, gsi_stmt (it));
|
||||||
|
e->flags &= ~EDGE_FALLTHRU;
|
||||||
|
e->flags |= EDGE_TRUE_VALUE;
|
||||||
|
|
||||||
function *func = DECL_STRUCT_FUNCTION (current_function_decl);
|
function *func = DECL_STRUCT_FUNCTION (current_function_decl);
|
||||||
tree index_tree = gimple_switch_index (s);
|
tree index_tree = gimple_switch_index (s);
|
||||||
tree lowest = get_switch_low (s);
|
tree lowest = get_switch_low (s);
|
||||||
|
tree highest = get_switch_high (s);
|
||||||
|
|
||||||
hsa_op_reg *index = hsa_cfun->reg_for_gimple_ssa (index_tree);
|
hsa_op_reg *index = hsa_cfun->reg_for_gimple_ssa (index_tree);
|
||||||
|
|
||||||
|
hsa_op_reg *cmp1_reg = new hsa_op_reg (BRIG_TYPE_B1);
|
||||||
|
hsa_op_immed *cmp1_immed = new hsa_op_immed (lowest);
|
||||||
|
hbb->append_insn (new hsa_insn_cmp (BRIG_COMPARE_GE, cmp1_reg->m_type,
|
||||||
|
cmp1_reg, index, cmp1_immed));
|
||||||
|
|
||||||
|
hsa_op_reg *cmp2_reg = new hsa_op_reg (BRIG_TYPE_B1);
|
||||||
|
hsa_op_immed *cmp2_immed = new hsa_op_immed (highest);
|
||||||
|
hbb->append_insn (new hsa_insn_cmp (BRIG_COMPARE_LE, cmp2_reg->m_type,
|
||||||
|
cmp2_reg, index, cmp2_immed));
|
||||||
|
|
||||||
|
hsa_op_reg *cmp_reg = new hsa_op_reg (BRIG_TYPE_B1);
|
||||||
|
hbb->append_insn (new hsa_insn_basic (3, BRIG_OPCODE_AND, cmp_reg->m_type,
|
||||||
|
cmp_reg, cmp1_reg, cmp2_reg));
|
||||||
|
|
||||||
|
hbb->append_insn (new hsa_insn_br (cmp_reg));
|
||||||
|
|
||||||
|
tree default_label = gimple_switch_default_label (s);
|
||||||
|
basic_block default_label_bb = label_to_block_fn (func,
|
||||||
|
CASE_LABEL (default_label));
|
||||||
|
|
||||||
|
make_edge (e->src, default_label_bb, EDGE_FALSE_VALUE);
|
||||||
|
|
||||||
|
hsa_cfun->m_modified_cfg = true;
|
||||||
|
|
||||||
|
/* Basic block with the SBR instruction. */
|
||||||
|
hbb = hsa_init_new_bb (e->dest);
|
||||||
|
|
||||||
hsa_op_reg *sub_index = new hsa_op_reg (index->m_type);
|
hsa_op_reg *sub_index = new hsa_op_reg (index->m_type);
|
||||||
hbb->append_insn (new hsa_insn_basic (3, BRIG_OPCODE_SUB, sub_index->m_type,
|
hbb->append_insn (new hsa_insn_basic (3, BRIG_OPCODE_SUB, sub_index->m_type,
|
||||||
sub_index, index,
|
sub_index, index,
|
||||||
|
|
@ -3452,11 +3489,6 @@ gen_hsa_insns_for_switch_stmt (gswitch *s, hsa_bb *hbb)
|
||||||
unsigned HOST_WIDE_INT size = tree_to_uhwi (get_switch_size (s));
|
unsigned HOST_WIDE_INT size = tree_to_uhwi (get_switch_size (s));
|
||||||
|
|
||||||
hsa_insn_sbr *sbr = new hsa_insn_sbr (sub_index, size + 1);
|
hsa_insn_sbr *sbr = new hsa_insn_sbr (sub_index, size + 1);
|
||||||
tree default_label = gimple_switch_default_label (s);
|
|
||||||
basic_block default_label_bb = label_to_block_fn (func,
|
|
||||||
CASE_LABEL (default_label));
|
|
||||||
|
|
||||||
sbr->m_default_bb = default_label_bb;
|
|
||||||
|
|
||||||
/* Prepare array with default label destination. */
|
/* Prepare array with default label destination. */
|
||||||
for (unsigned HOST_WIDE_INT i = 0; i <= size; i++)
|
for (unsigned HOST_WIDE_INT i = 0; i <= size; i++)
|
||||||
|
|
|
||||||
|
|
@ -564,9 +564,6 @@ public:
|
||||||
/* Jump table. */
|
/* Jump table. */
|
||||||
vec <basic_block> m_jump_table;
|
vec <basic_block> m_jump_table;
|
||||||
|
|
||||||
/* Default label basic block. */
|
|
||||||
basic_block m_default_bb;
|
|
||||||
|
|
||||||
/* Code list for label references. */
|
/* Code list for label references. */
|
||||||
hsa_op_code_list *m_label_code_list;
|
hsa_op_code_list *m_label_code_list;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue