Browse Source

Add expression transform for (unsigned)x > 0 -> (unsigned)x != 0

pull/728/head
Siegfried Pammer 9 years ago
parent
commit
01c3721c33
  1. 11
      ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs

11
ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs

@ -52,6 +52,17 @@ namespace ICSharpCode.Decompiler.IL.Transforms
// => logic.not(ceq(left, ldnull)) // => logic.not(ceq(left, ldnull))
inst.ReplaceWith(new LogicNot(new Ceq(inst.Left, inst.Right) { ILRange = inst.ILRange })); inst.ReplaceWith(new LogicNot(new Ceq(inst.Left, inst.Right) { ILRange = inst.ILRange }));
} }
if (inst.Right.MatchLdcI4(0)) {
// cgt.un(left, ldc.i4 0)
// => logic.not(ceq(left, ldc.i4 0))
ILInstruction array;
if (inst.Left.MatchLdLen(StackType.I, out array)) {
// cgt.un(ldlen array, ldc.i4 0)
// => logic.not(ceq(ldlen.i4 array, ldc.i4 0))
inst.Left.ReplaceWith(new LdLen(StackType.I4, array) { ILRange = inst.Left.ILRange });
}
inst.ReplaceWith(new LogicNot(new Ceq(inst.Left, inst.Right) { ILRange = inst.ILRange }));
}
} }
protected internal override void VisitClt_Un(Clt_Un inst) protected internal override void VisitClt_Un(Clt_Un inst)

Loading…
Cancel
Save