public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/31241]  New: Post Increment opportunity missed
@ 2007-03-17 14:10 pranav dot bhandarkar at gmail dot com
  2007-03-17 14:13 ` [Bug middle-end/31241] " pranav dot bhandarkar at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: pranav dot bhandarkar at gmail dot com @ 2007-03-17 14:10 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/31241] Post Increment opportunity missed
  2007-03-17 14:10 [Bug middle-end/31241] New: Post Increment opportunity missed pranav dot bhandarkar at gmail dot com
@ 2007-03-17 14:13 ` pranav dot bhandarkar at gmail dot com
  2007-03-19  2:53 ` ramana dot radhakrishnan at codito dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pranav dot bhandarkar at gmail dot com @ 2007-03-17 14:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pranav dot bhandarkar at gmail dot com  2007-03-17 14:13 -------
Created an attachment (id=13218)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13218&action=view)
Source that exposes the mentioned deficiency in the compiler


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/31241] Post Increment opportunity missed
  2007-03-17 14:10 [Bug middle-end/31241] New: Post Increment opportunity missed pranav dot bhandarkar at gmail dot com
  2007-03-17 14:13 ` [Bug middle-end/31241] " pranav dot bhandarkar at gmail dot com
@ 2007-03-19  2:53 ` ramana dot radhakrishnan at codito dot com
  2008-05-23 23:05 ` hp at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ramana dot radhakrishnan at codito dot com @ 2007-03-19  2:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ramana dot radhakrishnan at codito dot com  2007-03-19 02:52 -------
A similar problem also exists on the dataflow branch. Adding Kenneth Zadeck to
the CC.

However fno-tree-lrs has no impact in the df branch as on revision 122955 .


-- 

ramana dot radhakrishnan at codito dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zadeck at naturalbridge dot
                   |                            |com


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/31241] Post Increment opportunity missed
  2007-03-17 14:10 [Bug middle-end/31241] New: Post Increment opportunity missed pranav dot bhandarkar at gmail dot com
  2007-03-17 14:13 ` [Bug middle-end/31241] " pranav dot bhandarkar at gmail dot com
  2007-03-19  2:53 ` ramana dot radhakrishnan at codito dot com
@ 2008-05-23 23:05 ` hp at gcc dot gnu dot org
  2009-04-30 10:30 ` ramana at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: hp at gcc dot gnu dot org @ 2008-05-23 23:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from hp at gcc dot gnu dot org  2008-05-23 23:05 -------
This could be a duplicate of PR20211.


-- 

hp at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hp at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/31241] Post Increment opportunity missed
  2007-03-17 14:10 [Bug middle-end/31241] New: Post Increment opportunity missed pranav dot bhandarkar at gmail dot com
                   ` (2 preceding siblings ...)
  2008-05-23 23:05 ` hp at gcc dot gnu dot org
@ 2009-04-30 10:30 ` ramana at gcc dot gnu dot org
  2009-05-30  9:18 ` ramana at gcc dot gnu dot org
  2010-03-22 21:16 ` ramana at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-04-30 10:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from ramana at gcc dot gnu dot org  2009-04-30 10:30 -------
Not sure if this is related to PR31849 as well.


-- 

ramana at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-04-30 10:30:18
               date|                            |


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/31241] Post Increment opportunity missed
  2007-03-17 14:10 [Bug middle-end/31241] New: Post Increment opportunity missed pranav dot bhandarkar at gmail dot com
                   ` (3 preceding siblings ...)
  2009-04-30 10:30 ` ramana at gcc dot gnu dot org
@ 2009-05-30  9:18 ` ramana at gcc dot gnu dot org
  2010-03-22 21:16 ` ramana at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-05-30  9:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from ramana at gcc dot gnu dot org  2009-05-30 09:18 -------
This is improved by http://gcc.gnu.org/ml/gcc-patches/2009-05/msg01622.html.
With the patch we get the following code generated. 

        .cpu cortex-a8
        .eabi_attribute 27, 3
        .fpu neon
        .eabi_attribute 20, 1
        .eabi_attribute 21, 1
        .eabi_attribute 23, 3
        .eabi_attribute 24, 1
        .eabi_attribute 25, 1
        .eabi_attribute 26, 1
        .eabi_attribute 30, 2
        .eabi_attribute 18, 4
        .file   "31241.c"
        .text
        .align  2
        .global foo
        .type   foo, %function
foo:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        add     r2, r0, #40
.L2:
        ldr     r3, [r0, #0]
        orr     r3, r1, r3
        str     r3, [r0], #4
        cmp     r0, r2
        bne     .L2
        bx      lr
        .size   foo, .-foo
        .ident  "GCC: (GNU) 4.5.0 20090527 (experimental)"


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/31241] Post Increment opportunity missed
  2007-03-17 14:10 [Bug middle-end/31241] New: Post Increment opportunity missed pranav dot bhandarkar at gmail dot com
                   ` (4 preceding siblings ...)
  2009-05-30  9:18 ` ramana at gcc dot gnu dot org
@ 2010-03-22 21:16 ` ramana at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu dot org @ 2010-03-22 21:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from ramana at gcc dot gnu dot org  2010-03-22 21:16 -------
Unrolling the loop still doesn't show better use of auto-incs.


-- 

ramana at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-03-22 21:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-17 14:10 [Bug middle-end/31241] New: Post Increment opportunity missed pranav dot bhandarkar at gmail dot com
2007-03-17 14:13 ` [Bug middle-end/31241] " pranav dot bhandarkar at gmail dot com
2007-03-19  2:53 ` ramana dot radhakrishnan at codito dot com
2008-05-23 23:05 ` hp at gcc dot gnu dot org
2009-04-30 10:30 ` ramana at gcc dot gnu dot org
2009-05-30  9:18 ` ramana at gcc dot gnu dot org
2010-03-22 21:16 ` ramana at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).