https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79191

--- Comment #5 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Eric Gallager from comment #4)
> Where exactly in the compiler is this optimization supposed to be done and

Eric, that's part of the problem. The optimization already exists in VRP, but
it is defeated by another optimization in match.pd. We could restrict the
match.pd optimization with single_use, although this might cause us to miss
other optimizations. If we replace Y=(unsigned long)(unsigned)X with
Y=X&4294967295, we could try and replace (unsigned)X<3 with Y<3 at the same
time, but it isn't clear how/where/when to do that (restrict the transformation
to single_use in match.pd and add the super special code in
tree-ssa-forwprop.c?). We could try and introduce some magic in VRP (without
value numbering, it could be, when processing X & 4294967295, checking the
other uses of X for a conversion to a 32-bit int and using its interval if
there is a suitable domination relation between the relevant statements), but
that seems hard and ugly. Basically the PR seems to be asking for a better idea
on where to perform this optimization ;-)

Reply via email to