This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, PR43920, 4-9/9] Cross-jumping.
- From: Tom de Vries <vries at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org, ebotcazou at libertysurf dot fr
- Cc: Maxim Kuvyrkov <maxim at codesourcery dot com>, Bernd Schmidt <bernds at codesourcery dot com>
- Date: Thu, 31 Mar 2011 20:31:39 +0200
- Subject: [PATCH, PR43920, 4-9/9] Cross-jumping.
- References: <4D94C603.7080505@codesourcery.com>
The impact of patches 4-9 of the patch set on the example from the bug
report for ARM Thumb-2 -Os is a further size reduction of 7%, from 58 to
54 bytes.
This size reduction is illustrated in this diff of the assembly
(left, without patches, size 58. right, with patches, size 54):
...
push {r3, r4, r5, r6, r7, push {r3, r4, r5, r6, r7,
mov r7, r1 mov r7, r1
mov r6, r2 mov r6, r2
movs r1, #0 movs r1, #0
movs r2, #1 movs r2, #1
mov r5, r0 mov r5, r0
bl lseek bl lseek
movs r1, #0 movs r1, #0
movs r2, #2 movs r2, #2
mov r4, r0 mov r4, r0
mov r0, r5 mov r0, r5
bl lseek bl lseek
adds r2, r4, #1 adds r2, r4, #1
beq .L3 | beq .L5
adds r3, r0, #1 adds r3, r0, #1
beq .L2 beq .L2
subs r0, r0, r4 subs r0, r0, r4
beq .L5 beq .L5
str r4, [r7, #0] str r4, [r7, #0]
str r0, [r6, #0] str r0, [r6, #0]
movs r0, #0 movs r0, #0
pop {r3, r4, r5, r6, r7, pop {r3, r4, r5, r6, r7,
.L3: <
mov r0, r4 <
pop {r3, r4, r5, r6, r7, <
.L5: .L5:
mov r0, #-1 mov r0, #-1
.L2: .L2:
pop {r3, r4, r5, r6, r7, pop {r3, r4, r5, r6, r7,
...
The patches 4-9 allows crossjumping:
- to recognize that 'mov r0, r4' and 'move r0, #-1' have the same
effect, and
- to extend the search scope past label .L2 backward to .L5, in order
to recognize that the jump to .L3 can be replaced with a jump to .L5.
Thanks,
- Tom
- Follow-Ups:
- [PATCH, PR43920, 4/9] Cross-jumping - Don't count use or clobber.
- [PATCH, PR43920, 5/9] Cross-jumping - Add missing use of return register.
- [PATCH, PR43920, 6/9] Cross-jumping - Use reg-notes.
- [PATCH, PR43920, 7/9] Cross-jumping - Extend search scope.
- [PATCH, PR43920, 8/9] Cross-jumping - Extend search scope - test case.
- [PATCH, PR43920, 9/9] Cross-jumping - Allow both directions.