[PATCH] D106426: [FuncSpec] Support specialising recursive functions

Chuanqi Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 26 18:39:11 PDT 2021


ChuanqiXu added a comment.

In D106426#2903857 <https://reviews.llvm.org/D106426#2903857>, @SjoerdMeijer wrote:

> I am looking into this now, but now that we have cleared up the problem in previous messages, a.k.a are on the same page how things work for recursive function, I think we need to discuss how the cost-model changes would look like. Because in this example the numbers are arbitrary and a rationale is missing:
>
>> I guess I would be happy if recursiveFunc  would get specialized less than 4 times even when we set  func-specialization-max-iters to 100.
>
> Why 4 times? In other words, what is the metric here? Is that code-size or something else?

4 times is an arbitrary number. I thought the best would be 1 time only. But I worried if it is too strict. So I said 4 times. Now I think we should be more strict. So I think it would better to specialize it only 1 time.

> how things work for recursive function, I think we need to discuss how the cost-model changes would look like

I think we need to handle recursive function specially. Since it is common that recursive function f  and its specialized one f' have the same cost and bonus. We need to record the function specialized (and specialized argument). Then we need to specialize a function (for specific argument) we had specialized, we could forbid it or give it a much higher penalty. The detail is missing. But the key point is that we need to handle recursive function specially instead of tuning or refactoring the cost model.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106426/new/

https://reviews.llvm.org/D106426



More information about the llvm-commits mailing list