This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CCP confused by casts?


Richard Guenther wrote:

I'm investigating PR19637, especially the difference between
placement new on char* and void* pointers.  One difference is,
that for char* pointers, CCP is not able to propagate i.2_1
into the comparison:

<bb 0>:
  i.2_1 = (char *) &i;

You're being bitten by type casts.  This is not a gimple min invariant
(is_gimple_min_invariant), it cannot be replaced in any arbitrary
expression, that's why CCP doesn't propagate it.

In this case, VRP considers it non-NULL and fold 'if (__p_3 != 0B)'
(only on tree-cleanup-branch for now).

However, all the other type casts get in the way of propagating 1 into
the return sites because the intermediate dereferences would be
seemingly invalid for the different types.

For instance, for foo_char, we end up with:

  # BLOCK 0
  # PRED: ENTRY [100.0%]  (fallthru,exec)
  i.2_1 = (char *) &i;
  this_7 = (struct Foo *) __i.2_1;
  #   i_16 = V_MAY_DEF <i_15>;
  this_7->i[0] = 1;
  i.4_8 = (struct Foo *) &i;
  #   VUSE <i_16>;
  D.1778_9 = i.4_8->i[0];
  return D.1778_9;


The store to 'i_16' is not propagated into the load downstream because we can't prove that the two memory locations are identical. Must alias information may help here (both i.4_8 and this_7 must point to 'i').


Propagating &i into this_7->i[0] is also not possible because 'i' is an integer array, not a structure.


Diego.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]