This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/40887] GCC generates suboptimal code for indirect function calls on ARM
- From: "siarhei dot siamashka at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Dec 2009 08:27:13 -0000
- Subject: [Bug middle-end/40887] GCC generates suboptimal code for indirect function calls on ARM
- References: <bug-40887-17992@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from siarhei dot siamashka at gmail dot com 2009-12-21 08:27 -------
Created an attachment (id=19356)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19356&action=view)
return-address-prediction-bench.c
This looks like a really serious performance issue. Not just indirect call
alone is penalized, but the whole return address prediction stack is busted,
causing return address mispredictions for all the nested calls. The attached
test program demonstrates it.
$ time ./return-address-prediction-bench 1
Indirect call for the topmost function
real 0m0.793s
user 0m0.789s
sys 0m0.000s
$ time ./return-address-prediction-bench
Indirect call for the leaf function
real 0m1.797s
user 0m1.789s
sys 0m0.008s
gcc 4.4.2, "-O2 -mcpu=cortex-a8"
Change of function pointer type "void (*f)()" -> "void (* volatile f)()" can be
also used to "workaround" the problem. In this case execution times for both
variants of test are approximately the same.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40887