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

To"ro"k Edwin edwintorok at gmail.com
Mon Dec 29 04:17:14 PST 2008


On 2008-12-29 13:07, Duncan Sands wrote:
> Hi Edwin,
>
>   

Hi Duncan,

>> The attached patch adds another template parameter (that defaults to a
>> no-op implementation) to simplify BinOps where one operand is constant.
>>     
>
> I think this approach makes a fairly artificial distinction between
> constant folding when all operands are constant and constant folding
> when some operands are constant.  How about only having a simplifier:
> it would do what the folder does now if all operands are constant,
> and otherwise do the simplifications that your patch added.

We now have a NoopFolder, ConstantFolder, and TargetFolder.

Should the simplifications be part of ConstantFolder, or should there be
a 4th "folder" like this:
NoopFolder, ConstantFolder, SimplifyingConstantFolder (derived from
ConstantFolder), TargetFolder (derived from SimplifyingConstantFolder)?

I'd prefer the former, perhaps by  using ConstantFoldInstruction in
ConstantFolder.

>   For that
> matter, how about adding your simplifications to ConstantFoldInstruction,
> and have that do the work for the not-all-constant case.
>   

Yes, that looks like a good place. Can I then just make ConstantFolder
use ConstantFoldInstruction?

Best regards,
--Edwin



More information about the llvm-commits mailing list