This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/40887] GCC generates suboptimal code for indirect function calls on ARM



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]