On 24/05/11 20:35, Joseph S. Myers wrote:
On Tue, 24 May 2011, Andrew Stubbs wrote:
I've created this new, simpler patch that converts
(extend (mult a b))
into
(mult (extend a) (extend b))
regardless of what 'a' and 'b' might be. (These are then simplified and
superfluous extends removed, of course.)
Are there some missing conditions here? The two aren't equivalent in
general - (extend:SI (mult:HI a b)) multiplies the HImode values in HImode
(with modulo arithmetic on overflow) before extending the possibly wrapped
result to SImode. You'd need a and b themselves to be extended from
narrower modes in such a way that if you interpret the extended values in
the signedness of the outer extension, the result of the multiplication is
exactly representable in the mode of the multiplication. (For example, if
both values are extended from QImode, and all extensions have the same
signedness, that would be OK. There are cases that are OK where not all
extensions have the same signedness, e.g. (sign_extend:DI (mult:SI a b))
where a and b are zero-extended from HImode or QImode, at least one from
QImode, though there the outer extension is equivalent to a
zero-extension.)
So, you're saying that promoting a regular multiply to a widening
multiply isn't a valid transformation anyway? I suppose that does make
sense. I knew something was too easy.
OK, I'll go try again. :)
Andrew