This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/17106] New: Opportunity to eliminate loads from TOC.
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Aug 2004 14:59:21 -0000
- Subject: [Bug other/17106] New: Opportunity to eliminate loads from TOC.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Description:
A non-optimal code sequence is illustraded. Duplicate using gcc 3.5 and
command line:
gcc -O3 -m64 -c test.c
Testcase:
static int s1, s2, s3;
void no_common_toc1 ()
{
s1 = 1;
s2 = 2;
s3 = 3;
}
Assembly:
The code generated by gcc 3.5 contains loads the address from the TOC for
each
target location:
.no_common_toc1:
ld 11,.LC0@toc(2)
li 0,1
li 9,2
ld 8,.LC2@toc(2)
ld 10,.LC1@toc(2)
stw 0,0(11)
li 0,3
stw 9,0(10)
stw 0,0(8)
blr
A single load of the base of the TOC is all that is needed:
.no_common_toc1:
ld 11,.LC0@toc(2)
li 0,1
li 9,2
stw 0,0(11)
li 0,3
stw 9,4(11)
stw 0,8(11)
blr
--
Summary: Opportunity to eliminate loads from TOC.
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P1
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: steinmtz at us dot ibm dot com
CC: gcc-bugs at gcc dot gnu dot org,steinmtz at us dot ibm
dot com
GCC build triplet: powerpc64-linux
GCC host triplet: powerpc64-linux
GCC target triplet: powerpc64-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17106