Problem with your change to recompute virtual operands

law@redhat.com law@redhat.com
Tue Sep 16 20:57:00 GMT 2003


        * tree-ssa-dom.c (optimize_stmt): If folding changed stuff, we
        need to recalculate the vops.

I'd like to see some discussion about this change.  It's not safe to
go around blindly recomputing the virtual ops.  In fact, if you find 
yourself needing to recomputing the virtual operands, then odds are
something else is broken upstream.

The fundamental problem is you can't recreate the SSA versions when
you rebuild the virtual operands.

If you've got testcode, I'm happy to look at it.

FWIW, here's code that blows up after your change and shows why it's
unsafe in general to rebuild the virtual operands:

static unsigned short equot[(6 +3)];
int
foo (num)
     unsigned short num[];
{
  unsigned short *p = &equot[0];
  *p++ = num[0];
  *p++ = num[1];
}


We end up with:
;; Function foo (foo)

foo (num)
{
  short unsigned int * T.1;
  short unsigned int * p;

  
  # BLOCK 0.  PRED: -1.  SUCC: -2.
  (void)0;
  
  #   equot_9 = VDEF <equot_3>;
  equot[0] = *num_2;
  p_5 = &equot + 2B;
  T.1_6 = num_2 + 2B;
  
  #   VUSE <equot>;
  *(&equot + 2B) = *T.1_6;
  (void)0;
}


Note the vuse of an unversioned equot.  That leads to aborts later in the
compiler in code which happens to know that virtual operands must always
be versioned.

Jeff



More information about the Gcc-patches mailing list