This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, PR43920, 4-9/9] Cross-jumping.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]