public void VpPhiWithConstants() { var c1 = Constant.Word16(0x4711); var c2 = Constant.Word16(0x4711); var r1 = m.Reg16("r1"); var r2 = m.Reg16("r2"); var r3 = m.Reg16("r3"); m.Assign(r1, c1); m.Assign(r2, c2); var phiStm = m.Phi(r3, (r1, "block1"), (r2, "block2")); RunValuePropagator(); Assert.AreEqual("r3 = 0x4711<16>", phiStm.Instruction.ToString()); }
public void SrtReg685() { var m = new SsaProcedureBuilder(nameof(SrtReg685)); var i_1 = m.Reg32("i_1"); var i_2 = m.Reg32("i_2"); var i_3 = m.Reg32("i_3"); m.Assign(i_1, m.Int32(0)); m.Label("m1"); m.Phi(i_2, i_1, i_3); m.SideEffect(m.Fn("foo", i_2)); m.SideEffect(m.Fn("foo", m.IAdd(i_2, 1))); m.Assign(i_3, m.IAdd(i_2, 2)); m.BranchIf(m.Eq(i_3, 10), "m1"); m.Label("m2"); m.Return(); var dom = m.Procedure.CreateBlockDominatorGraph(); var lif = new LinearInductionVariableFinder(m.Procedure, m.Ssa.Identifiers, dom); lif.Find(); Assert.AreEqual("(0 0x00000002 0x0000000C)", lif.InductionVariables[0].ToString()); var ctx = lif.Contexts[lif.InductionVariables[0]]; var str = new StrengthReduction(m.Ssa, lif.InductionVariables[0], ctx); str.ClassifyUses(); Assert.AreEqual(2, str.IncrementedUses.Count); str.ModifyUses(); }
public void Urb_Remove_many_blocks() { var m = new SsaProcedureBuilder(name: nameof(Urb_Remove_many_blocks)); var r1_1 = m.Reg32("r1_1"); var r1_2 = m.Reg32("r1_2"); var r1_3 = m.Reg32("r1_3"); var r1_4 = m.Reg32("r1_4"); var r2 = m.Reg32("r2"); m.AddDefToEntryBlock(r2); m.BranchIf(Constant.False(), "m2"); m.Label("m1"); m.Assign(r1_1, 1); m.Goto("m4"); m.Label("m2"); // dead code m.BranchIf(m.Eq0(r2), "m3"); m.Label("m2a"); m.Assign(r1_2, 2); m.Goto("m4"); m.Label("m3"); m.Assign(r1_3, 3); // end of dead code. m.Label("m4"); m.Phi(r1_4, (r1_1, "m1"), (r1_2, "m2a"), (r1_3, "m3")); m.Return(r1_4); var sExp = #region @"// Urb_Remove_many_blocks // Return size: 0 define Urb_Remove_many_blocks Urb_Remove_many_blocks_entry: def r2 // succ: l1 l1: // succ: m1 m1: r1_1 = 1<32> // succ: m4 m4: r1_4 = r1_1 return r1_4 // succ: Urb_Remove_many_blocks_exit Urb_Remove_many_blocks_exit: "; #endregion RunTest(sExp, m); }
public void Urb_Remove_false() { var m = new SsaProcedureBuilder(name: nameof(Urb_Remove_false)); var r1_1 = m.Reg32("r1_1"); var r1_2 = m.Reg32("r1_2"); var r1_3 = m.Reg32("r1_3"); m.BranchIf(Constant.False(), "m2"); m.Label("m1"); m.Assign(r1_1, 1); m.Goto("m3"); m.Label("m2"); // dead code m.Assign(r1_2, 2); m.Label("m3"); m.Phi(r1_3, (r1_1, "m1"), (r1_2, "m2")); m.Return(r1_3); var sExp = #region @"// Urb_Remove_false // Return size: 0 define Urb_Remove_false Urb_Remove_false_entry: // succ: l1 l1: // succ: m1 m1: r1_1 = 1<32> // succ: m3 m3: r1_3 = r1_1 return r1_3 // succ: Urb_Remove_false_exit Urb_Remove_false_exit: "; #endregion RunTest(sExp, m); }