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

            Bug ID: 95622
           Summary: force_output flag on a variable prevents optimization
                    / regresses
                    c-c++-common/goacc/kernels-alias-ipa-pta-2.c
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, openacc, openmp
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

The following only shows up as FAIL in the testsuite if  ENABLE_OFFLOAD  is
true, even though it is only a compile-time test.   [Hence, it can make sense
to not only "make check-target-libgomp" with an offloading compiler but also
gcc/.]

Somewhat similar to PR 68773.

The testcase: c-c++-common/goacc/kernels-alias-ipa-pta-2.c
…
  {
    a[0] = 0;
    b[0] = 1;
    c[0] = a[0];
  }
…

Without ENABLE_OFFLOAD or before
r11-1075-g1c0fdaf79e3618fd7512608a2e5c62b6b306e9e8 (for PR94848 + PR95551):

  MEM[(unsigned int *)_5] = 0;  // a[0] = 0
  MEM[(unsigned int *)_4] = 1;  // b[0] = 1
  MEM[(unsigned int *)_3] = 0;  // c[0] = a[0]

With r11-1075 + offloading compiler, force_output is on offloading variables
(to ensure they are not optimized away), the last line becomes

  _8 = MEM[(unsigned int *)_5];  // _8 = a[0]
  MEM[(unsigned int *)_3] = _8;  // c[0] = _8

Expected: force_output does not affect the optimization. (Especially as "a"
cannot be optimized away as it is also used for "copyout".)

[A very well optimizing compiler could see that nothing uses a/b/c after the
target section and could replace the whole function body by "{ }"…]

Reply via email to