public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/34027] [4.3 regression] -Os code size nearly doubled
Date: Thu, 08 Nov 2007 21:45:00 -0000	[thread overview]
Message-ID: <20071108214530.30361.qmail@sourceware.org> (raw)
In-Reply-To: <bug-34027-9876@http.gcc.gnu.org/bugzilla/>



------- Comment #1 from rguenth at gcc dot gnu dot org  2007-11-08 21:45 -------
Confirmed.

Also, on 64bit x86_64 we don't see that this computes the modulus, but do

foobar:
.LFB2:  
        movl    $1000000000, %esi
        movq    %rdi, %rax
        xorl    %edx, %edx
        divq    %rsi
        imulq   $-1000000000, %rax, %rax
        addq    %rdi, %rax
        ret

for

unsigned long long foobar(unsigned long long ns)
{
  return ns % 1000000000L;
}

we produce instead

foobar2:
.LFB3:  
        movl    $1000000000, %edx
        movq    %rdi, %rax
        movq    %rdx, %rcx
        xorl    %edx, %edx
        divq    %rcx
        movq    %rdx, %rax
        ret

which is smaller and faster.  Likewise the 32bit variant:

foobar2:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        pushl   $0
        pushl   $1000000000
        pushl   12(%ebp)
        pushl   8(%ebp)
        call    __umoddi3
        addl    $16, %esp
        leave
        ret

which would make this argument moot (ok, only by cheating ;)).  The problem
is supposedly that we don't fold

(chrec_apply
  (varying_loop = 1
)
  (chrec = {ns_2(D), +, 0x0ffffffffc4653600}_1)
  (x = ns_2(D) /[fl] 1000000000)
  (res = ns_2(D) + (ns_2(D) /[fl] 1000000000) * 0x0ffffffffc4653600))

which is ns_2 - (ns_2 / 1000000000) * 1000000000.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
  BugsThisDependsOn|                            |32044
             Status|UNCONFIRMED                 |NEW
          Component|c                           |tree-optimization
     Ever Confirmed|0                           |1
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2007-11-08 21:45:30
               date|                            |
   Target Milestone|---                         |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34027


  reply	other threads:[~2007-11-08 21:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-08 11:39 [Bug c/34027] New: " bunk at stusta dot de
2007-11-08 21:45 ` rguenth at gcc dot gnu dot org [this message]
2007-11-09 12:15 ` [Bug tree-optimization/34027] " jakub at gcc dot gnu dot org
2007-11-09 12:20 ` rguenther at suse dot de
2007-11-09 12:30 ` jakub at gcc dot gnu dot org
2007-11-09 12:37 ` rguenther at suse dot de
2007-11-10  7:58 ` bunk at stusta dot de
2007-11-10 23:54 ` rguenth at gcc dot gnu dot org
2007-11-12 13:24 ` rguenth at gcc dot gnu dot org
2007-11-12 13:28 ` rguenth at gcc dot gnu dot org
2007-11-12 15:01 ` rguenth at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071108214530.30361.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).