[Bug tree-optimization/31146] forwprop does not look through casts

rguenth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Mar 12 15:35:00 GMT 2007



------- Comment #3 from rguenth at gcc dot gnu dot org  2007-03-12 15:35 -------
The problem is that for example FRE value numbers

  void *p_4 = &a[0];
  int *q_1 = (int *)p_4;

p_4 with void* type (even if &a[0] is of int* type) and so re-generates the
conversion to int* even though it is about to replace (int *)p_4 with p_4
(as tree_ssa_useless_type_conversion_1 is false for converting void* to int*).

At the same time tree-combining the conversion (int *)&a[0] leads to
&a[0] for which we have a value already, the void* p_4 :/

Maybe the new VN will fix this testcase as well.  With the series of forwprop
patches in my queue (which you obviously don't like at all, but I blame you
for that) we get for

  (void) (TARGET_EXPR <D.2605, (double *) operator new (8, (void *) &a[i])>;,
D.2605 != 0B ? try
    {
      *D.2605 = 0.0;
    }
  catch
    {
      operator delete ((void *) D.2605, (void *) &a[i]);
    }, D.2605 : D.2605;)

instead of

  __p_5 = &a[i_3];
  iftmp.3_6 = (double *) __p_5;
  if (iftmp.3_6 != 0B) goto <L1>; else goto <L2>;

<L1>:;
  *iftmp.3_6 = 0.0;

<L2>:;

just

  a[i_3] = 0.0;


-- 


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



More information about the Gcc-bugs mailing list