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

            Bug ID: 110192
           Summary: Missed GIMPLE optimization with calls
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

int *t;
long b;

void *
foo ()
{
  void *c;
  if (t)
    {
      c = operator new (b);
      return c;
    }
  void *d = operator new (b);
  return d;
}

has still in optimized dump
  t.0_1 = t;
  pretmp_13 = b;
  _14 = (long unsigned int) pretmp_13;
  if (t.0_1 != 0B)
    goto <bb 3>; [54.59%]
  else
    goto <bb 4>; [45.41%]

  <bb 3> [local count: 586155665]:
  _12 = operator new (_14); [tail call]
  goto <bb 5>; [100.00%]

  <bb 4> [local count: 487586160]:
  _10 = operator new (_14); [tail call]

  <bb 5> [local count: 1073741824]:
  # _6 = PHI <_12(3), _10(4)>
  return _6;
and only RTL optimizations manage (jump2) to just a single unconditional call.
In GCC 8 this causes ICE when t is thread_local (testcase reduced from skia) on
powerpc64le because it isn't prepared to have all TLSLD references disappear
during RTL optimizations (I think even trunk has a theoretical such problem
where get_some_local_dynamic_name will return NULL if all such references are
optimized out and it might misbehave in the callers).

Reply via email to