Double word left shift optimisation
Ian Lance Taylor
iant@google.com
Thu Jul 26 17:52:00 GMT 2012
On Thu, Jul 26, 2012 at 8:57 AM, Jon Beniston <jon.beniston@ensilica.com> wrote:
>
> I'd like to try to optimise double word left shifts of sign/zero extended
> operands if a widening multiply instruction is available. For the following
> code:
>
> long long f(long a, long b)
> {
> return (long long)a << b;
> }
>
> ARM, MIPS etc expand to a fairly long sequence like:
>
> nor $3,$0,$5
> sra $2,$4,31
> srl $7,$4,1
> srl $7,$7,$3
> sll $2,$2,$5
> andi $6,$5,0x20
> sll $3,$4,$5
> or $2,$7,$2
> movn $2,$3,$6
> movn $3,$0,$6
>
> I'd like to optimise this to something like:
>
> (long long) a * (1 << b)
>
> Which should just be 3 or so instructions. I don't think this can be
> sensibly done in the target backend as the generated pattern is too
> complicated to match and am not familiar with the middle end. Any
> suggestions as to where and how this should be best implemented?
It seems to me that you could just add an ashldi3 pattern.
Ian
More information about the Gcc
mailing list