|
|
|
@ -63,16 +63,19 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -63,16 +63,19 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
inst.Kind = ComparisonKind.Equality; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (inst.Right.MatchLdcI4(0) && inst.Sign == Sign.Unsigned |
|
|
|
|
&& (inst.Kind == ComparisonKind.GreaterThan || inst.Kind == ComparisonKind.LessThan)) |
|
|
|
|
var rightWithoutConv = inst.Right.UnwrapConv(ConversionKind.SignExtend).UnwrapConv(ConversionKind.ZeroExtend); |
|
|
|
|
if (rightWithoutConv.MatchLdcI4(0) |
|
|
|
|
&& inst.Sign == Sign.Unsigned |
|
|
|
|
&& (inst.Kind == ComparisonKind.GreaterThan || inst.Kind == ComparisonKind.LessThanOrEqual)) |
|
|
|
|
{ |
|
|
|
|
ILInstruction array; |
|
|
|
|
if (inst.Left.MatchLdLen(StackType.I, out array)) { |
|
|
|
|
// comp.unsigned(ldlen array > ldc.i4 0)
|
|
|
|
|
// comp.unsigned(ldlen array > conv i4->i(ldc.i4 0))
|
|
|
|
|
// => comp(ldlen.i4 array > ldc.i4 0)
|
|
|
|
|
// This is a special case where the C# compiler doesn't generate conv.i4 after ldlen.
|
|
|
|
|
inst.Left.ReplaceWith(new LdLen(StackType.I4, array) { ILRange = inst.Left.ILRange }); |
|
|
|
|
inst.InputType = StackType.I4; |
|
|
|
|
inst.Right = rightWithoutConv; |
|
|
|
|
} |
|
|
|
|
// comp.unsigned(left > ldc.i4 0) => comp(left != ldc.i4 0)
|
|
|
|
|
// comp.unsigned(left <= ldc.i4 0) => comp(left == ldc.i4 0)
|
|
|
|
|