This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix 14844/15459/21608: Forward-propagate casts that will collapse
On Tue, May 24, 2005 at 03:43:23PM -0700, Richard Henderson wrote:
> On Tue, May 24, 2005 at 06:35:33PM -0400, Diego Novillo wrote:
> > Not by hacking into copy-prop, I hope.
> Why not? It *is* a copy, bitwise if not typewise. Because of
> that, heuristics wrt cse-ing of other expressions don't really
> apply the same way.
Mostly because it would only catch that specific case, whereas ...
> At least using the same engine if you don't like sullying the
> existing pass.
... in this case, we would just get it as one of the various
expression combination that a generic expression propagator might
But you do have a point in that type casts are bitwise copies,
after all. What if you simply modify copy_prop_visit_stmt
to strip type casts before checking the RHS for copies?
T1 x_3 = (T1)y_1;
T2 z_5 = (T2)x_3;
If we strip T1, x_3's value becomes y_1 which is then substituted
in the second statement. Final substitution can determine that
the cast is not needed in z_5 = (T2)y_1.