This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/45631] devirtualization with profile feedback does not work for function pointers
- From: "hubicka at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 14 Dec 2010 23:52:49 +0000
- Subject: [Bug middle-end/45631] devirtualization with profile feedback does not work for function pointers
- Auto-submitted: auto-generated
- References: <bug-45631-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45631
--- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> 2010-12-14 23:52:45 UTC ---
I guess it is the simple algorithm we use to work out most common value.
We end up with
Trying transformations on stmt p_1(D) ();
Indirect call value:12 match:48 all:90.
The most common value profiler is implemented at:
/* Tries to determine the most common value among its inputs. Checks if the
value stored in COUNTERS[0] matches VALUE. If this is the case, COUNTERS[1]
is incremented. If this is not the case and COUNTERS[1] is not zero,
COUNTERS[1] is decremented. Otherwise COUNTERS[1] is set to one and
VALUE is stored to COUNTERS[0]. This algorithm guarantees that if this
function is called more than 50% of the time with one value, this value
will be in COUNTERS[0] in the end.
In any case, COUNTERS[2] is incremented. */
static inline void
__gcov_one_value_profiler_body (gcov_type *counters, gcov_type value)
{
if (value == counters[0])
counters[1]++;
else if (counters[1] == 0)
{
counters[1] = 1;
counters[0] = value;
}
else
counters[1]--;
counters[2]++;
}
So it stores value to counters[0] and then increases counters each time it sees
if. When we get to 0, we try the new value.
So the match is actually number of matches minus number of times it was
different.
It matches 3/4, it was different 1/4 of time and we get to 1/2 and that is not
enough for transformation to trigger.
Finally we require
if (4 * count <= 3 * all)
return false;
that is 4/3 > 1/2. I guess we can lower the threshold...