public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/106548] New: ICE in #pragma openmp parallel for simd linear with long long variables
@ 2022-08-07 17:57 sandra at gcc dot gnu.org
  2022-08-16  9:27 ` [Bug middle-end/106548] [OpenMP] " burnus at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sandra at gcc dot gnu.org @ 2022-08-07 17:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106548
           Summary: ICE in #pragma openmp parallel for simd linear with
                    long long variables
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sandra at gcc dot gnu.org
  Target Milestone: ---

Test case is reduced from libgomp.c/linear-1.c, with "simd" added to the loop:

int a[256];

__attribute__((noinline, noclone)) long long int
f3 (long long int i, long long int k)
{
  #pragma omp parallel for simd linear (i: k)
  for (short j = 16; j < 64; j++)
    {
      a[i] = j;
      i += 4;
    }
  return i;
}

$ x86_64-linux-gnu-gcc -S -fopenmp linear-1.c
during RTL pass: expand
linear-1.c: In function 'f3._omp_fn.0':
linear-1.c:6:11: internal compiler error: in expand_expr_real_1, at
expr.cc:10721
    6 |   #pragma omp parallel for simd linear (i: k)
      |           ^~~
0x748517 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        /path/to/gcc/expr.cc:10721
0xba694c expand_expr
        /path/to/gcc/expr.h:310
0xba694c expand_operands(tree_node*, tree_node*, rtx_def*, rtx_def**,
rtx_def**, expand_modifier)
        /path/to/gcc/expr.cc:8403
0xb9eedb expand_expr_real_2(separate_ops*, rtx_def*, machine_mode,
expand_modifier)
        /path/to/gcc/expr.cc:9631
0xa7a3c8 expand_gimple_stmt_1
        /path/to/gcc/cfgexpand.cc:3983
0xa7a3c8 expand_gimple_stmt
        /path/to/gcc/cfgexpand.cc:4044
0xa8013e expand_gimple_basic_block
        /path/to/gcc/cfgexpand.cc:6096
0xa81c66 execute
        /path/to/cfgexpand.cc:6822
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Declaring either i or k as plain "int" instead of "long long int" makes the
crash go away.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/106548] [OpenMP] ICE in #pragma openmp parallel for simd linear with long long variables
  2022-08-07 17:57 [Bug middle-end/106548] New: ICE in #pragma openmp parallel for simd linear with long long variables sandra at gcc dot gnu.org
@ 2022-08-16  9:27 ` burnus at gcc dot gnu.org
  2022-08-16 10:08 ` burnus at gcc dot gnu.org
  2022-08-16 15:29 ` burnus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-08-16  9:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The ICE is for:

expand_expr_real_1's

10721             gcc_assert (SCOPE_FILE_SCOPE_P (context)
10722                         || context == current_function_decl
10723                         || TREE_STATIC (exp)
10724                         || DECL_EXTERNAL (exp)

where  context)  is  function_decl f3
but    current_function_decl  is  function_decl f3._omp_fn.0

Here, exp is a  long long int  ssa_name with 'visited var <parm_decl
0x7ffff7ffb180 k>'
and the Gimple stmt is:
  _35 = _33 * k_34(D);

The dump is:
  void f3._omp_fn.0 (...)
  ...
    <bb 2> :
    k_13 = .omp_data_i_12(D)->k;
    ...
    _35 = _33 * k_34(D);

Thus, it seems as if some VALUE_EXPR is not taken into account?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/106548] [OpenMP] ICE in #pragma openmp parallel for simd linear with long long variables
  2022-08-07 17:57 [Bug middle-end/106548] New: ICE in #pragma openmp parallel for simd linear with long long variables sandra at gcc dot gnu.org
  2022-08-16  9:27 ` [Bug middle-end/106548] [OpenMP] " burnus at gcc dot gnu.org
@ 2022-08-16 10:08 ` burnus at gcc dot gnu.org
  2022-08-16 15:29 ` burnus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-08-16 10:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The problem is the following code in omp-low.c:

            do_firstprivate:
              lower_private_allocate (var, new_var, allocator, allocate_ptr,
                                      ilist, ctx, false, NULL_TREE);
              x = build_outer_var_ref (var, ctx);
              if (is_simd)
                {
                  if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
                      && gimple_omp_for_combined_into_p (ctx->stmt))
                    {
                      tree t = OMP_CLAUSE_LINEAR_STEP (c);

where the clause ('c') is
 <omp_clause 0x7ffff71432d0 linear
    op-0: <parm_decl 0x7ffff7ffb100 i>  ( == var)
    op-1: <parm_decl 0x7ffff7ffb180 k>

and 't' is
  <parm_decl 0x7ffff7ffb180 k


I think something like the following is needed:

diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -6190,2 +6190,6 @@ lower_rec_input_clausesgimple_seq *dlist,
                      tree t = OMP_CLAUSE_LINEAR_STEP (c);
+                     if (VAR_P (t)
+                         || TREE_CODE (t) == PARM_DECL
+                         || TREE_CODE (t) == RESULT_DECL)
+                       t = build_outer_var_ref (t, ctx);
                      tree stept = TREE_TYPE (t);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/106548] [OpenMP] ICE in #pragma openmp parallel for simd linear with long long variables
  2022-08-07 17:57 [Bug middle-end/106548] New: ICE in #pragma openmp parallel for simd linear with long long variables sandra at gcc dot gnu.org
  2022-08-16  9:27 ` [Bug middle-end/106548] [OpenMP] " burnus at gcc dot gnu.org
  2022-08-16 10:08 ` burnus at gcc dot gnu.org
@ 2022-08-16 15:29 ` burnus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-08-16 15:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Submitted patch:
  https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599832.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-16 15:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-07 17:57 [Bug middle-end/106548] New: ICE in #pragma openmp parallel for simd linear with long long variables sandra at gcc dot gnu.org
2022-08-16  9:27 ` [Bug middle-end/106548] [OpenMP] " burnus at gcc dot gnu.org
2022-08-16 10:08 ` burnus at gcc dot gnu.org
2022-08-16 15:29 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).