public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Edelsohn <dje@watson.ibm.com>
To: Roger Sayle <roger@www.eyesopen.com>
Cc: Zack Weinberg <zack@codesourcery.com>, gcc@gcc.gnu.org
Subject: Re: Strange conditional jumps on the POWER4
Date: Sun, 06 Apr 2003 15:14:00 -0000	[thread overview]
Message-ID: <200304060439.XAA31116@makai.watson.ibm.com> (raw)
In-Reply-To: Message from Roger Sayle <roger@www.eyesopen.com>  of "Sat, 05 Apr 2003 14:38:03 MST." <Pine.LNX.4.44.0304051355450.14942-100000@www.eyesopen.com>

>>>>> Roger Sayle writes:

Roger> So it looks as though the problem is not a register stall, or scheduling
Roger> problem but with branch prediction and basic block re-ordering.  If
Roger> you're lucky and the compiler gets the branch probabilities right,
Roger> and you always branch the same way it can be done in 300 ticks.  If
Roger> you're unlucky, the compiler gets the probabilities wrong and you
Roger> alternate taken/not-taken it takes 1200 ticks.

	Newer PowerPC processors switched to using a different encoding of
branch hints.  GCC for AIX currently does not enable the assembler mode to
map the mnemonics to the new hint bits, so Power4 always uses its internal
branch prediction, even if the +/- is present.  The Power4 processor is
predicting the branch correctly.

	I suspect the problem is the branch to branch.  Power4 has a one
cycle latency between branches.  In the faster code, the conditional
branch is not taken, we overwrite the register (hidden by renaming) and we
fallthru to the branch on counter.  For the slower code, we don't
overwrite the regiser, but the conditional branch is taken jumping to the
branch on counter.  The branch on counter is held off one cycle, leading
to the performance degradation.

David

  parent reply	other threads:[~2003-04-06  4:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-05 21:26 Roger Sayle
2003-04-06  1:42 ` Zack Weinberg
2003-04-06  1:59   ` Roger Sayle
2003-04-06  3:33     ` David Edelsohn
2003-04-06  5:21       ` Roger Sayle
2003-04-06 16:49         ` Segher Boessenkool
2003-04-07 23:03           ` David Edelsohn
2003-04-06 15:14     ` David Edelsohn [this message]
     [not found] <200304080131.VAA30506@makai.watson.ibm.com>
2003-04-08 15:50 ` Roger Sayle

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=200304060439.XAA31116@makai.watson.ibm.com \
    --to=dje@watson.ibm.com \
    --cc=gcc@gcc.gnu.org \
    --cc=roger@www.eyesopen.com \
    --cc=zack@codesourcery.com \
    /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).