This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch][simplify-rtx] Fix 16-bit -> 64-bit multiply and accumulate
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Andrew Stubbs <ams at codesourcery dot com>
- Cc: Bernd Schmidt <bernds at codesourcery dot com>, Richard Earnshaw <rearnsha at arm dot com>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 24 May 2011 19:35:34 +0000 (UTC)
- Subject: Re: [patch][simplify-rtx] Fix 16-bit -> 64-bit multiply and accumulate
- References: <4D01018F.3020108@codesourcery.com> <1296153619.9738.16.camel@e102346-lin.cambridge.arm.com> <4D42955C.1060707@codesourcery.com> <1296223929.9738.30.camel@e102346-lin.cambridge.arm.com> <4D42DD32.7020404@codesourcery.com> <1296228038.9738.48.camel@e102346-lin.cambridge.arm.com> <4D8CC0A9.5080504@codesourcery.com> <4DA823F1.2040907@codesourcery.com> <4DBFC5D8.1090009@codesourcery.com> <4DDBE035.8050901@codesourcery.com>
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.)
--
Joseph S. Myers
joseph@codesourcery.com