https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119371

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
BTW: It seems as if none of the testcases in libgomp actually
calls expand_GOMP_SIMT_XCHG_IDX!

* * *

The expansion happens in internal-fn.cc's

static void
expand_GOMP_SIMT_XCHG_IDX (internal_fn, gcall *stmt)
{
  tree lhs = gimple_call_lhs (stmt);
  if (!lhs)
    return;
  rtx target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
  rtx src = expand_normal (gimple_call_arg (stmt, 0));
  rtx idx = expand_normal (gimple_call_arg (stmt, 1));
  machine_mode mode = TYPE_MODE (TREE_TYPE (lhs));
  class expand_operand ops[3];
  create_call_lhs_operand (&ops[0], target, mode);
  create_input_operand (&ops[1], src, mode);
  create_input_operand (&ops[2], idx, SImode);
  gcc_assert (targetm.have_omp_simt_xchg_idx ());
  expand_insn (targetm.code_for_omp_simt_xchg_idx, 3, ops);  // <<< ICE here
  assign_call_lhs (lhs, target, &ops[0]);
}


where

(gdb) p debug(stmt)
*_20.D.1762 = .GOMP_SIMT_XCHG_IDX (D.1763, _30);

(gdb) p debug_rtx (target)
(mem:BLK (reg/f:DI 25 [ _20 ]) [1 *_20.D.1762+0 S4 A32])

(gdb) p debug(idx)
(reg:SI 31 [ _30 ])

(gdb) p debug_rtx (src)
(mem/c:BLK (reg/f:DI 17 virtual-stack-vars) [1 D.1763+0 S4 A128])

645       machine_mode mode = TYPE_MODE (TREE_TYPE (lhs));
(gdb) p mode
$9 = E_BLKmode


And, recall (comment 0) that BLKmode causes problems:

4636      gcc_assert (mode != BLKmode
4637                  && (GET_MODE (y) == mode || GET_MODE (y) == VOIDmode));

* * *

BTW: nvptx.md then has:

;; Implement IFN_GOMP_SIMT_XCHG_IDX: broadcast value in operand 1
;; from lane given by index in operand 2 to operand 0 in all lanes
(define_expand "omp_simt_xchg_idx"
  [(match_operand 0 "nvptx_register_or_complex_di_df_register_operand" "=R")
   (match_operand 1 "nvptx_register_or_complex_di_df_register_operand" "R")
   (match_operand:SI 2 "nvptx_nonmemory_operand" "Ri")]
  ""
{
  emit_insn (nvptx_gen_shuffle (operands[0], operands[1], operands[2],
                                SHUFFLE_IDX));

Reply via email to