[llvm-commits] [PATCH] Teach IRBuilder about simplifying BinOp(Value, Constant)

Török Edwin edwintorok at gmail.com
Tue Dec 30 08:08:18 PST 2008


On 2008-12-29 19:43, Török Edwin wrote:
> Will submit a new patch later.
>   

Here is the new patch, noteworthy changes:
- simplifications implemented in ConstantFolder (default on)
- except for the find-identical-instruction simplification, which is
default off, configurable via template parameter
- for binops there is now only CreateBinOp in constantfolder/nofolder
- NoFolder now simply returns 0 for binops, and lets IRBuilder create
the binary operator, and insert it
(I wonder how it ever worked before, without inserting the instruction
it created?)
- TargetFolder is derived from ConstantFolder now, to reuse the
simplifications
- new variants of ConstantFoldInstruction/ConstantFoldInstOperands that
do these simplifications also
- it first tries to simplify, and if it fails then search for already
existing instruction (if enabled)
- try to comply more with LLVM coding style

Some thoughts, if you agree I'll make these changes too
- copy+paste in createadd/createsub, etc. is obvious, I could just make
them call this->CreateBinOp, and let
the compiler constant-propagate, and inline expand
- I also attached instcombine-trivial.ll which confirms that instcombine
does these optimizations, should I add it to test/Transforms/InstCombine?

What do you think of my patch now?

Best regards,
--Edwin


-------------- next part --------------
A non-text attachment was scrubbed...
Name: simplifier2.patch
Type: text/x-diff
Size: 30515 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20081230/df04dade/attachment.patch>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: instcombine-trivial.ll
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20081230/df04dade/attachment.ksh>


More information about the llvm-commits mailing list