public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/36693] New: missed optimization for pointer access with offset on powerpc
@ 2008-07-02 10:22 rbuergel at web dot de
2008-08-11 1:32 ` [Bug rtl-optimization/36693] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: rbuergel at web dot de @ 2008-07-02 10:22 UTC (permalink / raw)
To: gcc-bugs
the following two equivalent functions are compiled into different asm-code.
The bad thing is, that the more readable function (get_and_increment2) creates
worse code. It is bigger and slower. This is because it uses one register more
than the more optimized version get_and_increment1.
struct IntPtr
{
int* m_ReadPtr;
};
int get_and_increment1(struct IntPtr* i)
{
return *(i->m_ReadPtr++);
}
int get_and_increment2(struct IntPtr* i)
{
i->m_ReadPtr++;
return *(i->m_ReadPtr - 1);
}
00000000 <get_and_increment1>:
0: 81 23 00 00 lwz r9,0(r3)
4: 80 09 00 00 lwz r0,0(r9)
8: 39 29 00 04 addi r9,r9,4
c: 91 23 00 00 stw r9,0(r3)
10: 7c 03 03 78 mr r3,r0
14: 4e 80 00 20 blr
00000018 <get_and_increment2>:
18: 81 23 00 00 lwz r9,0(r3)
1c: 39 29 00 04 addi r9,r9,4
20: 91 23 00 00 stw r9,0(r3)
24: 80 69 ff fc lwz r3,-4(r9)
28: 4e 80 00 20 blr
--
Summary: missed optimization for pointer access with offset on
powerpc
Product: gcc
Version: 4.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rbuergel at web dot de
GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: powerpc-linux-uclibc
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36693
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug rtl-optimization/36693] missed optimization for pointer access with offset on powerpc
2008-07-02 10:22 [Bug c/36693] New: missed optimization for pointer access with offset on powerpc rbuergel at web dot de
@ 2008-08-11 1:32 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-11 1:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2008-08-11 01:31 -------
Hmm, this works on the trunk with -O2 -mtune=cell which means this is a
scheduling issue:
[apinski@dhcp-10-98-10-216 ~]$ ~/gcc-mainline/bin/gcc -O2 -o - -S t.c
-mtune=cell
.file "t.c"
.section ".text"
.align 2
.p2align 3,,7
.globl get_and_increment1
.type get_and_increment1, @function
get_and_increment1:
lwz 9,0(3)
addi 0,9,4
stw 0,0(3)
lwz 3,0(9)
blr
.size get_and_increment1,.-get_and_increment1
.align 2
.p2align 3,,7
.globl get_and_increment2
.type get_and_increment2, @function
get_and_increment2:
lwz 9,0(3)
addi 0,9,4
stw 0,0(3)
lwz 3,0(9)
blr
.size get_and_increment2,.-get_and_increment2
.ident "GCC: (GNU) 4.4.0 20080810 (experimental) [trunk revision
138922]"
.section .note.GNU-stack,"",@progbits
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|tree-optimization |rtl-optimization
GCC host triplet|x86_64-pc-linux-gnu |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36693
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-08-11 1:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-02 10:22 [Bug c/36693] New: missed optimization for pointer access with offset on powerpc rbuergel at web dot de
2008-08-11 1:32 ` [Bug rtl-optimization/36693] " pinskia 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).