4.0.0 generates duplicated labels on sh4-unknown-linux-gnu with -fPIC -O2
for the code below:

void bar (void);

int f(int i, int j)
{
  static void *a[5] = {&&b,&&c,&&d,&&e,&&f};

    if (i >=5) i = 0; if (i<=0)i=5;
    goto *a[i];
  e:
    i++;  if (i >=5) i = 0; if (i<=0)i=5;
    j++;
    goto *a[i];
  f:
    i--;  if (i >=5) i = 0; if (i<=0)i=5;
    j--;
    goto *a[i];
  b:
    i+=2;  if (i >=5) i = 0; if (i<=0)i=5;
    goto *a[i];
  c:
    i*=2;  if (i >=5) i = 0; if (i<=0)i=5;
    bar ();
    goto *a[i];
  d:;
}

which is a slightly modified testcase in PR 15242.  SH uses the unique
label for PIC call insn and it's noncopyable.  duplicate_computed_gotos
which was introduced to solve PR 15242 copies the block including call
insn for bar and produces duplicated labels.  I'm proposing a patch
http://gcc.gnu.org/ml/gcc-patches/2005-02/msg00924.html to avoid this.

-- 
           Summary: [4.0.0 Regression] duplicated labels in PIC
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kkojima at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gn
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: sh4-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20117

Reply via email to