[llvm-dev] Optimize Indirect Call to direct call
Johan Engelen via llvm-dev
llvm-dev at lists.llvm.org
Thu Apr 7 04:47:54 PDT 2016
Hello all,
I am trying to get LLVM to optimize an indirect call to a branching
control flow with a direct call and an indirect call.
What I mean is, transform this:
```
%funcptr = select i1 %condition, void()* @known_function, void ()*
%loaded_address
%result = tail call void %funcptr()
```
into this:
```
br i1 %condition, label %if.true, label %if.false
if.true:
tail call void @ known_function()
br label %if.end
if.false:
tail call void %loaded_address()
br label %if.end
if.end:
```
Can LLVM do this perhaps when I add metadata about probabilities of
%condition being true or not, or is this not possible at all?
(The reason for my question is a virtual call optimization after profiling.
@known_function is simple and inlinable, which I think results in a faster
code path when %condition is almost always true. It is very similar to the
Indirect Call Promotion currently being implemented as PGO option.)
Thanks,
Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160407/331affce/attachment.html>
More information about the llvm-dev
mailing list