public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/19803] New: __builtin_expect doesnt modify branch prediction for power4 target
@ 2005-02-07 15:28 anton at samba dot org
2005-02-07 17:21 ` [Bug tree-optimization/19803] " amodra at bigpond dot net dot au
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: anton at samba dot org @ 2005-02-07 15:28 UTC (permalink / raw)
To: gcc-bugs
gcc version 4.0.0 20050203 (experimental)
The following code snippet shows how branch prediction isnt used even when
specifying builtin_expect. flags used: -O2 -mcpu=power4
#if 1
#define likely(x) __builtin_expect(!!(x), 1)
#else
#define likely(x) x
#endif
int i;
void foo(void)
{
while (likely(i--)) {
bar();
}
}
...
b .L2
.p2align 4,,15
.L3:
bl bar
nop
.L2:
lwz 9,0(31)
addi 9,9,-1
extsw 9,9
cmpwi 7,9,-1
stw 9,0(31)
bne 7,.L3
--
Summary: __builtin_expect doesnt modify branch prediction for
power4 target
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: anton at samba dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19803
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/19803] __builtin_expect doesnt modify branch prediction for power4 target
2005-02-07 15:28 [Bug tree-optimization/19803] New: __builtin_expect doesnt modify branch prediction for power4 target anton at samba dot org
@ 2005-02-07 17:21 ` amodra at bigpond dot net dot au
2005-02-07 17:21 ` [Bug target/19803] __builtin_expect does not modify branch prediction for power4/5 pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: amodra at bigpond dot net dot au @ 2005-02-07 17:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From amodra at bigpond dot net dot au 2005-02-07 03:28 -------
builtin_expect uses PROB_VERY_LIKELY.
>From predict.c
#define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 10 - 1)
#define PROB_EVEN (REG_BR_PROB_BASE / 2)
#define PROB_VERY_LIKELY (REG_BR_PROB_BASE - PROB_VERY_UNLIKELY)
#define PROB_ALWAYS (REG_BR_PROB_BASE)
In other words, builtin_expect is using 10% / 90%
But powerpc64 only emits branch prediction hints when at 2% / 98%. See
rs6000.c:output_cbranch
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-02-07 03:28:18
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19803
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/19803] __builtin_expect does not modify branch prediction for power4/5
2005-02-07 15:28 [Bug tree-optimization/19803] New: __builtin_expect doesnt modify branch prediction for power4 target anton at samba dot org
2005-02-07 17:21 ` [Bug tree-optimization/19803] " amodra at bigpond dot net dot au
@ 2005-02-07 17:21 ` pinskia at gcc dot gnu dot org
2005-02-07 17:25 ` amodra at bigpond dot net dot au
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-07 17:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-02-07 03:39 -------
(In reply to comment #1)
> builtin_expect uses PROB_VERY_LIKELY.
>
> But powerpc64 only emits branch prediction hints when at 2% / 98%. See
> rs6000.c:output_cbranch
This is a target problem as mentioned above.
Hmm, I thought there was a patch floating around to fix this but I could be wrong.
Also note this changed back in 2002 for power4:
<http://gcc.gnu.org/ml/gcc-patches/2002-08/msg00149.html> so in a way it could be considered a
regression.
It also effects power5 also (and ppc970).
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Component|tree-optimization |target
GCC target triplet|powerpc64-unknown-linux-gnu |powerpc*-*-*
Summary|__builtin_expect doesnt |__builtin_expect does not
|modify branch prediction for|modify branch prediction for
|power4 target |power4/5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19803
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/19803] __builtin_expect does not modify branch prediction for power4/5
2005-02-07 15:28 [Bug tree-optimization/19803] New: __builtin_expect doesnt modify branch prediction for power4 target anton at samba dot org
2005-02-07 17:21 ` [Bug tree-optimization/19803] " amodra at bigpond dot net dot au
2005-02-07 17:21 ` [Bug target/19803] __builtin_expect does not modify branch prediction for power4/5 pinskia at gcc dot gnu dot org
@ 2005-02-07 17:25 ` amodra at bigpond dot net dot au
2005-02-08 9:18 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: amodra at bigpond dot net dot au @ 2005-02-07 17:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From amodra at bigpond dot net dot au 2005-02-07 04:47 -------
patch http://gcc.gnu.org/ml/gcc-patches/2005-02/msg00225.html
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|enhancement |normal
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19803
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/19803] __builtin_expect does not modify branch prediction for power4/5
2005-02-07 15:28 [Bug tree-optimization/19803] New: __builtin_expect doesnt modify branch prediction for power4 target anton at samba dot org
` (2 preceding siblings ...)
2005-02-07 17:25 ` amodra at bigpond dot net dot au
@ 2005-02-08 9:18 ` cvs-commit at gcc dot gnu dot org
2005-02-08 9:19 ` cvs-commit at gcc dot gnu dot org
2005-02-08 9:25 ` amodra at bigpond dot net dot au
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-02-08 9:18 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-02-07 21:12 -------
Subject: Bug 19803
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: amodra@gcc.gnu.org 2005-02-07 21:11:45
Modified files:
gcc : ChangeLog predict.c
Log message:
PR target/19803
* predict.c (PROB_VERY_UNLIKELY): Use 1% instead of 10%.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7414&r2=2.7415
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/predict.c.diff?cvsroot=gcc&r1=1.137&r2=1.138
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19803
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/19803] __builtin_expect does not modify branch prediction for power4/5
2005-02-07 15:28 [Bug tree-optimization/19803] New: __builtin_expect doesnt modify branch prediction for power4 target anton at samba dot org
` (3 preceding siblings ...)
2005-02-08 9:18 ` cvs-commit at gcc dot gnu dot org
@ 2005-02-08 9:19 ` cvs-commit at gcc dot gnu dot org
2005-02-08 9:25 ` amodra at bigpond dot net dot au
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-02-08 9:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-02-07 21:18 -------
Subject: Bug 19803
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_4-branch
Changes by: amodra@gcc.gnu.org 2005-02-07 21:18:33
Modified files:
gcc : ChangeLog predict.c
Log message:
PR target/19803
* predict.c (PROB_VERY_UNLIKELY): Use 1% instead of 10%.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.794&r2=2.2326.2.795
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/predict.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.98&r2=1.98.2.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19803
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/19803] __builtin_expect does not modify branch prediction for power4/5
2005-02-07 15:28 [Bug tree-optimization/19803] New: __builtin_expect doesnt modify branch prediction for power4 target anton at samba dot org
` (4 preceding siblings ...)
2005-02-08 9:19 ` cvs-commit at gcc dot gnu dot org
@ 2005-02-08 9:25 ` amodra at bigpond dot net dot au
5 siblings, 0 replies; 7+ messages in thread
From: amodra at bigpond dot net dot au @ 2005-02-08 9:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From amodra at bigpond dot net dot au 2005-02-07 21:23 -------
Fixed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19803
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-02-07 21:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-07 15:28 [Bug tree-optimization/19803] New: __builtin_expect doesnt modify branch prediction for power4 target anton at samba dot org
2005-02-07 17:21 ` [Bug tree-optimization/19803] " amodra at bigpond dot net dot au
2005-02-07 17:21 ` [Bug target/19803] __builtin_expect does not modify branch prediction for power4/5 pinskia at gcc dot gnu dot org
2005-02-07 17:25 ` amodra at bigpond dot net dot au
2005-02-08 9:18 ` cvs-commit at gcc dot gnu dot org
2005-02-08 9:19 ` cvs-commit at gcc dot gnu dot org
2005-02-08 9:25 ` amodra at bigpond dot net dot au
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).