<div dir="ltr">Hello all,<div>  I am trying to get LLVM to optimize an indirect call to a branching control flow with a direct call and an indirect call.</div><div>What I mean is, transform this:</div><div>```</div><div><div><div>  %funcptr = select i1 %condition, void()* @known_function, void ()* %loaded_address</div><div>  %result = tail call void %funcptr()</div></div></div><div>```</div><div>into this:</div><div><div>```</div><div>  br i1 %condition, label %if.true, label %if.false</div><div>if.true:</div><div>  tail call void @ known_function()</div><div>  br label %if.end</div><div>if.false:<br></div><div>  tail call void %loaded_address()</div><div>  br label %if.end</div><div>if.end:<br></div></div><div>```</div><div><br></div><div>Can LLVM do this perhaps when I add metadata about probabilities of %condition being true or not, or is this not possible at all?</div><div><br></div><div>(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.)</div><div><br></div><div>Thanks,</div><div>  Johan</div><div><br></div></div>