[PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

Segher Boessenkool segher@kernel.crashing.org
Thu Oct 22 20:39:50 GMT 2020


On Thu, Oct 15, 2020 at 09:59:24AM +0100, Alex Coplan wrote:
> Currently, make_extraction() identifies where we can emit an ASHIFT of
> an extend in place of an extraction, but fails to make the corresponding
> canonicalization/simplification when presented with a MULT by a power of
> two. Such a representation is canonical when representing a left-shifted
> address inside a MEM.
> 
> This patch remedies this situation: after the patch, make_extraction()
> now also identifies RTXs such as:
> 
> (mult:DI (subreg:DI (reg:SI r)) (const_int 2^n))
> 
> and rewrites this as:
> 
> (mult:DI (sign_extend:DI (reg:SI r)) (const_int 2^n))
> 
> instead of using a sign_extract.

That is only correct if SUBREG_PROMOTED_VAR_P is true and
SUBREG_PROMOTED_UNSIGNED_P is false for r.  Is that guaranteed to be
true here (and how then?)


Segher


More information about the Gcc-patches mailing list