diff mbox

[hsa/69674] Make testsuite libgomp.c/for-3.c compile with -m32

Message ID 20160226155800.GE3094@virgil.suse.cz
State New
Headers show

Commit Message

Martin Jambor Feb. 26, 2016, 3:58 p.m. UTC
Hi,

the following wrong decision about HSA pointer type leads to hitting
an assert later in the out-of-ssa phase for 32bit targets.  I have not
attempted to test HSA on a 32bit i686 yet, I believe there is no
functional runtime (although it should be possible to come up with
one) and we do not build libgomp plugin for it, but we should not ICE
and the new code below is the correct way of doing things anyway.  So
I will commit it shortly, it has been included in a
bootstrap/testsuite run.

Thanks,

Martin

2016-02-18  Martin Jambor  <mjambor@suse.cz>

	pr hsa/69674
	* hsa-gen.c (gen_hsa_phi_from_gimple_phi): Use proper hsa type for
	pointers.
	(gen_hsa_addr): Allow integer constants in TMR_INDEX2.
---
 gcc/hsa-gen.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c
index a7dc220..a295fda 100644
--- a/gcc/hsa-gen.c
+++ b/gcc/hsa-gen.c
@@ -2105,9 +2105,17 @@  gen_hsa_addr (tree ref, hsa_bb *hbb, HOST_WIDE_INT *output_bitsize = NULL,
 	}
       if (TMR_INDEX2 (ref))
 	{
-	  hsa_op_base *disp2 = hsa_cfun->reg_for_gimple_ssa
-	    (TMR_INDEX2 (ref))->get_in_type (addrtype, hbb);
-	  reg = add_addr_regs_if_needed (reg, as_a <hsa_op_reg *> (disp2), hbb);
+	  if (TREE_CODE (TMR_INDEX2 (ref)) == SSA_NAME)
+	    {
+	      hsa_op_base *disp2 = hsa_cfun->reg_for_gimple_ssa
+		(TMR_INDEX2 (ref))->get_in_type (addrtype, hbb);
+	      reg = add_addr_regs_if_needed (reg, as_a <hsa_op_reg *> (disp2),
+					     hbb);
+	    }
+	  else if (TREE_CODE (TMR_INDEX2 (ref)) == INTEGER_CST)
+	    offset += wi::to_offset (TMR_INDEX2 (ref));
+	  else
+	    gcc_unreachable ();
 	}
       offset += wi::to_offset (TMR_OFFSET (ref));
       break;
@@ -5329,7 +5337,8 @@  gen_hsa_phi_from_gimple_phi (gimple *phi_stmt, hsa_bb *hbb)
 	      hsa_op_address *addr = gen_hsa_addr (TREE_OPERAND (op, 0),
 						   hbb_src);
 
-	      hsa_op_reg *dest = new hsa_op_reg (BRIG_TYPE_U64);
+	      hsa_op_reg *dest
+		= new hsa_op_reg (hsa_get_segment_addr_type (BRIG_SEGMENT_FLAT));
 	      hsa_insn_basic *insn
 		= new hsa_insn_basic (2, BRIG_OPCODE_LDA, BRIG_TYPE_U64,
 				      dest, addr);