public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/57836] New: large constants evaluated inline
@ 2013-07-06 11:58 amodra at gmail dot com
  2013-11-09 22:25 ` [Bug target/57836] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: amodra at gmail dot com @ 2013-07-06 11:58 UTC (permalink / raw)
  To: gcc-bugs

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..


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

end of thread, other threads:[~2020-04-01 23:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-06 11:58 [Bug target/57836] New: large constants evaluated inline amodra at gmail dot com
2013-11-09 22:25 ` [Bug target/57836] " pinskia at gcc dot gnu.org
2014-05-12  6:38 ` amodra at gmail dot com
2014-05-15  0:14 ` dje at gcc dot gnu.org
2015-04-22 11:59 ` jakub at gcc dot gnu.org
2015-07-16  9:16 ` rguenth at gcc dot gnu.org
2020-04-01 23:17 ` amodra at gmail dot com

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).