This is the mail archive of the
mailing list for the GCC project.
Re: [PING^2][PATCH][2 of 2] RTL expansion for zero sign extension elimination with VRP
- From: Richard Biener <rguenther at suse dot de>
- To: Kugan <kugan dot vivekanandarajah at linaro dot org>
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, gcc-patches at gcc dot gnu dot org, steven at gcc dot gnu dot org
- Date: Tue, 15 Oct 2013 15:25:19 +0200 (CEST)
- Subject: Re: [PING^2][PATCH][2 of 2] RTL expansion for zero sign extension elimination with VRP
- Authentication-results: sourceware.org; auth=none
- References: <51ABFC6E dot 30205 at linaro dot org> <1726629 dot C2vZH2NXuZ at polaris> <520B31F5 dot 7020200 at linaro dot org> <52245B58 dot 6090507 at linaro dot org> <CAELXzTO=EdN_wn-EvYu6LALK8jLmfrDhwWNG_rRAK1xcXdPqWA at mail dot gmail dot com> <5253B4FA dot 9090203 at linaro dot org> <525D153A dot 1030808 at linaro dot org>
On Tue, 15 Oct 2013, Kugan wrote:
> Hi Eric,
> Can you please help to review this patch?
I think that gimple_assign_is_zero_sign_ext_redundant and its
description is somewhat confused. You seem to have two cases
here, one being NOP_EXPR or CONVERT_EXPR that are in the IL
because they are required for type correctness. So,
long = (long) int
which usually expands to
(set:DI (sext:DI reg:SI))
you want to expand as
(set:DI (subreg:DI reg:SI))
where you have to be careful for modes smaller than word_mode.
You don't seem to implement this optimization though (but
the gimple_assign_is_zero_sign_ext_redundant talks about it).
Second are promotions required by the target (PROMOTE_MODE)
that do arithmetic on wider registers like for
char = char + char
where they cannot do
(set:QI (plus:QI reg:QI reg:QI))
but instead have, for example reg:SI only and you get
(set:SI (plus:SI reg:SI reg:SI))
(set:SI ([sz]ext:SI (subreg:QI reg:SI)))
that you try to address with the cfgexpand hunk but I believe
it doesn't work the way you do it. That is because on GIMPLE
you do not see SImode temporaries and thus no SImode value-ranges.
tem = (char) 255 + (char) 1;
which has a value-range of [0,0] but clearly when computed in
SImode the value-range is [256, 256]. That is, VRP computes
value-ranges in the expression type, not in some arbitrary
So what you'd have to do is take the value-ranges of the
two operands of the plus and see whether the plus can overflow
QImode when computed in SImode (for the example).
[exposing the effect of PROMOTE_MODE earlier than at RTL expansion
time may make this less awkward]
> > +2013-09-25 Kugan Vivekanandarajah <firstname.lastname@example.org>
> > +
> > + * dojump.c (do_compare_and_jump): Generate rtl without
> > + zero/sign extension if redundant.
> > + * cfgexpand.c (expand_gimple_stmt_1): Likewise.
> > + * gimple.c (gimple_assign_is_zero_sign_ext_redundant) : New
> > + function.
> > + * gimple.h (gimple_assign_is_zero_sign_ext_redundant) : Declare.
> > +