/* { dg-do compile } */
/* { dg-options "-O2 -fprofile-generate" } */

struct S
{
  int a;
  void **b;
};

void
foo (struct S *x, int y)
{
  if (!x)
    return;
  if (y >= x->a)
    return;
  x->a--;
  for (; y < x->a; y++)
    x->b[y] = x->b[y + 1];
  x->b[x->a] = (void *) 0;
}

ICEs on IA-64 during combine, but the bug is earlier.
CSE2 creates:
(insn 42 41 87 3 (set (reg/v:SI 344 [ y.8 ])
        (reg:DI 378)) 4 {*movsi_internal} (nil)
    (nil))
which is invalid because the modes don't match.
Before CSE2 there is:
(insn 100 99 101 0 (set (reg:DI 378)
        (reg:DI 113 in1)) -1 (nil)
    (nil))
...
(insn 103 102 104 0 (set (reg:DI 113 in1)
        (reg:DI 378)) -1 (nil)
    (nil))
...
(insn 12 11 13 0 (set (reg/v:SI 350 [ y ])
        (reg:SI 113 in1 [ y ])) 4 {*movsi_internal} (nil)
    (nil))
...
(insn 42 41 87 3 (set (reg/v:SI 344 [ y.8 ])
        (reg/v:SI 350 [ y ])) 4 {*movsi_internal} (nil)
    (nil))
where insns 100 and 103 and code around it are created by .bp pass.

-- 
           Summary: ICE in simplify_subreg with -fprofile-generate
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: critical
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: ia64-linux


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

Reply via email to