* [Bug c++/66584] gcc differs in static, branch-prediction cost from icc in switch.
2015-06-18 10:16 [Bug c++/66584] New: gcc differs in static, branch-prediction cost from icc in switch jmcguiness at liquidcapital dot com
@ 2015-06-18 14:24 ` ebotcazou at gcc dot gnu.org
2015-06-18 14:44 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2015-06-18 14:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66584
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2015-06-18
CC| |ebotcazou at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
What would you like us to document exactly? How are we supposed to track the
evolution of ICC over time? Why not simply ask ICC to change its heuristics?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/66584] gcc differs in static, branch-prediction cost from icc in switch.
2015-06-18 10:16 [Bug c++/66584] New: gcc differs in static, branch-prediction cost from icc in switch jmcguiness at liquidcapital dot com
2015-06-18 14:24 ` [Bug c++/66584] " ebotcazou at gcc dot gnu.org
@ 2015-06-18 14:44 ` pinskia at gcc dot gnu.org
2015-06-18 15:23 ` jmcguiness at liquidcapital dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-06-18 14:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66584
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
More than that, documenting gcc's branch heuristics is just in the code. And
you can see it what gcc figures out via debug dumps. It is also harder to
document this due to different things. For an example if your case 2 contained
a call to call function, it would change gcc's choices too.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/66584] gcc differs in static, branch-prediction cost from icc in switch.
2015-06-18 10:16 [Bug c++/66584] New: gcc differs in static, branch-prediction cost from icc in switch jmcguiness at liquidcapital dot com
2015-06-18 14:24 ` [Bug c++/66584] " ebotcazou at gcc dot gnu.org
2015-06-18 14:44 ` pinskia at gcc dot gnu.org
@ 2015-06-18 15:23 ` jmcguiness at liquidcapital dot com
2015-06-18 15:33 ` jmcguiness at liquidcapital dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jmcguiness at liquidcapital dot com @ 2015-06-18 15:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66584
--- Comment #4 from Jason McG <jmcguiness at liquidcapital dot com> ---
(In reply to Eric Botcazou from comment #2)
> What would you like us to document exactly? How are we supposed to track
...
Perhaps I was unclear. I am asking that you point out to me in the gcc
documentation where it comments regarding code generation for
switch-statements, and that it might make clear that the lexographic "top-down"
approach nor the default label are preferred but other, more complex heuristics
are used that defeat static branch-prediction analysis. I do not think this is
unreasonable. So I disagree entirely that this is invalid.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/66584] gcc differs in static, branch-prediction cost from icc in switch.
2015-06-18 10:16 [Bug c++/66584] New: gcc differs in static, branch-prediction cost from icc in switch jmcguiness at liquidcapital dot com
` (2 preceding siblings ...)
2015-06-18 15:23 ` jmcguiness at liquidcapital dot com
@ 2015-06-18 15:33 ` jmcguiness at liquidcapital dot com
2015-06-18 15:46 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jmcguiness at liquidcapital dot com @ 2015-06-18 15:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66584
Jason McG <jmcguiness at liquidcapital dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |---
--- Comment #5 from Jason McG <jmcguiness at liquidcapital dot com> ---
(In reply to Andrew Pinski from comment #3)
> More than that, documenting gcc's branch heuristics is just in the code. And
...
I am sorry, but I do not agree. As per my other reply, in comment 4, I think it
is entirely reasonable to request that an additional statement along the lines
of "code generation for switch statements may not follow a top-down approach
nor prefer the default case (if it exists) in terms of static
branch-prediction. The __builtin_expected() intrinsic has no effect" is
included in the web-based documentation in a suitable sub-section. If some
algorithm were used, then adding a link to the web site to the appropriate
paper might be a quick remedy?
This would ensure that developers are not mislead by the argument that
__builtin_expected() takes thinking they could use that, nor would they be
mislead by lore assuming that the default or a lexographic top-down approach to
static branch-prediction were used.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/66584] gcc differs in static, branch-prediction cost from icc in switch.
2015-06-18 10:16 [Bug c++/66584] New: gcc differs in static, branch-prediction cost from icc in switch jmcguiness at liquidcapital dot com
` (3 preceding siblings ...)
2015-06-18 15:33 ` jmcguiness at liquidcapital dot com
@ 2015-06-18 15:46 ` pinskia at gcc dot gnu.org
2015-06-18 16:25 ` jmcguiness at liquidcapital dot com
2015-06-18 16:27 ` jmcguiness at liquidcapital dot com
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-06-18 15:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66584
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
If someone cares so much about the static branch predictor, they would be a
compiler developer. This is the first time I have seen a non-compiler developer
care about documenting gcc heuristics. Note there is no one paper. Also if
branches are 50/50, the decision can change based on adding another statement
and is hard to document otherwise.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/66584] gcc differs in static, branch-prediction cost from icc in switch.
2015-06-18 10:16 [Bug c++/66584] New: gcc differs in static, branch-prediction cost from icc in switch jmcguiness at liquidcapital dot com
` (4 preceding siblings ...)
2015-06-18 15:46 ` pinskia at gcc dot gnu.org
@ 2015-06-18 16:25 ` jmcguiness at liquidcapital dot com
2015-06-18 16:27 ` jmcguiness at liquidcapital dot com
6 siblings, 0 replies; 8+ messages in thread
From: jmcguiness at liquidcapital dot com @ 2015-06-18 16:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66584
--- Comment #7 from Jason McG <jmcguiness at liquidcapital dot com> ---
(In reply to Andrew Pinski from comment #6)
> If someone cares so much about the static branch predictor, they would be a
...
I am not a compiler developer and I do care about this in the code I work upon.
I occasionally have switch statements that I statically know have a more
commonly used case label (e.g. could be made the default) that static
branch-prediction would reduce the cost of calling. It would have saved me some
time if the documentation I was requesting were present in a more accessible
form that writing test code & reviewing the assembler that gcc generates.
Aside: I have read
https://ols.fedoraproject.org/GCC/Reprints-2008/sayle-reprint.pdf and no-where
does this article describe, apart from in passing, the effect of mis-predicted
branches that using static branch-prediction could avoid by clearly
implementing a "preferred branch" e.g. the default upon their cost models. If I
had time I'd research this, unfortunately I do not.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/66584] gcc differs in static, branch-prediction cost from icc in switch.
2015-06-18 10:16 [Bug c++/66584] New: gcc differs in static, branch-prediction cost from icc in switch jmcguiness at liquidcapital dot com
` (5 preceding siblings ...)
2015-06-18 16:25 ` jmcguiness at liquidcapital dot com
@ 2015-06-18 16:27 ` jmcguiness at liquidcapital dot com
6 siblings, 0 replies; 8+ messages in thread
From: jmcguiness at liquidcapital dot com @ 2015-06-18 16:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66584
--- Comment #8 from Jason McG <jmcguiness at liquidcapital dot com> ---
(In reply to Andrew Pinski from comment #6)
...
> compiler developer. This is the first time I have seen a non-compiler
> developer care about documenting gcc heuristics. Note there is no one paper.
...
See comment 5. The documentation I am proposing is pretty trivial, I repeat:
"code generation for switch statements may not follow a top-down approach nor
prefer the default case (if it exists) in terms of static branch-prediction.
The __builtin_expected() intrinsic has no effect". I find it had to understand
how that documentation could be considered contentious.
^ permalink raw reply [flat|nested] 8+ messages in thread