> Jan Hubicka <hubi...@ucw.cz> writes: > > > Hi, > > this is first of two patches for getting more realistic predictions of > > recursive functions. It is clear that in order for recursion to finish, the > > sum of frequencies of recursive calls should not exceed sum of frequencies > > of > > the function entry block. This global condition is however bit hard to > > achieve > > by local predictors. > > How would this handle tail recursion? > > In this case it may just be a funky way to write a loop, but not > predicting it as taken would be bad.
It predicts path leading to recursive call by 75% so the tail recursion loop would end up predicted to iterate 4 times that seems not too bad. Also we eliminate trivial cases of tail recursion before branch prediction. Honza > > -Andi