This is the mail archive of the gcc-bugs@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]

[Bug middle-end/31241] New: Post Increment opportunity missed


A simple code that adds a 'value' too all the elements of an array should
generate post increments while loading/storing values from/into the array. The
code looks something like this

for (i = 0; i < 10; i++) {
    *(intArray++) |= value;
}

However a post increment is not generated at O3 ( that causes the
tree-optimizer to unroll the loop)

Here is the information of the toolchain and the code produced.

$>arm-none-eabi-gcc -v -O3 -S enhance.c --save-temps -o-
Using built-in specs.
Target: arm-none-eabi
Configured with:
/mnt/tools/fsf/build/combined-arm-none-eabi-gcc-4.2-branch-2007-03-16/configure
--target=arm-none-eabi
--prefix=/mnt/tools/fsf/install/arm-none-eabi-gcc-4.2-branch-2007-03-16
--enable-languages=c,c++ --disable-nls --with-newlib --disable-gdbtk
--disable-libssp
Thread model: single
gcc version 4.2.0 20070315 (prerelease)

/mnt/tools/fsf/install/arm-none-eabi-gcc-4.2-branch-2007-03-16/libexec/gcc/arm-none-eabi/4.2.0/cc1
-E -quiet -v -D__USES_INITFINI__ enhance.c -O3 -fpch-preprocess -o enhance.i
ignoring nonexistent directory
"/mnt/tools/fsf/install/arm-none-eabi-gcc-4.2-branch-2007-03-16/lib/gcc/arm-none-eabi/4.2.0/../../../../arm-none-eabi/sys-include"
ignoring nonexistent directory
"/mnt/tools/fsf/install/arm-none-eabi-gcc-4.2-branch-2007-03-16/lib/gcc/arm-none-eabi/4.2.0/../../../../arm-none-eabi/include"#include
"..." search starts here:
#include <...> search starts here:

/mnt/tools/fsf/install/arm-none-eabi-gcc-4.2-branch-2007-03-16/lib/gcc/arm-none-eabi/4.2.0/include
End of search list.

/mnt/tools/fsf/install/arm-none-eabi-gcc-4.2-branch-2007-03-16/libexec/gcc/arm-none-eabi/4.2.0/cc1
-fpreprocessed enhance.i -quiet -dumpbase enhance.c -auxbase-strip - -O3
-version -o-
GNU C version 4.2.0 20070315 (prerelease) (arm-none-eabi)
        compiled by GNU C version 4.0.3 (Ubuntu 4.0.3-1ubuntu5).
GGC heuristics: --param ggc-min-expand=97 --param ggc-min-heapsize=127206
Compiler executable checksum: 31464fade10aeea055a352aa873c9729
        .file   "enhance.c"
        .text
        .align  2
        .global ShouldUsePostModify
        .type   ShouldUsePostModify, %function
ShouldUsePostModify:
        @ Function supports interworking.
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        ldr     ip, [r0, #0]
        mov     r3, r0
        orr     ip, ip, r1
        str     ip, [r3], #4
        ldr     r2, [r0, #4]
        orr     r2, r2, r1
        str     r2, [r0, #4]
        ldr     r0, [r3, #4]
        orr     r0, r0, r1
        str     r0, [r3, #4]
        add     r3, r3, #4
        ldr     r2, [r3, #4]
        orr     r2, r2, r1
        str     r2, [r3, #4]
        add     r3, r3, #4
        ldr     r2, [r3, #4]
        orr     r2, r2, r1
        str     r2, [r3, #4]
        add     r3, r3, #4
        ldr     r2, [r3, #4]
        orr     r2, r2, r1
        str     r2, [r3, #4]
        add     r3, r3, #4
        ldr     r2, [r3, #4]
        orr     r2, r2, r1
        str     r2, [r3, #4]
        add     r3, r3, #4
        ldr     r2, [r3, #4]
        orr     r2, r2, r1
        str     r2, [r3, #4]
        add     r3, r3, #4
        ldr     r2, [r3, #4]
        orr     r2, r2, r1
        str     r2, [r3, #4]
        add     r3, r3, #4
        ldr     r2, [r3, #4]
        orr     r2, r2, r1
        @ lr needed for prologue
        str     r2, [r3, #4]
        bx      lr
        .size   ShouldUsePostModify, .-ShouldUsePostModify
        .ident  "GCC: (GNU) 4.2.0 20070315 (prerelease)"

However this problem vanishes when I use -fno-tree-lrs, this is becuase, then
each copy of intArray created by the unroller gets combined and the load/ store
can be combined with the increment of intArray. However, I dont think that this
( the use of -fno-tree-lrs) is the way to go.


-- 
           Summary: Post Increment opportunity missed
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pranav dot bhandarkar at gmail dot com
GCC target triplet: arm-none-eabi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31241


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