diff --git a/Source/Data/IR-Optimizations-BitValue.json b/Source/Data/IR-Optimizations-BitValue.json
index 772f4918f6..3e275e09d0 100644
--- a/Source/Data/IR-Optimizations-BitValue.json
+++ b/Source/Data/IR-Optimizations-BitValue.json
@@ -35,18 +35,18 @@
{
"Type": "BitValue",
"Name": "MulSigned##",
- "SubName": "NotSigned",
+ "SubName": "ButNotSigned",
"Expression": "IR.MulSigned## a b",
"Filter": "IsBitValueSignBitCleared##(a) && IsBitValueSignBitCleared##(b)",
"Result": "(IR.MulUnsigned## a b)",
"Priority": "20",
- "Variations": "Yes",
+ "Variations": "No",
"Log": "No"
},
{
"Type": "BitValue",
"Name": "RemSigned##",
- "SubName": "NotSigned",
+ "SubName": "ButNotSigned",
"Expression": "IR.RemSigned## a b",
"Filter": "IsBitValueSignBitCleared##(a) && IsBitValueSignBitCleared##(b)",
"Result": "(IR.RemUnsigned## a b)",
@@ -57,7 +57,7 @@
{
"Type": "BitValue",
"Name": "ArithShiftRight##",
- "SubName": "NotSigned",
+ "SubName": "ButNotSigned",
"Expression": "IR.ArithShiftRight## a b",
"Filter": "IsBitValueSignBitCleared##(a)",
"Result": "(IR.ShiftRight## a b)",
@@ -68,12 +68,18 @@
{
"Type": "BitValue",
"Name": "Compare##x32SignedLess",
- "SubName": "SignedLessAdd##",
+ "SubName": "Add##",
"Expression": "IR.Compare##x32 {<} (IR.Add## a c1) c2",
"Filter": "IsResolvedConstant(c1) && IsResolvedConstant(c2) && !IsAddOverflow##(BitValueMax##(a), BitValueMax##(c1))",
"Result": "(IR.Compare##x32 {<} a (IR.Sub## c2 c1))",
- "Variations": "No",
- "Log": "Yes"
+ "Variations": "Yes",
+ "Log": "Yes",
+ "Commutative": [
+ "IR.Compare32x32",
+ "IR.Compare32x64",
+ "IR.Compare64x32",
+ "IR.Compare64x64"
+ ]
},
{
"Type": "BitValue",
@@ -82,8 +88,14 @@
"Expression": "IR.Compare##x64 {<} (IR.Add## a c1) c2",
"Filter": "IsResolvedConstant(c1) && IsResolvedConstant(c2) && !IsAddOverflow##(BitValueMax##(a), BitValueMax##(c1))",
"Result": "(IR.Compare##x64 {<} a (IR.Sub## c2 c1))",
- "Variations": "No",
- "Log": "Yes"
+ "Variations": "Yes",
+ "Log": "Yes",
+ "Commutative": [
+ "IR.Compare32x32",
+ "IR.Compare32x64",
+ "IR.Compare64x32",
+ "IR.Compare64x64"
+ ]
},
{
"Type": "BitValue",
@@ -92,8 +104,14 @@
"Expression": "IR.Compare##x32 {< u} (IR.Add## a c1) c2",
"Filter": "IsResolvedConstant(c1) && IsResolvedConstant(c2) && !IsAddOverflow##(BitValueMax##(a), BitValueMax##(c1))",
"Result": "(IR.Compare##x32 {<} a (IR.Sub## c2 c1))",
- "Variations": "No",
- "Log": "Yes"
+ "Variations": "Yes",
+ "Log": "Yes",
+ "Commutative": [
+ "IR.Compare32x32",
+ "IR.Compare32x64",
+ "IR.Compare64x32",
+ "IR.Compare64x64"
+ ]
},
{
"Type": "BitValue",
@@ -102,8 +120,14 @@
"Expression": "IR.Compare##x64 {< u} (IR.Add## a c1) c2",
"Filter": "IsResolvedConstant(c1) && IsResolvedConstant(c2) && !IsAddOverflow##(BitValueMax##(a), BitValueMax##(c1))",
"Result": "(IR.Compare##x64 {<} a (IR.Sub## c2 c1))",
- "Variations": "No",
- "Log": "Yes"
+ "Variations": "Yes",
+ "Log": "Yes",
+ "Commutative": [
+ "IR.Compare32x32",
+ "IR.Compare32x64",
+ "IR.Compare64x32",
+ "IR.Compare64x64"
+ ]
}
]
}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/AutoTransforms.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/AutoTransforms.cs
index 1eda2b2664..4efa515ed3 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/AutoTransforms.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/AutoTransforms.cs
@@ -916,21 +916,27 @@ public static class AutoTransforms
new Useless.ZeroExtend16x64ZeroExtend32x64(),
new Useless.ZeroExtend32x64ZeroExtend8x64(),
new Useless.ZeroExtend32x64ZeroExtend16x64(),
- new BitValue.MulSigned32NotSigned(),
- new BitValue.MulSigned32NotSigned_v1(),
- new BitValue.MulSigned64NotSigned(),
- new BitValue.MulSigned64NotSigned_v1(),
- new BitValue.RemSigned32NotSigned(),
- new BitValue.RemSigned64NotSigned(),
- new BitValue.ArithShiftRight32NotSigned(),
- new BitValue.ArithShiftRight64NotSigned(),
- new BitValue.Compare32x32SignedLessSignedLessAdd32(),
- new BitValue.Compare64x32SignedLessSignedLessAdd64(),
+ new BitValue.MulSigned32ButNotSigned(),
+ new BitValue.MulSigned64ButNotSigned(),
+ new BitValue.RemSigned32ButNotSigned(),
+ new BitValue.RemSigned64ButNotSigned(),
+ new BitValue.ArithShiftRight32ButNotSigned(),
+ new BitValue.ArithShiftRight64ButNotSigned(),
+ new BitValue.Compare32x32SignedLessAdd32(),
+ new BitValue.Compare32x32SignedLessAdd32_v1(),
+ new BitValue.Compare64x32SignedLessAdd64(),
+ new BitValue.Compare64x32SignedLessAdd64_v1(),
new BitValue.Compare32x64SignedLessAdd32(),
+ new BitValue.Compare32x64SignedLessAdd32_v1(),
new BitValue.Compare64x64SignedLessAdd64(),
+ new BitValue.Compare64x64SignedLessAdd64_v1(),
new BitValue.Compare32x32UnsignedLessAdd32(),
+ new BitValue.Compare32x32UnsignedLessAdd32_v1(),
new BitValue.Compare64x32UnsignedLessAdd64(),
+ new BitValue.Compare64x32UnsignedLessAdd64_v1(),
new BitValue.Compare32x64UnsignedLessAdd32(),
+ new BitValue.Compare32x64UnsignedLessAdd32_v1(),
new BitValue.Compare64x64UnsignedLessAdd64(),
+ new BitValue.Compare64x64UnsignedLessAdd64_v1(),
};
}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight32NotSigned.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight32ButNotSigned.cs
similarity index 75%
rename from Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight32NotSigned.cs
rename to Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight32ButNotSigned.cs
index 2962431563..f688ec2a58 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight32NotSigned.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight32ButNotSigned.cs
@@ -5,12 +5,12 @@
namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
///
-/// ArithShiftRight32NotSigned
+/// ArithShiftRight32ButNotSigned
///
[Transform("IR.Optimizations.Auto.BitValue")]
-public sealed class ArithShiftRight32NotSigned : BaseTransform
+public sealed class ArithShiftRight32ButNotSigned : BaseTransform
{
- public ArithShiftRight32NotSigned() : base(IRInstruction.ArithShiftRight32, TransformType.Auto | TransformType.Optimization)
+ public ArithShiftRight32ButNotSigned() : base(IRInstruction.ArithShiftRight32, TransformType.Auto | TransformType.Optimization)
{
}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight64NotSigned.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight64ButNotSigned.cs
similarity index 75%
rename from Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight64NotSigned.cs
rename to Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight64ButNotSigned.cs
index e6c8552e11..f56be48655 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight64NotSigned.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/ArithShiftRight64ButNotSigned.cs
@@ -5,12 +5,12 @@
namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
///
-/// ArithShiftRight64NotSigned
+/// ArithShiftRight64ButNotSigned
///
[Transform("IR.Optimizations.Auto.BitValue")]
-public sealed class ArithShiftRight64NotSigned : BaseTransform
+public sealed class ArithShiftRight64ButNotSigned : BaseTransform
{
- public ArithShiftRight64NotSigned() : base(IRInstruction.ArithShiftRight64, TransformType.Auto | TransformType.Optimization)
+ public ArithShiftRight64ButNotSigned() : base(IRInstruction.ArithShiftRight64, TransformType.Auto | TransformType.Optimization)
{
}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x32SignedLessAdd32.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x32SignedLessAdd32.cs
new file mode 100644
index 0000000000..6f412ab52c
--- /dev/null
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x32SignedLessAdd32.cs
@@ -0,0 +1,107 @@
+// Copyright (c) MOSA Project. Licensed under the New BSD License.
+
+// This code was generated by an automated template.
+
+namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
+
+///
+/// Compare32x32SignedLessAdd32
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class Compare32x32SignedLessAdd32 : BaseTransform
+{
+ public Compare32x32SignedLessAdd32() : base(IRInstruction.Compare32x32, TransformType.Auto | TransformType.Optimization, true)
+ {
+ }
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (context.ConditionCode != ConditionCode.Less)
+ return false;
+
+ if (!context.Operand1.IsVirtualRegister)
+ return false;
+
+ if (!context.Operand1.IsDefinedOnce)
+ return false;
+
+ if (context.Operand1.Definitions[0].Instruction != IRInstruction.Add32)
+ return false;
+
+ if (!IsResolvedConstant(context.Operand1.Definitions[0].Operand2))
+ return false;
+
+ if (!IsResolvedConstant(context.Operand2))
+ return false;
+
+ if (IsAddOverflow32(BitValueMax32(context.Operand1.Definitions[0].Operand1), BitValueMax32(context.Operand1.Definitions[0].Operand2)))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1.Definitions[0].Operand1;
+ var t2 = context.Operand1.Definitions[0].Operand2;
+ var t3 = context.Operand2;
+
+ var v1 = transform.VirtualRegisters.Allocate32();
+
+ context.SetInstruction(IRInstruction.Sub32, v1, t3, t2);
+ context.AppendInstruction(IRInstruction.Compare32x32, ConditionCode.Less, result, t1, v1);
+ }
+}
+
+///
+/// Compare32x32SignedLessAdd32_v1
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class Compare32x32SignedLessAdd32_v1 : BaseTransform
+{
+ public Compare32x32SignedLessAdd32_v1() : base(IRInstruction.Compare32x32, TransformType.Auto | TransformType.Optimization, true)
+ {
+ }
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (context.ConditionCode != ConditionCode.Greater)
+ return false;
+
+ if (!context.Operand2.IsVirtualRegister)
+ return false;
+
+ if (!context.Operand2.IsDefinedOnce)
+ return false;
+
+ if (context.Operand2.Definitions[0].Instruction != IRInstruction.Add32)
+ return false;
+
+ if (!IsResolvedConstant(context.Operand2.Definitions[0].Operand2))
+ return false;
+
+ if (!IsResolvedConstant(context.Operand1))
+ return false;
+
+ if (IsAddOverflow32(BitValueMax32(context.Operand2.Definitions[0].Operand1), BitValueMax32(context.Operand2.Definitions[0].Operand2)))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1;
+ var t2 = context.Operand2.Definitions[0].Operand1;
+ var t3 = context.Operand2.Definitions[0].Operand2;
+
+ var v1 = transform.VirtualRegisters.Allocate32();
+
+ context.SetInstruction(IRInstruction.Sub32, v1, t1, t3);
+ context.AppendInstruction(IRInstruction.Compare32x32, ConditionCode.Less, result, t2, v1);
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x32SignedLessSignedLessAdd32.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x32SignedLessSignedLessAdd32.cs
deleted file mode 100644
index d928b74fdc..0000000000
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x32SignedLessSignedLessAdd32.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) MOSA Project. Licensed under the New BSD License.
-
-// This code was generated by an automated template.
-
-namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
-
-///
-/// Compare32x32SignedLessSignedLessAdd32
-///
-[Transform("IR.Optimizations.Auto.BitValue")]
-public sealed class Compare32x32SignedLessSignedLessAdd32 : BaseTransform
-{
- public Compare32x32SignedLessSignedLessAdd32() : base(IRInstruction.Compare32x32, TransformType.Auto | TransformType.Optimization, true)
- {
- }
-
- public override bool Match(Context context, Transform transform)
- {
- if (context.ConditionCode != ConditionCode.Less)
- return false;
-
- if (!context.Operand1.IsVirtualRegister)
- return false;
-
- if (!context.Operand1.IsDefinedOnce)
- return false;
-
- if (context.Operand1.Definitions[0].Instruction != IRInstruction.Add32)
- return false;
-
- if (!IsResolvedConstant(context.Operand1.Definitions[0].Operand2))
- return false;
-
- if (!IsResolvedConstant(context.Operand2))
- return false;
-
- if (IsAddOverflow32(BitValueMax32(context.Operand1.Definitions[0].Operand1), BitValueMax32(context.Operand1.Definitions[0].Operand2)))
- return false;
-
- return true;
- }
-
- public override void Transform(Context context, Transform transform)
- {
- var result = context.Result;
-
- var t1 = context.Operand1.Definitions[0].Operand1;
- var t2 = context.Operand1.Definitions[0].Operand2;
- var t3 = context.Operand2;
-
- var v1 = transform.VirtualRegisters.Allocate32();
-
- context.SetInstruction(IRInstruction.Sub32, v1, t3, t2);
- context.AppendInstruction(IRInstruction.Compare32x32, ConditionCode.Less, result, t1, v1);
- }
-}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x32UnsignedLessAdd32.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x32UnsignedLessAdd32.cs
index 119f9382ca..b97c0f97ce 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x32UnsignedLessAdd32.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x32UnsignedLessAdd32.cs
@@ -54,3 +54,54 @@ public override void Transform(Context context, Transform transform)
context.AppendInstruction(IRInstruction.Compare32x32, ConditionCode.Less, result, t1, v1);
}
}
+
+///
+/// Compare32x32UnsignedLessAdd32_v1
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class Compare32x32UnsignedLessAdd32_v1 : BaseTransform
+{
+ public Compare32x32UnsignedLessAdd32_v1() : base(IRInstruction.Compare32x32, TransformType.Auto | TransformType.Optimization, true)
+ {
+ }
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (context.ConditionCode != ConditionCode.UnsignedGreater)
+ return false;
+
+ if (!context.Operand2.IsVirtualRegister)
+ return false;
+
+ if (!context.Operand2.IsDefinedOnce)
+ return false;
+
+ if (context.Operand2.Definitions[0].Instruction != IRInstruction.Add32)
+ return false;
+
+ if (!IsResolvedConstant(context.Operand2.Definitions[0].Operand2))
+ return false;
+
+ if (!IsResolvedConstant(context.Operand1))
+ return false;
+
+ if (IsAddOverflow32(BitValueMax32(context.Operand2.Definitions[0].Operand1), BitValueMax32(context.Operand2.Definitions[0].Operand2)))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1;
+ var t2 = context.Operand2.Definitions[0].Operand1;
+ var t3 = context.Operand2.Definitions[0].Operand2;
+
+ var v1 = transform.VirtualRegisters.Allocate32();
+
+ context.SetInstruction(IRInstruction.Sub32, v1, t1, t3);
+ context.AppendInstruction(IRInstruction.Compare32x32, ConditionCode.Less, result, t2, v1);
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x64SignedLessAdd32.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x64SignedLessAdd32.cs
index bebe2879dd..8b69d44b1d 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x64SignedLessAdd32.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x64SignedLessAdd32.cs
@@ -54,3 +54,54 @@ public override void Transform(Context context, Transform transform)
context.AppendInstruction(IRInstruction.Compare32x64, ConditionCode.Less, result, t1, v1);
}
}
+
+///
+/// Compare32x64SignedLessAdd32_v1
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class Compare32x64SignedLessAdd32_v1 : BaseTransform
+{
+ public Compare32x64SignedLessAdd32_v1() : base(IRInstruction.Compare32x64, TransformType.Auto | TransformType.Optimization, true)
+ {
+ }
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (context.ConditionCode != ConditionCode.Greater)
+ return false;
+
+ if (!context.Operand2.IsVirtualRegister)
+ return false;
+
+ if (!context.Operand2.IsDefinedOnce)
+ return false;
+
+ if (context.Operand2.Definitions[0].Instruction != IRInstruction.Add32)
+ return false;
+
+ if (!IsResolvedConstant(context.Operand2.Definitions[0].Operand2))
+ return false;
+
+ if (!IsResolvedConstant(context.Operand1))
+ return false;
+
+ if (IsAddOverflow32(BitValueMax32(context.Operand2.Definitions[0].Operand1), BitValueMax32(context.Operand2.Definitions[0].Operand2)))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1;
+ var t2 = context.Operand2.Definitions[0].Operand1;
+ var t3 = context.Operand2.Definitions[0].Operand2;
+
+ var v1 = transform.VirtualRegisters.Allocate32();
+
+ context.SetInstruction(IRInstruction.Sub32, v1, t1, t3);
+ context.AppendInstruction(IRInstruction.Compare32x64, ConditionCode.Less, result, t2, v1);
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x64UnsignedLessAdd32.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x64UnsignedLessAdd32.cs
index d24ec5f9a9..253be1d0b2 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x64UnsignedLessAdd32.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare32x64UnsignedLessAdd32.cs
@@ -54,3 +54,54 @@ public override void Transform(Context context, Transform transform)
context.AppendInstruction(IRInstruction.Compare32x64, ConditionCode.Less, result, t1, v1);
}
}
+
+///
+/// Compare32x64UnsignedLessAdd32_v1
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class Compare32x64UnsignedLessAdd32_v1 : BaseTransform
+{
+ public Compare32x64UnsignedLessAdd32_v1() : base(IRInstruction.Compare32x64, TransformType.Auto | TransformType.Optimization, true)
+ {
+ }
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (context.ConditionCode != ConditionCode.UnsignedGreater)
+ return false;
+
+ if (!context.Operand2.IsVirtualRegister)
+ return false;
+
+ if (!context.Operand2.IsDefinedOnce)
+ return false;
+
+ if (context.Operand2.Definitions[0].Instruction != IRInstruction.Add32)
+ return false;
+
+ if (!IsResolvedConstant(context.Operand2.Definitions[0].Operand2))
+ return false;
+
+ if (!IsResolvedConstant(context.Operand1))
+ return false;
+
+ if (IsAddOverflow32(BitValueMax32(context.Operand2.Definitions[0].Operand1), BitValueMax32(context.Operand2.Definitions[0].Operand2)))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1;
+ var t2 = context.Operand2.Definitions[0].Operand1;
+ var t3 = context.Operand2.Definitions[0].Operand2;
+
+ var v1 = transform.VirtualRegisters.Allocate32();
+
+ context.SetInstruction(IRInstruction.Sub32, v1, t1, t3);
+ context.AppendInstruction(IRInstruction.Compare32x64, ConditionCode.Less, result, t2, v1);
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x32SignedLessAdd64.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x32SignedLessAdd64.cs
new file mode 100644
index 0000000000..cf1802331c
--- /dev/null
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x32SignedLessAdd64.cs
@@ -0,0 +1,107 @@
+// Copyright (c) MOSA Project. Licensed under the New BSD License.
+
+// This code was generated by an automated template.
+
+namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
+
+///
+/// Compare64x32SignedLessAdd64
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class Compare64x32SignedLessAdd64 : BaseTransform
+{
+ public Compare64x32SignedLessAdd64() : base(IRInstruction.Compare64x32, TransformType.Auto | TransformType.Optimization, true)
+ {
+ }
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (context.ConditionCode != ConditionCode.Less)
+ return false;
+
+ if (!context.Operand1.IsVirtualRegister)
+ return false;
+
+ if (!context.Operand1.IsDefinedOnce)
+ return false;
+
+ if (context.Operand1.Definitions[0].Instruction != IRInstruction.Add64)
+ return false;
+
+ if (!IsResolvedConstant(context.Operand1.Definitions[0].Operand2))
+ return false;
+
+ if (!IsResolvedConstant(context.Operand2))
+ return false;
+
+ if (IsAddOverflow64(BitValueMax64(context.Operand1.Definitions[0].Operand1), BitValueMax64(context.Operand1.Definitions[0].Operand2)))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1.Definitions[0].Operand1;
+ var t2 = context.Operand1.Definitions[0].Operand2;
+ var t3 = context.Operand2;
+
+ var v1 = transform.VirtualRegisters.Allocate64();
+
+ context.SetInstruction(IRInstruction.Sub64, v1, t3, t2);
+ context.AppendInstruction(IRInstruction.Compare64x32, ConditionCode.Less, result, t1, v1);
+ }
+}
+
+///
+/// Compare64x32SignedLessAdd64_v1
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class Compare64x32SignedLessAdd64_v1 : BaseTransform
+{
+ public Compare64x32SignedLessAdd64_v1() : base(IRInstruction.Compare64x32, TransformType.Auto | TransformType.Optimization, true)
+ {
+ }
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (context.ConditionCode != ConditionCode.Greater)
+ return false;
+
+ if (!context.Operand2.IsVirtualRegister)
+ return false;
+
+ if (!context.Operand2.IsDefinedOnce)
+ return false;
+
+ if (context.Operand2.Definitions[0].Instruction != IRInstruction.Add64)
+ return false;
+
+ if (!IsResolvedConstant(context.Operand2.Definitions[0].Operand2))
+ return false;
+
+ if (!IsResolvedConstant(context.Operand1))
+ return false;
+
+ if (IsAddOverflow64(BitValueMax64(context.Operand2.Definitions[0].Operand1), BitValueMax64(context.Operand2.Definitions[0].Operand2)))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1;
+ var t2 = context.Operand2.Definitions[0].Operand1;
+ var t3 = context.Operand2.Definitions[0].Operand2;
+
+ var v1 = transform.VirtualRegisters.Allocate64();
+
+ context.SetInstruction(IRInstruction.Sub64, v1, t1, t3);
+ context.AppendInstruction(IRInstruction.Compare64x32, ConditionCode.Less, result, t2, v1);
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x32SignedLessSignedLessAdd64.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x32SignedLessSignedLessAdd64.cs
deleted file mode 100644
index f356c976c1..0000000000
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x32SignedLessSignedLessAdd64.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) MOSA Project. Licensed under the New BSD License.
-
-// This code was generated by an automated template.
-
-namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
-
-///
-/// Compare64x32SignedLessSignedLessAdd64
-///
-[Transform("IR.Optimizations.Auto.BitValue")]
-public sealed class Compare64x32SignedLessSignedLessAdd64 : BaseTransform
-{
- public Compare64x32SignedLessSignedLessAdd64() : base(IRInstruction.Compare64x32, TransformType.Auto | TransformType.Optimization, true)
- {
- }
-
- public override bool Match(Context context, Transform transform)
- {
- if (context.ConditionCode != ConditionCode.Less)
- return false;
-
- if (!context.Operand1.IsVirtualRegister)
- return false;
-
- if (!context.Operand1.IsDefinedOnce)
- return false;
-
- if (context.Operand1.Definitions[0].Instruction != IRInstruction.Add64)
- return false;
-
- if (!IsResolvedConstant(context.Operand1.Definitions[0].Operand2))
- return false;
-
- if (!IsResolvedConstant(context.Operand2))
- return false;
-
- if (IsAddOverflow64(BitValueMax64(context.Operand1.Definitions[0].Operand1), BitValueMax64(context.Operand1.Definitions[0].Operand2)))
- return false;
-
- return true;
- }
-
- public override void Transform(Context context, Transform transform)
- {
- var result = context.Result;
-
- var t1 = context.Operand1.Definitions[0].Operand1;
- var t2 = context.Operand1.Definitions[0].Operand2;
- var t3 = context.Operand2;
-
- var v1 = transform.VirtualRegisters.Allocate64();
-
- context.SetInstruction(IRInstruction.Sub64, v1, t3, t2);
- context.AppendInstruction(IRInstruction.Compare64x32, ConditionCode.Less, result, t1, v1);
- }
-}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x32UnsignedLessAdd64.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x32UnsignedLessAdd64.cs
index 48d0cd2f88..15304f265b 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x32UnsignedLessAdd64.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x32UnsignedLessAdd64.cs
@@ -54,3 +54,54 @@ public override void Transform(Context context, Transform transform)
context.AppendInstruction(IRInstruction.Compare64x32, ConditionCode.Less, result, t1, v1);
}
}
+
+///
+/// Compare64x32UnsignedLessAdd64_v1
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class Compare64x32UnsignedLessAdd64_v1 : BaseTransform
+{
+ public Compare64x32UnsignedLessAdd64_v1() : base(IRInstruction.Compare64x32, TransformType.Auto | TransformType.Optimization, true)
+ {
+ }
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (context.ConditionCode != ConditionCode.UnsignedGreater)
+ return false;
+
+ if (!context.Operand2.IsVirtualRegister)
+ return false;
+
+ if (!context.Operand2.IsDefinedOnce)
+ return false;
+
+ if (context.Operand2.Definitions[0].Instruction != IRInstruction.Add64)
+ return false;
+
+ if (!IsResolvedConstant(context.Operand2.Definitions[0].Operand2))
+ return false;
+
+ if (!IsResolvedConstant(context.Operand1))
+ return false;
+
+ if (IsAddOverflow64(BitValueMax64(context.Operand2.Definitions[0].Operand1), BitValueMax64(context.Operand2.Definitions[0].Operand2)))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1;
+ var t2 = context.Operand2.Definitions[0].Operand1;
+ var t3 = context.Operand2.Definitions[0].Operand2;
+
+ var v1 = transform.VirtualRegisters.Allocate64();
+
+ context.SetInstruction(IRInstruction.Sub64, v1, t1, t3);
+ context.AppendInstruction(IRInstruction.Compare64x32, ConditionCode.Less, result, t2, v1);
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x64SignedLessAdd64.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x64SignedLessAdd64.cs
index 8ae7ce046d..09cab9de15 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x64SignedLessAdd64.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x64SignedLessAdd64.cs
@@ -54,3 +54,54 @@ public override void Transform(Context context, Transform transform)
context.AppendInstruction(IRInstruction.Compare64x64, ConditionCode.Less, result, t1, v1);
}
}
+
+///
+/// Compare64x64SignedLessAdd64_v1
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class Compare64x64SignedLessAdd64_v1 : BaseTransform
+{
+ public Compare64x64SignedLessAdd64_v1() : base(IRInstruction.Compare64x64, TransformType.Auto | TransformType.Optimization, true)
+ {
+ }
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (context.ConditionCode != ConditionCode.Greater)
+ return false;
+
+ if (!context.Operand2.IsVirtualRegister)
+ return false;
+
+ if (!context.Operand2.IsDefinedOnce)
+ return false;
+
+ if (context.Operand2.Definitions[0].Instruction != IRInstruction.Add64)
+ return false;
+
+ if (!IsResolvedConstant(context.Operand2.Definitions[0].Operand2))
+ return false;
+
+ if (!IsResolvedConstant(context.Operand1))
+ return false;
+
+ if (IsAddOverflow64(BitValueMax64(context.Operand2.Definitions[0].Operand1), BitValueMax64(context.Operand2.Definitions[0].Operand2)))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1;
+ var t2 = context.Operand2.Definitions[0].Operand1;
+ var t3 = context.Operand2.Definitions[0].Operand2;
+
+ var v1 = transform.VirtualRegisters.Allocate64();
+
+ context.SetInstruction(IRInstruction.Sub64, v1, t1, t3);
+ context.AppendInstruction(IRInstruction.Compare64x64, ConditionCode.Less, result, t2, v1);
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x64UnsignedLessAdd64.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x64UnsignedLessAdd64.cs
index 4b4323f5f8..15f33d3ba4 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x64UnsignedLessAdd64.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/Compare64x64UnsignedLessAdd64.cs
@@ -54,3 +54,54 @@ public override void Transform(Context context, Transform transform)
context.AppendInstruction(IRInstruction.Compare64x64, ConditionCode.Less, result, t1, v1);
}
}
+
+///
+/// Compare64x64UnsignedLessAdd64_v1
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class Compare64x64UnsignedLessAdd64_v1 : BaseTransform
+{
+ public Compare64x64UnsignedLessAdd64_v1() : base(IRInstruction.Compare64x64, TransformType.Auto | TransformType.Optimization, true)
+ {
+ }
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (context.ConditionCode != ConditionCode.UnsignedGreater)
+ return false;
+
+ if (!context.Operand2.IsVirtualRegister)
+ return false;
+
+ if (!context.Operand2.IsDefinedOnce)
+ return false;
+
+ if (context.Operand2.Definitions[0].Instruction != IRInstruction.Add64)
+ return false;
+
+ if (!IsResolvedConstant(context.Operand2.Definitions[0].Operand2))
+ return false;
+
+ if (!IsResolvedConstant(context.Operand1))
+ return false;
+
+ if (IsAddOverflow64(BitValueMax64(context.Operand2.Definitions[0].Operand1), BitValueMax64(context.Operand2.Definitions[0].Operand2)))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1;
+ var t2 = context.Operand2.Definitions[0].Operand1;
+ var t3 = context.Operand2.Definitions[0].Operand2;
+
+ var v1 = transform.VirtualRegisters.Allocate64();
+
+ context.SetInstruction(IRInstruction.Sub64, v1, t1, t3);
+ context.AppendInstruction(IRInstruction.Compare64x64, ConditionCode.Less, result, t2, v1);
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned32ButNotSigned.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned32ButNotSigned.cs
new file mode 100644
index 0000000000..018c984c51
--- /dev/null
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned32ButNotSigned.cs
@@ -0,0 +1,39 @@
+// Copyright (c) MOSA Project. Licensed under the New BSD License.
+
+// This code was generated by an automated template.
+
+namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
+
+///
+/// MulSigned32ButNotSigned
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class MulSigned32ButNotSigned : BaseTransform
+{
+ public MulSigned32ButNotSigned() : base(IRInstruction.MulSigned32, TransformType.Auto | TransformType.Optimization)
+ {
+ }
+
+ public override int Priority => 20;
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (!IsBitValueSignBitCleared32(context.Operand1))
+ return false;
+
+ if (!IsBitValueSignBitCleared32(context.Operand2))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1;
+ var t2 = context.Operand2;
+
+ context.SetInstruction(IRInstruction.MulUnsigned32, result, t1, t2);
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned32NotSigned.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned32NotSigned.cs
deleted file mode 100644
index 3b86384b1a..0000000000
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned32NotSigned.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) MOSA Project. Licensed under the New BSD License.
-
-// This code was generated by an automated template.
-
-namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
-
-///
-/// MulSigned32NotSigned
-///
-[Transform("IR.Optimizations.Auto.BitValue")]
-public sealed class MulSigned32NotSigned : BaseTransform
-{
- public MulSigned32NotSigned() : base(IRInstruction.MulSigned32, TransformType.Auto | TransformType.Optimization)
- {
- }
-
- public override int Priority => 20;
-
- public override bool Match(Context context, Transform transform)
- {
- if (!IsBitValueSignBitCleared32(context.Operand1))
- return false;
-
- if (!IsBitValueSignBitCleared32(context.Operand2))
- return false;
-
- return true;
- }
-
- public override void Transform(Context context, Transform transform)
- {
- var result = context.Result;
-
- var t1 = context.Operand1;
- var t2 = context.Operand2;
-
- context.SetInstruction(IRInstruction.MulUnsigned32, result, t1, t2);
- }
-}
-
-///
-/// MulSigned32NotSigned_v1
-///
-[Transform("IR.Optimizations.Auto.BitValue")]
-public sealed class MulSigned32NotSigned_v1 : BaseTransform
-{
- public MulSigned32NotSigned_v1() : base(IRInstruction.MulSigned32, TransformType.Auto | TransformType.Optimization)
- {
- }
-
- public override int Priority => 20;
-
- public override bool Match(Context context, Transform transform)
- {
- if (!IsBitValueSignBitCleared32(context.Operand2))
- return false;
-
- if (!IsBitValueSignBitCleared32(context.Operand1))
- return false;
-
- return true;
- }
-
- public override void Transform(Context context, Transform transform)
- {
- var result = context.Result;
-
- var t1 = context.Operand1;
- var t2 = context.Operand2;
-
- context.SetInstruction(IRInstruction.MulUnsigned32, result, t2, t1);
- }
-}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned64ButNotSigned.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned64ButNotSigned.cs
new file mode 100644
index 0000000000..30756ec8ea
--- /dev/null
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned64ButNotSigned.cs
@@ -0,0 +1,39 @@
+// Copyright (c) MOSA Project. Licensed under the New BSD License.
+
+// This code was generated by an automated template.
+
+namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
+
+///
+/// MulSigned64ButNotSigned
+///
+[Transform("IR.Optimizations.Auto.BitValue")]
+public sealed class MulSigned64ButNotSigned : BaseTransform
+{
+ public MulSigned64ButNotSigned() : base(IRInstruction.MulSigned64, TransformType.Auto | TransformType.Optimization)
+ {
+ }
+
+ public override int Priority => 20;
+
+ public override bool Match(Context context, Transform transform)
+ {
+ if (!IsBitValueSignBitCleared64(context.Operand1))
+ return false;
+
+ if (!IsBitValueSignBitCleared64(context.Operand2))
+ return false;
+
+ return true;
+ }
+
+ public override void Transform(Context context, Transform transform)
+ {
+ var result = context.Result;
+
+ var t1 = context.Operand1;
+ var t2 = context.Operand2;
+
+ context.SetInstruction(IRInstruction.MulUnsigned64, result, t1, t2);
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned64NotSigned.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned64NotSigned.cs
deleted file mode 100644
index e76fe2643d..0000000000
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/MulSigned64NotSigned.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) MOSA Project. Licensed under the New BSD License.
-
-// This code was generated by an automated template.
-
-namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
-
-///
-/// MulSigned64NotSigned
-///
-[Transform("IR.Optimizations.Auto.BitValue")]
-public sealed class MulSigned64NotSigned : BaseTransform
-{
- public MulSigned64NotSigned() : base(IRInstruction.MulSigned64, TransformType.Auto | TransformType.Optimization)
- {
- }
-
- public override int Priority => 20;
-
- public override bool Match(Context context, Transform transform)
- {
- if (!IsBitValueSignBitCleared64(context.Operand1))
- return false;
-
- if (!IsBitValueSignBitCleared64(context.Operand2))
- return false;
-
- return true;
- }
-
- public override void Transform(Context context, Transform transform)
- {
- var result = context.Result;
-
- var t1 = context.Operand1;
- var t2 = context.Operand2;
-
- context.SetInstruction(IRInstruction.MulUnsigned64, result, t1, t2);
- }
-}
-
-///
-/// MulSigned64NotSigned_v1
-///
-[Transform("IR.Optimizations.Auto.BitValue")]
-public sealed class MulSigned64NotSigned_v1 : BaseTransform
-{
- public MulSigned64NotSigned_v1() : base(IRInstruction.MulSigned64, TransformType.Auto | TransformType.Optimization)
- {
- }
-
- public override int Priority => 20;
-
- public override bool Match(Context context, Transform transform)
- {
- if (!IsBitValueSignBitCleared64(context.Operand2))
- return false;
-
- if (!IsBitValueSignBitCleared64(context.Operand1))
- return false;
-
- return true;
- }
-
- public override void Transform(Context context, Transform transform)
- {
- var result = context.Result;
-
- var t1 = context.Operand1;
- var t2 = context.Operand2;
-
- context.SetInstruction(IRInstruction.MulUnsigned64, result, t2, t1);
- }
-}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned32NotSigned.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned32ButNotSigned.cs
similarity index 79%
rename from Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned32NotSigned.cs
rename to Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned32ButNotSigned.cs
index ddb6718f8d..920e66f723 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned32NotSigned.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned32ButNotSigned.cs
@@ -5,12 +5,12 @@
namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
///
-/// RemSigned32NotSigned
+/// RemSigned32ButNotSigned
///
[Transform("IR.Optimizations.Auto.BitValue")]
-public sealed class RemSigned32NotSigned : BaseTransform
+public sealed class RemSigned32ButNotSigned : BaseTransform
{
- public RemSigned32NotSigned() : base(IRInstruction.RemSigned32, TransformType.Auto | TransformType.Optimization)
+ public RemSigned32ButNotSigned() : base(IRInstruction.RemSigned32, TransformType.Auto | TransformType.Optimization)
{
}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned64NotSigned.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned64ButNotSigned.cs
similarity index 79%
rename from Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned64NotSigned.cs
rename to Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned64ButNotSigned.cs
index 536a1a26a1..c4c2a0c96c 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned64NotSigned.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Auto/BitValue/RemSigned64ButNotSigned.cs
@@ -5,12 +5,12 @@
namespace Mosa.Compiler.Framework.Transforms.Optimizations.Auto.BitValue;
///
-/// RemSigned64NotSigned
+/// RemSigned64ButNotSigned
///
[Transform("IR.Optimizations.Auto.BitValue")]
-public sealed class RemSigned64NotSigned : BaseTransform
+public sealed class RemSigned64ButNotSigned : BaseTransform
{
- public RemSigned64NotSigned() : base(IRInstruction.RemSigned64, TransformType.Auto | TransformType.Optimization)
+ public RemSigned64ButNotSigned() : base(IRInstruction.RemSigned64, TransformType.Auto | TransformType.Optimization)
{
}
diff --git a/Source/Mosa.Utility.SourceCodeGenerator/BuildTransformations.cs b/Source/Mosa.Utility.SourceCodeGenerator/BuildTransformations.cs
index 48da5ba0d3..b60ce3d56f 100644
--- a/Source/Mosa.Utility.SourceCodeGenerator/BuildTransformations.cs
+++ b/Source/Mosa.Utility.SourceCodeGenerator/BuildTransformations.cs
@@ -34,7 +34,7 @@ protected override void Iterator()
{
if (Entries.Commutative != null)
{
- foreach (string instruction in Entries.Commutative)
+ foreach (var instruction in Entries.Commutative)
{
CommutativeInstructions.Add(instruction);
}
@@ -75,24 +75,38 @@ protected override void Body(dynamic node = null)
if (!optimization && !transformation)
optimization = true;
- GenerateTranformations(name, Family, type, subName, expression, filter, prefilter, result, variations, log, optimization, priority);
+ List commutativeInstructions = null;
+
+ if (node.Commutative != null)
+ {
+ commutativeInstructions = new List();
+ foreach (var instruction in node.Commutative)
+ {
+ commutativeInstructions.Add(instruction);
+ }
+ }
+
+ if (commutativeInstructions == null)
+ commutativeInstructions = CommutativeInstructions;
+
+ GenerateTranformations(name, Family, type, subName, expression, filter, prefilter, result, variations, log, optimization, priority, commutativeInstructions);
}
- private void GenerateTranformations(string name, string familyName, string type, string subName, string expression, string filter, string prefilter, string result, bool variations, bool log, bool optimization, int priority)
+ private void GenerateTranformations(string name, string familyName, string type, string subName, string expression, string filter, string prefilter, string result, bool variations, bool log, bool optimization, int priority, List commutativeInstructions)
{
if (expression.Contains("R#"))
{
- GenerateTransformation(R4(name), R4(familyName), R4(type), R4(subName), new Transformation(R4(expression), R4(filter), R4(result), prefilter), variations, log, optimization, priority);
- GenerateTransformation(R8(name), R8(familyName), R8(type), R8(subName), new Transformation(R8(expression), R8(filter), R8(result), prefilter), variations, log, optimization, priority);
+ GenerateTransformation(R4(name), R4(familyName), R4(type), R4(subName), new Transformation(R4(expression), R4(filter), R4(result), prefilter), variations, log, optimization, priority, commutativeInstructions);
+ GenerateTransformation(R8(name), R8(familyName), R8(type), R8(subName), new Transformation(R8(expression), R8(filter), R8(result), prefilter), variations, log, optimization, priority, commutativeInstructions);
}
else if (expression.Contains("##"))
{
- GenerateTransformation(To32(name), To32(familyName), To32(type), To32(subName), new Transformation(To32(expression), To32(filter), To32(result), prefilter), variations, log, optimization, priority);
- GenerateTransformation(To64(name), To64(familyName), To64(type), To64(subName), new Transformation(To64(expression), To64(filter), To64(result), prefilter), variations, log, optimization, priority);
+ GenerateTransformation(To32(name), To32(familyName), To32(type), To32(subName), new Transformation(To32(expression), To32(filter), To32(result), prefilter), variations, log, optimization, priority, commutativeInstructions);
+ GenerateTransformation(To64(name), To64(familyName), To64(type), To64(subName), new Transformation(To64(expression), To64(filter), To64(result), prefilter), variations, log, optimization, priority, commutativeInstructions);
}
else
{
- GenerateTransformation(name, familyName, type, subName, new Transformation(expression, filter, result, prefilter), variations, log, optimization, priority);
+ GenerateTransformation(name, familyName, type, subName, new Transformation(expression, filter, result, prefilter), variations, log, optimization, priority, commutativeInstructions);
}
}
@@ -116,7 +130,7 @@ private static string R8(string s)
return s?.Replace("R#", "R8");
}
- private void GenerateTransformation(string name, string familyName, string type, string subName, Transformation transform, bool Variations, bool log, bool optimization, int priority)
+ private void GenerateTransformation(string name, string familyName, string type, string subName, Transformation transform, bool Variations, bool log, bool optimization, int priority, List commutativeInstructions)
{
Lines.Clear();
First = true;
@@ -135,22 +149,22 @@ private void GenerateTransformation(string name, string familyName, string type,
Lines.AppendLine($"namespace {Path}.Transforms.Optimizations.Auto.{type};");
Lines.AppendLine();
- GenerateTransformations(name, familyName, type, subName, transform, Variations, log, optimization, priority);
+ GenerateTransformations(name, familyName, type, subName, transform, Variations, log, optimization, priority, commutativeInstructions);
Save();
}
- private void GenerateTransformations(string name, string familyName, string type, string subName, Transformation transform, bool variations, bool log, bool optimization, int priority)
+ private void GenerateTransformations(string name, string familyName, string type, string subName, Transformation transform, bool variations, bool log, bool optimization, int priority, List commutativeInstructions)
{
GenerateTransformation2(name, familyName, type, subName, transform, log, optimization, priority);
if (!variations)
return;
- if (CommutativeInstructions == null || CommutativeInstructions.Count == 0)
+ if (commutativeInstructions == null || commutativeInstructions.Count == 0)
return;
- var derivedVariations = transform.DeriveVariations(CommutativeInstructions);
+ var derivedVariations = transform.DeriveVariations(commutativeInstructions);
var index = 1;
foreach (var variation in derivedVariations)