This is the mail archive of the
mailing list for the GCC project.
Re: Zero/Sign extension elimination using value ranges
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Kugan <kugan dot vivekanandarajah at linaro dot org>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Richard Biener <richard dot guenther at gmail dot com>, Eric Botcazou <ebotcazou at adacore dot com>
- Date: Tue, 20 May 2014 08:52:57 +0200
- Subject: Re: Zero/Sign extension elimination using value ranges
- Authentication-results: sourceware.org; auth=none
- References: <537ABD93 dot 2040703 at linaro dot org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, May 20, 2014 at 12:27:31PM +1000, Kugan wrote:
> 1. Handling NOP_EXPR or CONVERT_EXPR that are in the IL because they
> are required for type correctness. We have two cases here:
> A) Mode is smaller than word_mode. This is usually from where the
> zero/sign extensions are showing up in final assembly.
> For example :
> int = (int) short
> which usually expands to
> (set (reg:SI )
> (sext:SI (subreg:HI (reg:SI ))))
> We can expand this
> (set (reg:SI ) (((reg:SI ))))
> If following is true:
> 1. Value stored in RHS and LHS are of the same signedness
> 2. Type can hold the value. i.e., In cases like char = (char) short, we
> check that the value in short is representable char type. (i.e. look at
> the value range in RHS SSA_NAME and see if that can be represented in
> types of LHS without overflowing)
> Subreg here is not a paradoxical subreg. We are removing the subreg and
> zero/sign extend here.
> I am assuming here that QI/HI registers are represented in SImode
> (basically word_mode) with zero/sign extend is used as in
> (zero_extend:SI (subreg:HI (reg:SI 117)).
Wouldn't it be better to just set proper flags on the SUBREG based on value
range info (SUBREG_PROMOTED_VAR_P and SUBREG_PROMOTED_UNSIGNED_P)?
Then not only the optimizers could eliminate in zext/sext when possible, but
all other optimizations could benefit from that.