This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] lower-subreg: Decompose multiword shifts
- From: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- To: Andreas Krebbel <Andreas dot Krebbel at de dot ibm dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 3 Aug 2007 01:16:09 +0200
- Subject: Re: [PATCH] lower-subreg: Decompose multiword shifts
- References: <20070802153434.GA24953@blc4eb430604175.ibm.com>
On Thu, Aug 02, 2007 at 05:34:34PM +0200, Andreas Krebbel wrote:
> Hello,
>
> the attached patch enhances the lower subreg pass to be able to
> decompose multiword shift instructions.
>
> Currently GCC generates quite ugly code (on s390 31bit) for a function
> like the first of the attached testcase:
>
> u64
> foo (u32 high, u32 low)
> {
> return ((u64)high << 32) | low;
> }
On x86_64 with -O2 -march=k6 -m32, I get:
foo:
pushl %ebp # 39 *pushsi2 [length = 1]
movl %esp, %ebp # 40 *movsi_1/1 [length = 2]
movl 8(%ebp), %edx # 37 *movsi_1/1 [length = 3]
movl 12(%ebp), %eax # 10 *movsi_1/1 [length = 3]
leave # 43 leave [length = 1]
movl %edx, %ecx # 46 *movsi_1/1 [length = 2]
movl %ecx, %edx # 11 *movsi_1/1 [length = 2]
ret # 44 return_internal [length = 1]
This appears sort of fine, i.e. no shifts, with just two useless "movl"
instructions. But the shift remains until the split4 pass, leaving the two
"movl" instructions behind. So I tried your patch:
foo:
pushl %ebp # 43 *pushsi2 [length = 1]
movl %esp, %ebp # 44 *movsi_1/1 [length = 2]
pushl %esi # 45 *pushsi2 [length = 1]
pushl %ebx # 46 *pushsi2 [length = 1]
movl 12(%ebp), %eax # 39 *movsi_1/1 [length = 3]
popl %ebx # 49 popsi1 [length = 1]
movl 8(%ebp), %ecx # 41 *movsi_1/1 [length = 3]
popl %esi # 50 popsi1 [length = 1]
leave # 51 leave [length = 1]
movl %ecx, %edx # 36 *movsi_1/1 [length = 2]
ret # 52 return_internal [length = 1]
I don't know if it's your fault, but it's worse!
--
Rask Ingemann Lambertsen