From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16132 invoked by alias); 6 Jul 2013 11:58:52 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 16107 invoked by uid 48); 6 Jul 2013 11:58:49 -0000 From: "amodra at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/57836] New: large constants evaluated inline Date: Sat, 06 Jul 2013 11:58:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: amodra at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-07/txt/msg00356.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57836 Bug ID: 57836 Summary: large constants evaluated inline Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: amodra at gmail dot com On powerpc64 with -mcmodel=small -O1, this int x; void f1 (long long hx) { if (hx < 0x3ff0000000000000LL) x++; } results in .L.f1: lis 9,0x3fef ori 9,9,65535 sldi 9,9,32 oris 9,9,0xffff ori 9,9,65535 cmpd 7,3,9 bgtlr 7 ld 9,.LC1@toc(2) lwz 10,0(9) addi 10,10,1 stw 10,0(9) blr The -mcmodel isn't significant, just there to make comparison with older compilers easy. Prior to gcc-4.5 we generated .L.f1: ld 0,.LC0@toc(2) cmpd 7,3,0 bgtlr 7 ld 9,.LC1@toc(2) lwz 11,0(9) addi 0,11,1 stw 0,0(9) blr Both pre- and post-4.5 compilers initially expand rtl using the constant load from toc, but 4.5 and later substitute the constant in the first cse pass. The problem stems from rtx cost for the load from toc being the same as the inline constant form. The costs are the same both pre- and post-4.5. The reason pre-4.5 does not substitute the constant is related to this comment is cse.c: /* Find cheapest and skip it for the next time. For items of equal cost, use this order: src_folded, src, src_eqv, src_related and hash table entry. */ Pre-4.5 src_folded is NULL, src is a mem, src_eqv the constant. Post-4.5 src_folded is the constant, src is a mem, src_eqv the constant again. Pre-4.5, rs6000.c lacked delegitimize_address. src_folded is set by fold_rtx, which calls equiv_constant, which calls avoid_constant_pool_reference, which calls targetm.delegitimize_address. When this is missing, we don't get to see the constant..