public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110499] New: malloc branch predictor is broken
@ 2023-06-30 13:53 hubicka at gcc dot gnu.org
2023-07-01 20:53 ` [Bug tree-optimization/110499] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: hubicka at gcc dot gnu.org @ 2023-06-30 13:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110499
Bug ID: 110499
Summary: malloc branch predictor is broken
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: hubicka at gcc dot gnu.org
Target Milestone: ---
Malloc branch predictor currently predicts that malloc() call likely returns 1.
This is good for NULL pointer checks, but not good for checking pointers for
equality:
#include <malloc.h>
void
test()
{
if (malloc(10) == malloc(20))
printf ("Impossible!\n");
}
gets predicted as:
void test ()
{
void * _1;
void * _2;
<bb 2> [local count: 1073741824]:
_1 = malloc (10);
_2 = malloc (20);
if (_1 == _2)
goto <bb 3>; [99.96%]
else
goto <bb 4>; [0.04%]
<bb 3> [local count: 1073312329]:
__builtin_puts (&"Impossible!"[0]);
<bb 4> [local count: 1073741824]:
return;
}
So we think that Impossible is output with 99.96 probability.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/110499] malloc branch predictor is broken
2023-06-30 13:53 [Bug tree-optimization/110499] New: malloc branch predictor is broken hubicka at gcc dot gnu.org
@ 2023-07-01 20:53 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-01 20:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110499
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2023-07-01
Keywords| |missed-optimization
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-01 20:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 13:53 [Bug tree-optimization/110499] New: malloc branch predictor is broken hubicka at gcc dot gnu.org
2023-07-01 20:53 ` [Bug tree-optimization/110499] " pinskia at gcc dot gnu.org
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).