Johan Engelen via llvm-dev
2016-Apr-07 11:47 UTC
[llvm-dev] Optimize Indirect Call to direct call
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>