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]

New optimization for reload_combine


This fixes one subproblem of PR42235.  In reload_combine, we recognize a
new pattern:

 REG1 = REG2 + CONST
 ...
 something MEM (REG1)

and try to use the addition in the MEM directly, moving the add insn
downwards if REG1 and REG2 are identical.  This has two benefits: it may
be possible to eliminate the add, and the load no longer depends on the
add instruction and may schedule sooner.

This can make the generated code quite a lot nicer:

-       adds    r3, r2, #2
        strb    r5, [r2, #0]
-       strb    r5, [r3, #0]
-       adds    r3, r2, #3
+       strb    r5, [r2, #2]
        strb    r5, [r2, #1]
-       strb    r5, [r3, #0]
-       adds    r3, r2, #4
+       strb    r5, [r2, #3]
        lsrs    r1, r1, #11
-       strb    r5, [r3, #0]
-       adds    r3, r2, #5
+       strb    r5, [r2, #4]
        add     r1, r1, r1, lsl #1
-       strb    r5, [r3, #0]
+       strb    r5, [r2, #5]

Bootstrapped and regression tested on i686-linux.  Also tested on
    qemu-system-armv7/arch=armv7-a/thumb
    qemu-system-armv7/thumb
    qemu-system-armv7

Does postreload.c fall under reload?  If not, would someone approve this?


Bernd

Attachment: rc-newpattern.diff
Description: Text document


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