[LLVMdev] missed optimizations

Andrew Lenharth andrewl at lenharth.org
Tue Sep 16 12:12:10 PDT 2008


On Tue, Sep 16, 2008 at 1:59 PM, Nuno Lopes <nunoplopes at sapo.pt> wrote:
> Hi,
> This kind of transformation isn't currently done by LLVM (note that here
> this pass is only removing case statements. other transformations are not of
> my responsibility :).
> The patch is available at
> http://web.ist.utl.pt/nuno.lopes/llvm_function_ret_infer.txt
> I would love to ear some feedback, so that this pass can eventually be
> merged to the LLVM tree. In particular I'm not sure if there's a better way
> to track the possible return values of each function (e.g. is there any code
> that I can reuse?)

AnalyzeFunction can use BB->getTerminator() rather than iterating over
all instructions to find the terminator.

After you Analyze all the functions, why not just iterator on the uses
of the functions you found you could transform rather than on ever
instruction in the module?

It seems you should be able to handle any comparison with a constant
by using the min or max of your set as appropriate to the cmp.

Andrew



More information about the llvm-dev mailing list