From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1823 invoked by alias); 19 Aug 2004 14:59:21 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 1769 invoked by uid 9082); 19 Aug 2004 14:59:21 -0000 Date: Thu, 19 Aug 2004 14:59:00 -0000 From: "gcc-bugzilla at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20040819145911.17106.steinmtz@us.ibm.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug other/17106] New: Opportunity to eliminate loads from TOC. X-Bugzilla-Reason: CC X-SW-Source: 2004-08/txt/msg01929.txt.bz2 List-Id: 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