ups0

did you emplement Constant Folding and another optimizations in this example


Re: Phoenix about LocalOpt Example

Andy Ayers - MSFT

If you dive into the local opt source, you'll see the folowing comment:

  optimizations available in the LocalOpt plug-in are:

    FoldConstant     constant folding
    DeadStore      dead store elimination
    DeadExpr       dead expression elimination
    ReduceStrength    simple strength reduction e.g. MUL X 4 -> SHL X 2

So yes, there is a version of constant folding.






Re: Phoenix about LocalOpt Example

ups0

Excuse me, Andy, but I can't find any optimization without SimpleBrunchInstr optimization in this localOptExample. Could you describe me where are constant folding optimization placed






Re: Phoenix about LocalOpt Example

Andy Ayers - MSFT

Look in dag.cs; you'll see a method called DAG.Fold, and within this method are statements like the following (dag.cs line 979):

Code Snippet

dstValue = Phx.Constant.Info.EvaluateBinary(ref result, instruction.Opcode,

instruction.ConditionCode, instruction.SourceOperand1.Type, srcValue[0], srcValue[1]);

Here the sample uses the constant package (that is, the code in Phx.Constant namespace) utility EvaluateBinary to actually perform the folding operation, based on the opcode, the types of the inputs, and the input operands. If the constant package is unable to fold then the return value is null. Otherwise the return value of EvaluateBinary is a Phx.Constant.Value that describes the folded result.






Re: Phoenix about LocalOpt Example

ups0

thank you, Andy.