public virtual void ProcessScc(IList <SsaIdentifier> scc) { if (scc.Count <= 1) { return; } ctx = new LinearInductionVariableContext(); PhiFunction?phi = FindPhiFunction(scc); if (phi == null) { return; } ctx.DeltaValue = FindLinearIncrement(scc); if (ctx.DeltaValue == null) { return; } ctx.InitialValue = FindInitialValue(phi); ctx.TestValue = FindFinalValue(scc); LinearInductionVariable?iv = CreateInductionVariable(); if (iv != null) { foreach (SsaIdentifier sid in scc) { sid.InductionVariable = iv; } ivs.Add(iv); contexts.Add(iv, ctx); } }
public StrengthReduction(SsaState ssa, LinearInductionVariable liv, LinearInductionVariableContext ctx) { this.ssa = ssa; this.liv = liv; this.ctx = ctx; incrUses = new List <IncrementedUse>(); }
public StrengthReduction(SsaState ssa, LinearInductionVariable liv, LinearInductionVariableContext ctx) { this.ssa = ssa; this.liv = liv; this.ctx = ctx; incrUses = new List<IncrementedUse>(); }
public LinearInductionVariableFinder(SsaState ssa, BlockDominatorGraph doms) { this.ssa = ssa; this.doms = doms; this.ctx = new LinearInductionVariableContext(); this.ivs = new List <LinearInductionVariable>(); this.contexts = new Dictionary <LinearInductionVariable, LinearInductionVariableContext>(); }
public LinearInductionVariableFinder(Procedure proc, SsaIdentifierCollection ssaIds, BlockDominatorGraph doms) { this.proc = proc; this.ssaIds = ssaIds; this.doms = doms; this.ctx = new LinearInductionVariableContext(); this.ivs = new List <LinearInductionVariable>(); this.contexts = new Dictionary <LinearInductionVariable, LinearInductionVariableContext>(); }
private void ModifyTest(LinearInductionVariableContext ctx, IncrementedUse use) { if (ctx.TestStatement == null) { return; } if (ctx.TestStatement.Instruction is Branch branch && branch.Condition is BinaryExpression exp && exp.Right is Constant c) { exp.Right = Operator.ISub.ApplyConstants(c, use.Increment); } }
private void ModifyTest(LinearInductionVariableContext ctx, IncrementedUse use) { if (ctx.TestStatement == null) return; Branch branch; BinaryExpression exp ; Constant c ; if (ctx.TestStatement.Instruction.As(out branch) && branch.Condition.As(out exp) && exp.Right.As(out c)) { exp.Right = Operator.ISub.ApplyConstants(c, use.Increment); } }