[Bug target/100232] [OpenMP][nvptx] Reduction fails with optimization and 'loop'/'for simd' but not with 'for'

vries at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 28 12:51:30 GMT 2021


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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amonakov at gcc dot gnu.org

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
In expand_GOMP_SIMT_XCHG_BFLY, we have a subreg target:
...
(gdb) call debug_rtx ( target )
(subreg/s/u:QI (reg:SI 40 [ _61 ]) 0)
...

During expand_insn, the operands are legitimized, and this changes the state of
the output operand to:
...
(gdb) call debug_rtx ( ops[0].value )
(reg:QI 57)
...

So the value is written to reg 57, but never actually copied back to reg 40.

Tentative fix:
...
diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index dd7173126fb..28ae3ed167a 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -361,6 +361,8 @@ expand_GOMP_SIMT_XCHG_BFLY (internal_fn, gcall *stmt)
   create_input_operand (&ops[2], idx, SImode);
   gcc_assert (targetm.have_omp_simt_xchg_bfly ());
   expand_insn (targetm.code_for_omp_simt_xchg_bfly, 3, ops);
+  if (ops[0].value != target)
+    emit_move_insn (target, ops[0].value);
 }

 /* Exchange between SIMT lanes according to given source lane index.  */
...


More information about the Gcc-bugs mailing list