[Bug middle-end/83023] branch probabilities pessimize malloc

2018-08-07 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83023

Martin Liška  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Martin Liška  ---
Implemented.

[Bug middle-end/83023] branch probabilities pessimize malloc

2018-08-07 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83023

--- Comment #4 from Martin Liška  ---
Author: marxin
Date: Tue Aug  7 11:59:13 2018
New Revision: 263355

URL: https://gcc.gnu.org/viewcvs?rev=263355=gcc=rev
Log:
Add malloc predictor (PR middle-end/83023).

2018-08-07  Martin Liska  

PR middle-end/83023
* predict.c (expr_expected_value_1): Handle DECL_IS_MALLOC,
BUILT_IN_REALLOC and DECL_IS_OPERATOR_NEW.
* predict.def (PRED_MALLOC_NONNULL): New predictor.
* doc/extend.texi: Document that malloc attribute adds
hit to compiler.
2018-08-07  Martin Liska  

PR middle-end/83023
* gcc.dg/predict-16.c: New test.
* g++.dg/predict-1.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/predict-1.C
trunk/gcc/testsuite/gcc.dg/predict-16.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/doc/extend.texi
trunk/gcc/predict.c
trunk/gcc/predict.def
trunk/gcc/testsuite/ChangeLog

[Bug middle-end/83023] branch probabilities pessimize malloc

2018-02-16 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83023

Martin Liška  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Target Milestone|--- |9.0

[Bug middle-end/83023] branch probabilities pessimize malloc

2017-11-19 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83023

Martin Liška  changed:

   What|Removed |Added

 CC|mliska at suse dot cz  |marxin at gcc dot 
gnu.org
   Assignee|unassigned at gcc dot gnu.org  |marxin at gcc dot 
gnu.org

--- Comment #3 from Martin Liška  ---
Thanks for report. That can be definitely improved.

[Bug middle-end/83023] branch probabilities pessimize malloc

2017-11-19 Thread hubicka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83023

Jan Hubicka  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-11-19
 CC||mliska at suse dot cz
 Ever confirmed|0   |1

--- Comment #2 from Jan Hubicka  ---
We get:

Predictions for bb 2
  DS theory heuristics: 53.5%   
  combined heuristics: 53.5%
  pointer (on trees) heuristics of edge 2->3: 70.0% 
  call heuristics of edge 2->3: 33.0%   

We do not know that malloc is likely returning non-NULL, but we predict with
70% that pointer is non-NULL but in the testcase this prediction is overwritten
with call heuristics.

builtin_expect code can be easily extended to handle builtins that likely
return given value. I am adding Martin to CC as this may be part of predictor
retuning this time.

[Bug middle-end/83023] branch probabilities pessimize malloc

2017-11-17 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83023

Richard Biener  changed:

   What|Removed |Added

 CC||hubicka at gcc dot gnu.org

--- Comment #1 from Richard Biener  ---
True!  I guess ptr != 0 should be differently predicted?  Usually it might
work because code is

 p = malloc ();
 if (!p)
   abort ();