On Mon, Sep 2, 2013 at 9:03 AM, bin.cheng <bin.ch...@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.ch...@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.ch...@arm.com>
>
>         * gcc.target/arm/ivopts-orig_biv-inc.c: New test.

Reply via email to