In some cases I get different result when:
1. My template contains code X and I have prefilter that converts code X to code Y
and when:
2. My template contains code Y and no prefilter
Why don't you apply prefilter right after you get content with getContent function? I think that in this case if you get code Y after prefilter you will get exactly the same result as if you had code Y initially and did not apply any prefilters.

To be more specific, I am trying to redefine function delcared in base template. For this I use blocks:
base template: {block a}{function a}code version 1{/function}{/block}
child template: {block a}{function a}code version 2{/function}{/block}
This works as I expect (function is redefined and outputs "code version 2" instead of "code version 1"). However, adding {block} to every function manually is inconvenient, so I have written prefilter that does this work (i.e. it adds block to every function definition). So now I have:
base template: {function a}code version 1{/function}
child template: {function a}code version 2{/function}
and prefilter adds blocks, so that the code after prefilters is the same as above. However, this does not work. So I get different result, though the code after applying prefilters is the same in both cases.

I'm currently out of office for a week and will look into it when I'm back.
But you may be right that {block} tags of inheritance are processed before the prefilter so you can't currently add {block} tags by the filter.

This problem will not occur in the upcomming major release of 3.2 as the internals of template inheritance have been completely rewritten.

I will try to implement a fix for 3.1 but that is not as easy as running the prefilters at the time of getContent. Because of the internals this would cause that the prefilters to run twice in other cases....