[LLVMdev] Failure to optimize ? operator
eli.friedman at gmail.com
Tue Dec 13 16:58:35 PST 2011
On Tue, Dec 13, 2011 at 5:59 AM, Brent Walker <brenthwalker at gmail.com> wrote:
> The following seemingly identical functions, get compiled to quite
> different machine code. The first is correctly optimized (the
> computation of var y is nicely moved into the else branch of the "if"
> statement), which the second one is not (the full computation of var y
> is always done). The output was produced using the demo page on
> llvm's web site (optimization level LTO).
> Can someone shed some light on this strange behavior?
The IR you're seeing is the IR we naturally generate for the given IR,
and LLVM doesn't have an optimization to turn your f2 into f1. Which
version is better depends on the values passed into the function,
which makes it a bit tricky to write an optimization to turn one into
More information about the llvm-dev