public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Vincent Diepeveen <diep@xs4all.nl>, David Brown <david@westcontrol.com>
Cc: Xinrong Fu <fxinrong@gmail.com>, gcc-help@gcc.gnu.org
Subject: Re: Why is the performance of 32bit program worse than 64bit program running on the same 64bit system, They are compiled from same source. Which gcc option can fix it?
Date: Wed, 26 Mar 2014 14:07:00 -0000	[thread overview]
Message-ID: <5332A2E7.4080607@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1403251616160.8531@xs8.xs4all.nl>

On 03/25/2014 04:51 PM, Vincent Diepeveen wrote:

> a) for example if you use signed 32 bits indexation, for example
>
> int i, array[64];
>
> i = ...;
> x = array[i];
>
> this goes very fast in 32 bits processor and 32 bits mode yet a lot
> slower in 64 bits mode, as i needs a sign extension to 64 bits.
> So the compiler generates 1 additional instruction in 64 bits mode
> to sign extend i from 32 bits to 64 bits.

Is this relevant in practice?  I'm asking because it's a missed 
optimization opportunity—negative subscripts lead to undefined behavior 
here, so the sign extension can be omitted.

> b) some processors can 'issue' more 32 bits instructions a clock than 64
> bits instructions.

Some earlier processors also support more µop optimization in 32 bit mode.

> My chessprogram Diep which is deterministic integer code (so no vector
> codes) compiled 32 bits versus 64 bits is about 10%-12% slower in 64
> bits than in 32 bits. This where it does use a few 64 bits datatypes
> (very little though). In 64 bits the datasize used doesn't grow,
> instruction wise it grows immense of course.

Well, chess programs used to be the prototypical example for 64 bit 
architectures ...

> Besides the above reasons another reason why 32 bits programs compiled
> 64 bits can be a lot slower in case of Diep is:
>
> c) the larger code size causes more L1 instruction cache misses.

This really depends on the code.  Not everything is larger.  Typically 
it's the increased pointer size that cause increased data cache misses, 
which then casues slowdowns.

-- 
Florian Weimer / Red Hat Product Security Team

  reply	other threads:[~2014-03-26  9:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-25  8:33 Xinrong Fu
2014-03-25 10:10 ` Andrew Haley
2014-03-25 10:12 ` David Brown
2014-03-25 15:51   ` Jonathan Wakely
2014-03-25 19:38   ` Vincent Diepeveen
2014-03-26 14:07     ` Florian Weimer [this message]
2014-03-26 14:47       ` Vincent Diepeveen
2014-03-27 18:02         ` Xinrong Fu

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=5332A2E7.4080607@redhat.com \
    --to=fweimer@redhat.com \
    --cc=david@westcontrol.com \
    --cc=diep@xs4all.nl \
    --cc=fxinrong@gmail.com \
    --cc=gcc-help@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).