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]

Re: [PATCH GCC]Find auto-increment use both before and after candidate's increment in IVOPT


On Mon, Sep 2, 2013 at 9:03 AM, bin.cheng <bin.cheng@arm.com> wrote:
> Hi,
> For now set_autoinc_for_original_candidates only searches auto-inc uses
> before candidate's increment, causing pre-increment opportunities missed for
> original candidates.  This is a straightforward fix by searching after
> candidate's increment too.
>
> The patch also includes a test case to illustrate the problem.  Without the
> patch, assembly of the test is:
> foo:
>         @ args = 0, pretend = 0, frame = 0
>         @ frame_needed = 0, uses_anonymous_args = 0
>         @ link register save eliminated.
>         movw    r3, #:lower16:__ctype_ptr__
>         ldrb    r2, [r0]        @ zero_extendqisi2
>         movt    r3, #:upper16:__ctype_ptr__
>         ldr     r1, [r3]
>         adds    r3, r1, r2
>         ldrb    r3, [r3, #1]    @ zero_extendqisi2
>         lsls    r3, r3, #29
>         bmi     .L2
>         adds    r3, r0, #1
> .L3:
>         mov     r0, r3
>         adds    r3, r3, #1
>         ldrb    r2, [r0]        @ zero_extendqisi2
>         add     r2, r2, r1
>         ldrb    r2, [r2, #1]    @ zero_extendqisi2
>         lsls    r2, r2, #29
>         bpl     .L3
> .L2:
>         bx      lr
>         .size   foo, .-foo
>
> Which can be optimized into below:
> foo:
>         @ args = 0, pretend = 0, frame = 0
>         @ frame_needed = 0, uses_anonymous_args = 0
>         @ link register save eliminated.
>         movw    r3, #:lower16:__ctype_ptr__
>         ldrb    r1, [r0]        @ zero_extendqisi2
>         movt    r3, #:upper16:__ctype_ptr__
>         ldr     r2, [r3]
>         adds    r3, r2, r1
>         ldrb    r3, [r3, #1]    @ zero_extendqisi2
>         lsls    r1, r3, #29
>         bmi     .L2
> .L3:
>         ldrb    r3, [r0, #1]!   @ zero_extendqisi2
>         add     r3, r3, r2
>         ldrb    r3, [r3, #1]    @ zero_extendqisi2
>         lsls    r3, r3, #29
>         bpl     .L3
> .L2:
>         bx      lr
>         .size   foo, .-foo
>
> Bootstrapped and tested on arm a15, is it OK?

Ok.

Thanks,
Richard.

> Thanks.
> bin
>
> 2013-09-02  Bin Cheng  <bin.cheng@arm.com>
>
>         * tree-ssa-loop-ivopts.c (set_autoinc_for_original_candidates):
>         Find auto-increment use both before and after candidate.
>
> gcc/testsuite/ChangeLog
> 2013-09-02  Bin Cheng  <bin.cheng@arm.com>
>
>         * gcc.target/arm/ivopts-orig_biv-inc.c: New test.


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