diff --git a/src/tests/JIT/opt/InstructionCombining/Add.cs b/src/tests/JIT/opt/InstructionCombining/Add.cs
new file mode 100644
index 00000000000000..0ac13412879c94
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Add.cs
@@ -0,0 +1,215 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+namespace TestAdd
+{
+ public class Program
+ {
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ [Fact]
+ public static int CheckAdd()
+ {
+ bool fail = false;
+
+ if (Add(1, 2) != 3)
+ {
+ fail = true;
+ }
+
+ if (AddLSL(5, 5) != 85)
+ {
+ fail = true;
+ }
+
+ if (AddLSLSwap(5, 5) != 85)
+ {
+ fail = true;
+ }
+
+ if (AddLSR(1, 0x20000000) != 2)
+ {
+ fail = true;
+ }
+
+ if (AddASR(-2, 0x4000) != -1)
+ {
+ fail = true;
+ }
+
+ if (AddLargeShift(0x100000, 1) != 0x900000)
+ {
+ fail = true;
+ }
+
+ if (AddLargeShift64Bit(0xAB, 0x19a0000000000) != 0x178)
+ {
+ fail = true;
+ }
+
+ if (Adds(-5, 5) != 1)
+ {
+ fail = true;
+ }
+
+ if (AddsLSL(-0x78000, 0xF) != 1)
+ {
+ fail = true;
+ }
+
+ if (AddsLSLSwap(-0x78000, 0xF) != 1)
+ {
+ fail = true;
+ }
+
+ if (AddsLSR(0, 0x3c0) != 1)
+ {
+ fail = true;
+ }
+
+ if (AddsASR(-1, 0x800) != 1)
+ {
+ fail = true;
+ }
+
+ if (AddsLargeShift(-0xFF, 0x1fe0) != 1)
+ {
+ fail = true;
+ }
+
+ if (AddsLargeShift64Bit(-0x40000000000, 1) != 1)
+ {
+ fail = true;
+ }
+
+ if (fail)
+ {
+ return 101;
+ }
+ return 100;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int Add(int a, int b)
+ {
+ //ARM64-FULL-LINE: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
+ return a + b;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AddLSL(int a, int b)
+ {
+ //ARM64-FULL-LINE: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #4
+ return a + (b<<4);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AddLSLSwap(int a, int b)
+ {
+ //ARM64-FULL-LINE: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #4
+ return (b<<4) + a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static uint AddLSR(uint a, uint b)
+ {
+ //ARM64-FULL-LINE: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSR #29
+ return a + (b>>29);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AddASR(int a, int b)
+ {
+ //ARM64-FULL-LINE: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, ASR #14
+ return a + (b>>14);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AddLargeShift(int a, int b)
+ {
+ //ARM64-FULL-LINE: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #23
+ return a + (b<<183);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static long AddLargeShift64Bit(long a, long b)
+ {
+ //ARM64-FULL-LINE: add {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, ASR #41
+ return a + (b>>169);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int Adds(int a, int b)
+ {
+ //ARM64-FULL-LINE: adds {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
+ if (a + b == 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AddsLSL(int a, int b)
+ {
+ //ARM64-FULL-LINE: adds {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #15
+ if (a + (b<<15) == 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AddsLSLSwap(int a, int b)
+ {
+ //ARM64-FULL-LINE: adds {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #15
+ if ((b<<15) + a == 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AddsLSR(uint a, uint b)
+ {
+ //ARM64-FULL-LINE: adds {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSR #6
+ if (a + (b>>6) != 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AddsASR(int a, int b)
+ {
+ //ARM64-FULL-LINE: adds {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, ASR #11
+ if (a + (b>>11) == 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AddsLargeShift(int a, int b)
+ {
+ //ARM64-FULL-LINE: adds {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, ASR #5
+ if (a + (b>>133) == 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static long AddsLargeShift64Bit(long a, long b)
+ {
+ //ARM64-FULL-LINE: adds {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, LSL #42
+ if (a + (b<<106) == 0) {
+ return 1;
+ }
+ return -1;
+ }
+ }
+}
diff --git a/src/tests/JIT/opt/InstructionCombining/Add.csproj b/src/tests/JIT/opt/InstructionCombining/Add.csproj
new file mode 100644
index 00000000000000..1328d31335bd09
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Add.csproj
@@ -0,0 +1,17 @@
+
+
+
+ true
+
+
+ None
+ True
+
+
+
+ true
+
+
+
+
+
diff --git a/src/tests/JIT/opt/InstructionCombining/And.cs b/src/tests/JIT/opt/InstructionCombining/And.cs
new file mode 100644
index 00000000000000..9a16c1938d45d8
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/And.cs
@@ -0,0 +1,215 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+namespace TestAnd
+{
+ public class Program
+ {
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ [Fact]
+ public static int CheckAnd()
+ {
+ bool fail = false;
+
+ if (And(3, 2) != 2)
+ {
+ fail = true;
+ }
+
+ if (AndLSL(255, 1) != 16)
+ {
+ fail = true;
+ }
+
+ if (AndLSLSwap(255, 1) != 16)
+ {
+ fail = true;
+ }
+
+ if (AndLSR(255, 0x10000000) != 8)
+ {
+ fail = true;
+ }
+
+ if (AndASR(-5, 0x3C00) != 0xB)
+ {
+ fail = true;
+ }
+
+ if (AndLargeShift(9, 1) != 8)
+ {
+ fail = true;
+ }
+
+ if (AndLargeShift64Bit(0xF000000000, 7) != 0xE000000000)
+ {
+ fail = true;
+ }
+
+ if (Ands(4, 4) != 1)
+ {
+ fail = true;
+ }
+
+ if (AndsLSL(8, 2) != 1)
+ {
+ fail = true;
+ }
+
+ if (AndsLSLSwap(8, 2) != 1)
+ {
+ fail = true;
+ }
+
+ if (AndsLSR(3, 0xa0000) != 1)
+ {
+ fail = true;
+ }
+
+ if (AndsASR(6, 0x6000) != 1)
+ {
+ fail = true;
+ }
+
+ if (AndsLargeShift(0x80000000, 1) != 1)
+ {
+ fail = true;
+ }
+
+ if (AndsLargeShift64Bit(0xD, 0x34000000000) != 1)
+ {
+ fail = true;
+ }
+
+ if (fail)
+ {
+ return 101;
+ }
+ return 100;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int And(int a, int b)
+ {
+ //ARM64-FULL-LINE: and {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
+ return a & b;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AndLSL(int a, int b)
+ {
+ //ARM64-FULL-LINE: and {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #4
+ return a & (b<<4);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AndLSLSwap(int a, int b)
+ {
+ //ARM64-FULL-LINE: and {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #4
+ return (b<<4) & a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static uint AndLSR(uint a, uint b)
+ {
+ //ARM64-FULL-LINE: and {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSR #25
+ return a & (b>>25);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AndASR(int a, int b)
+ {
+ //ARM64-FULL-LINE: and {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, ASR #10
+ return a & (b>>10);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AndLargeShift(int a, int b)
+ {
+ //ARM64-FULL-LINE: and {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #3
+ return a & (b<<67);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static long AndLargeShift64Bit(long a, long b)
+ {
+ //ARM64-FULL-LINE: and {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, LSL #37
+ return a & (b<<101);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int Ands(int a, int b)
+ {
+ //ARM64-FULL-LINE: tst {{w[0-9]+}}, {{w[0-9]+}}
+ if ((a & b) != 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AndsLSL(int a, int b)
+ {
+ //ARM64-FULL-LINE: tst {{w[0-9]+}}, {{w[0-9]+}}, LSL #2
+ if ((a & (b<<2)) != 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AndsLSLSwap(int a, int b)
+ {
+ //ARM64-FULL-LINE: tst {{w[0-9]+}}, {{w[0-9]+}}, LSL #2
+ if (((b<<2) & a) != 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AndsLSR(uint a, uint b)
+ {
+ //ARM64-FULL-LINE: tst {{w[0-9]+}}, {{w[0-9]+}}, LSR #17
+ if ((a & (b>>17)) != 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AndsASR(int a, int b)
+ {
+ //ARM64-FULL-LINE: tst {{w[0-9]+}}, {{w[0-9]+}}, ASR #12
+ if ((a & (b>>12)) != 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AndsLargeShift(uint a, uint b)
+ {
+ //ARM64-FULL-LINE: tst {{w[0-9]+}}, {{w[0-9]+}}, LSL #31
+ if ((a & (b<<255)) != 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int AndsLargeShift64Bit(ulong a, ulong b)
+ {
+ //ARM64-FULL-LINE: lsr {{x[0-9]+}}, {{x[0-9]+}}, #38
+ //ARM64-FULL-LINE: tst {{x[0-9]+}}, {{x[0-9]+}}
+ if ((a & (b>>230)) != 0) {
+ return 1;
+ }
+ return -1;
+ }
+ }
+}
diff --git a/src/tests/JIT/opt/InstructionCombining/And.csproj b/src/tests/JIT/opt/InstructionCombining/And.csproj
new file mode 100644
index 00000000000000..8e7b7770b02247
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/And.csproj
@@ -0,0 +1,17 @@
+
+
+
+ true
+
+
+ None
+ True
+
+
+
+ true
+
+
+
+
+
diff --git a/src/tests/JIT/opt/InstructionCombining/Cmn.cs b/src/tests/JIT/opt/InstructionCombining/Cmn.cs
new file mode 100644
index 00000000000000..f8e05ed9125a0d
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Cmn.cs
@@ -0,0 +1,138 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+namespace TestCompareNegative
+{
+ public class Program
+ {
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ [Fact]
+ public static int CheckCompareNegative()
+ {
+ bool fail = false;
+
+ if (!Cmn(-4, 4))
+ {
+ fail = true;
+ }
+
+ if (!CmnLSL(-16, 4))
+ {
+ fail = true;
+ }
+
+ if (!CmnLSLSwap(-16, 4))
+ {
+ fail = true;
+ }
+
+ if (!CmnLSR(0xFFFFFFFC, 0x10))
+ {
+ fail = true;
+ }
+
+ if (!CmnASR(-0xA, 0x2800))
+ {
+ fail = true;
+ }
+
+ if (!CmnLargeShift(-0x18, 0x3))
+ {
+ fail = true;
+ }
+
+ if (!CmnLargeShift64Bit(-0x300000000000000, 0x6))
+ {
+ fail = true;
+ }
+
+ if (fail)
+ {
+ return 101;
+ }
+ return 100;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Cmn(int a, int b)
+ {
+ //ARM64-FULL-LINE: cmn {{w[0-9]+}}, {{w[0-9]+}}
+ if (a == -b)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmnLSL(int a, int b)
+ {
+ //ARM64-FULL-LINE: cmn {{w[0-9]+}}, {{w[0-9]+}}, LSL #2
+ if (a == -(b<<2))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmnLSLSwap(int a, int b)
+ {
+ //ARM64-FULL-LINE: cmn {{w[0-9]+}}, {{w[0-9]+}}, LSL #2
+ if (-(b<<2) == a)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmnLSR(uint a, uint b)
+ {
+ //ARM64-FULL-LINE: lsr {{w[0-9]+}}, {{w[0-9]+}}, #2
+ //ARM64-FULL-LINE: cmn {{w[0-9]+}}, {{w[0-9]+}}
+ if (a == (uint)-(b>>2))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmnASR(int a, int b)
+ {
+ //ARM64-FULL-LINE: cmn {{w[0-9]+}}, {{w[0-9]+}}, ASR #10
+ if (a == -(b>>10))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmnLargeShift(int a, int b)
+ {
+ //ARM64-FULL-LINE: cmn {{w[0-9]+}}, {{w[0-9]+}}, LSL #3
+ if (a == -(b<<35))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmnLargeShift64Bit(long a, long b)
+ {
+ //ARM64-FULL-LINE: cmn {{x[0-9]+}}, {{x[0-9]+}}, LSL #55
+ if (a == -(b<<247))
+ {
+ return true;
+ }
+ return false;
+ }
+ }
+}
diff --git a/src/tests/JIT/opt/InstructionCombining/Cmn.csproj b/src/tests/JIT/opt/InstructionCombining/Cmn.csproj
new file mode 100644
index 00000000000000..f92126ec42c194
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Cmn.csproj
@@ -0,0 +1,17 @@
+
+
+
+ true
+
+
+ None
+ True
+
+
+
+ true
+
+
+
+
+
diff --git a/src/tests/JIT/opt/InstructionCombining/Cmp.cs b/src/tests/JIT/opt/InstructionCombining/Cmp.cs
new file mode 100644
index 00000000000000..0ce7de0faee544
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Cmp.cs
@@ -0,0 +1,138 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+namespace TestCompare
+{
+ public class Program
+ {
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ [Fact]
+ public static int CheckCompare()
+ {
+ bool fail = false;
+
+ if (!Cmp(12, 12))
+ {
+ fail = true;
+ }
+
+ if (!CmpLSL(12, 3))
+ {
+ fail = true;
+ }
+
+ if (!CmpLSLSwap(12, 3))
+ {
+ fail = true;
+ }
+
+ if (!CmpLSR(5, 0xa00))
+ {
+ fail = true;
+ }
+
+ if (!CmpASR(7, 0x380))
+ {
+ fail = true;
+ }
+
+ if (!CmpLargeShift(0x500000, 0xA))
+ {
+ fail = true;
+ }
+
+ if (!CmpLargeShift64Bit(0x580000000000000, 0xB))
+ {
+ fail = true;
+ }
+
+ if (fail)
+ {
+ return 101;
+ }
+ return 100;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Cmp(int a, int b)
+ {
+ //ARM64-FULL-LINE: cmp {{w[0-9]+}}, {{w[0-9]+}}
+ if (a == b)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmpLSL(int a, int b)
+ {
+ //ARM64-FULL-LINE: cmp {{w[0-9]+}}, {{w[0-9]+}}, LSL #2
+ if (a == (b<<2))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmpLSLSwap(int a, int b)
+ {
+ //ARM64-FULL-LINE: cmp {{w[0-9]+}}, {{w[0-9]+}}, LSL #2
+ if ((b<<2) == a)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmpLSR(uint a, uint b)
+ {
+ //ARM64-FULL-LINE: cmp {{w[0-9]+}}, {{w[0-9]+}}, LSR #9
+ if (a == (b>>9))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmpASR(int a, int b)
+ {
+ //ARM64-FULL-LINE: cmp {{w[0-9]+}}, {{w[0-9]+}}, ASR #7
+ if (a == (b>>7))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmpLargeShift(int a, int b)
+ {
+ //ARM64-FULL-LINE: cmp {{w[0-9]+}}, {{w[0-9]+}}, LSL #19
+ if (a == (b<<115))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool CmpLargeShift64Bit(long a, long b)
+ {
+ //ARM64-FULL-LINE: lsl {{x[0-9]+}}, {{x[0-9]+}}, #55
+ //ARM64-FULL-LINE: cmp {{x[0-9]+}}, {{x[0-9]+}}
+ if (a == (b<<119))
+ {
+ return true;
+ }
+ return false;
+ }
+ }
+}
diff --git a/src/tests/JIT/opt/InstructionCombining/Cmp.csproj b/src/tests/JIT/opt/InstructionCombining/Cmp.csproj
new file mode 100644
index 00000000000000..121723d2791f87
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Cmp.csproj
@@ -0,0 +1,17 @@
+
+
+
+ true
+
+
+ None
+ True
+
+
+
+ true
+
+
+
+
+
diff --git a/src/tests/JIT/opt/InstructionCombining/Eor.cs b/src/tests/JIT/opt/InstructionCombining/Eor.cs
new file mode 100644
index 00000000000000..f62c53a52268c1
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Eor.cs
@@ -0,0 +1,109 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+namespace TestEor
+{
+ public class Program
+ {
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ [Fact]
+ public static int CheckEor()
+ {
+ bool fail = false;
+
+ if (Eor(5, 3) != 6)
+ {
+ fail = true;
+ }
+
+ if (EorLSL(32, 3) != 16)
+ {
+ fail = true;
+ }
+
+ if (EorLSLSwap(32, 3) != 16)
+ {
+ fail = true;
+ }
+
+ if (EorLSR(0xBA, 0xABCDE) != 0x11)
+ {
+ fail = true;
+ }
+
+ if (EorASR(0x8282, 0x1DA00000) != 0x82B9)
+ {
+ fail = true;
+ }
+
+ if (EorLargeShift(0xDCBA, 0x1F) != 0xc3ba)
+ {
+ fail = true;
+ }
+
+ if (EorLargeShift64Bit(0x2468, 0x26ae123456789ABC) != 0x373F)
+ {
+ fail = true;
+ }
+
+ if (fail)
+ {
+ return 101;
+ }
+ return 100;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int Eor(int a, int b)
+ {
+ //ARM64-FULL-LINE: eor {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
+ return a ^ b;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int EorLSL(int a, int b)
+ {
+ //ARM64-FULL-LINE: eor {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #4
+ return a ^ (b<<4);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int EorLSLSwap(int a, int b)
+ {
+ //ARM64-FULL-LINE: eor {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #4
+ return (b<<4) ^ a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static uint EorLSR(uint a, uint b)
+ {
+ //ARM64-FULL-LINE: eor {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSR #12
+ return a ^ (b>>12);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int EorASR(int a, int b)
+ {
+ //ARM64-FULL-LINE: eor {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, ASR #23
+ return a ^ (b>>23);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int EorLargeShift(int a, int b)
+ {
+ //ARM64-FULL-LINE: eor {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #8
+ return a ^ (b<<136);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static ulong EorLargeShift64Bit(ulong a, ulong b)
+ {
+ //ARM64-FULL-LINE: eor {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, LSR #49
+ return a ^ (b>>177);
+ }
+ }
+}
diff --git a/src/tests/JIT/opt/InstructionCombining/Eor.csproj b/src/tests/JIT/opt/InstructionCombining/Eor.csproj
new file mode 100644
index 00000000000000..dd4c42699f2e68
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Eor.csproj
@@ -0,0 +1,17 @@
+
+
+
+ true
+
+
+ None
+ True
+
+
+
+ true
+
+
+
+
+
diff --git a/src/tests/JIT/opt/InstructionCombining/Neg.cs b/src/tests/JIT/opt/InstructionCombining/Neg.cs
new file mode 100644
index 00000000000000..cf2850eab045a0
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Neg.cs
@@ -0,0 +1,98 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+namespace TestNeg
+{
+ public class Program
+ {
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ [Fact]
+ public static int CheckNeg()
+ {
+ bool fail = false;
+
+ if (Neg(3) != -3)
+ {
+ fail = true;
+ }
+
+ if (NegLSL(4) != -16)
+ {
+ fail = true;
+ }
+
+ if (NegLSR(0x300000) != 0xFFFFFFFD)
+ {
+ fail = true;
+ }
+
+ if (NegASR(0xA000) != -5)
+ {
+ fail = true;
+ }
+
+ if (NegLargeShift(0xC) != -0x180000)
+ {
+ fail = true;
+ }
+
+ if (NegLargeShift64Bit(0xD) != 0x6000000000000000)
+ {
+ fail = true;
+ }
+
+ if (fail)
+ {
+ return 101;
+ }
+ return 100;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int Neg(int a)
+ {
+ //ARM64-FULL-LINE: neg {{w[0-9]+}}, {{w[0-9]+}}
+ return -a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int NegLSL(int a)
+ {
+ //ARM64-FULL-LINE: neg {{w[0-9]+}}, {{w[0-9]+}}, LSL #2
+ return -(a<<2);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static uint NegLSR(uint a)
+ {
+ //ARM64-FULL-LINE: lsr {{w[0-9]+}}, {{w[0-9]+}}, #20
+ //ARM64-FULL-LINE: neg {{w[0-9]+}}, {{w[0-9]+}}
+ return (uint)-(a>>20);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int NegASR(int a)
+ {
+ //ARM64-FULL-LINE: neg {{w[0-9]+}}, {{w[0-9]+}}, ASR #13
+ return -(a>>13);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int NegLargeShift(int a)
+ {
+ //ARM64-FULL-LINE: neg {{w[0-9]+}}, {{w[0-9]+}}, LSL #17
+ return -(a<<81);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static long NegLargeShift64Bit(long a)
+ {
+ //ARM64-FULL-LINE: neg {{x[0-9]+}}, {{x[0-9]+}}, LSL #61
+ return -(a<<189);
+ }
+ }
+}
diff --git a/src/tests/JIT/opt/InstructionCombining/Neg.csproj b/src/tests/JIT/opt/InstructionCombining/Neg.csproj
new file mode 100644
index 00000000000000..5593e2e3ec2db3
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Neg.csproj
@@ -0,0 +1,17 @@
+
+
+
+ true
+
+
+ None
+ True
+
+
+
+ true
+
+
+
+
+
diff --git a/src/tests/JIT/opt/InstructionCombining/Orr.cs b/src/tests/JIT/opt/InstructionCombining/Orr.cs
new file mode 100644
index 00000000000000..204b1c85d1eab2
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Orr.cs
@@ -0,0 +1,109 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+namespace TestOrr
+{
+ public class Program
+ {
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ [Fact]
+ public static int CheckOrr()
+ {
+ bool fail = false;
+
+ if (Orr(2, 4) != 6)
+ {
+ fail = true;
+ }
+
+ if (OrrLSL(0x180, 5) != 0x1C0)
+ {
+ fail = true;
+ }
+
+ if (OrrLSLSwap(0x180, 5) != 0x1C0)
+ {
+ fail = true;
+ }
+
+ if (OrrLSR(0x7, 0x1234) != 0x27)
+ {
+ fail = true;
+ }
+
+ if (OrrASR(0x13, 0xA98765) != 0x3B)
+ {
+ fail = true;
+ }
+
+ if (OrrLargeShift(0x1A40, 0x8E) != 0x1BC0)
+ {
+ fail = true;
+ }
+
+ if (OrrLargeShift64Bit(0x2468, 0xDEF1234567) != 0x246F)
+ {
+ fail = true;
+ }
+
+ if (fail)
+ {
+ return 101;
+ }
+ return 100;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int Orr(int a, int b)
+ {
+ //ARM64-FULL-LINE: orr {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
+ return a | b;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int OrrLSL(int a, int b)
+ {
+ //ARM64-FULL-LINE: orr {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #6
+ return a | (b<<6);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int OrrLSLSwap(int a, int b)
+ {
+ //ARM64-FULL-LINE: orr {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #6
+ return (b<<6) | a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static uint OrrLSR(uint a, uint b)
+ {
+ //ARM64-FULL-LINE: orr {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSR #7
+ return a | (b>>7);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int OrrASR(int a, int b)
+ {
+ //ARM64-FULL-LINE: orr {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, ASR #18
+ return a | (b>>18);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int OrrLargeShift(int a, int b)
+ {
+ //ARM64-FULL-LINE: orr {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #5
+ return a | (b<<101);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static ulong OrrLargeShift64Bit(ulong a, ulong b)
+ {
+ //ARM64-FULL-LINE: orr {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, LSR #33
+ return a | (b>>289);
+ }
+ }
+}
diff --git a/src/tests/JIT/opt/InstructionCombining/Orr.csproj b/src/tests/JIT/opt/InstructionCombining/Orr.csproj
new file mode 100644
index 00000000000000..07c6535e553e0a
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Orr.csproj
@@ -0,0 +1,17 @@
+
+
+
+ true
+
+
+ None
+ True
+
+
+
+ true
+
+
+
+
+
diff --git a/src/tests/JIT/opt/InstructionCombining/Sub.cs b/src/tests/JIT/opt/InstructionCombining/Sub.cs
new file mode 100644
index 00000000000000..105666b2ff6194
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Sub.cs
@@ -0,0 +1,187 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+namespace TestSub
+{
+ public class Program
+ {
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ [Fact]
+ public static int CheckSub()
+ {
+ bool fail = false;
+
+ if (Sub(5, 2) != 3)
+ {
+ fail = true;
+ }
+
+ if (SubLSL(100, 2) != 84)
+ {
+ fail = true;
+ }
+
+ if (SubLSR(10, 64) != 6)
+ {
+ fail = true;
+ }
+
+ if (SubASR(10, 320) != 5)
+ {
+ fail = true;
+ }
+
+ if (SubLargeShift(0x40000F, 1) != 0xF)
+ {
+ fail = true;
+ }
+
+ if (SubLargeShift64Bit(0x40000000000ACE, 1) != 0xACE)
+ {
+ fail = true;
+ }
+
+ if (Subs(15, 15) != 1)
+ {
+ fail = true;
+ }
+
+ if (SubsLSL(14, 7) != 1)
+ {
+ fail = true;
+ }
+
+ if (SubsLSR(1, 0x80000000) != 1)
+ {
+ fail = true;
+ }
+
+ if (SubsASR(27, 0x1B00000) != 1)
+ {
+ fail = true;
+ }
+
+ if (SubsLargeShift(4, 2) != 1)
+ {
+ fail = true;
+ }
+
+ if (SubsLargeShift64Bit(0x300000000, 3) != 1)
+ {
+ fail = true;
+ }
+
+ if (fail)
+ {
+ return 101;
+ }
+ return 100;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int Sub(int a, int b)
+ {
+ //ARM64-FULL-LINE: sub {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
+ return a - b;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int SubLSL(int a, int b)
+ {
+ //ARM64-FULL-LINE: sub {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #3
+ return a - (b<<3);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static uint SubLSR(uint a, uint b)
+ {
+ //ARM64-FULL-LINE: sub {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSR #4
+ return a - (b>>4);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int SubASR(int a, int b)
+ {
+ //ARM64-FULL-LINE: sub {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, ASR #6
+ return a - (b>>6);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int SubLargeShift(int a, int b)
+ {
+ //ARM64-FULL-LINE: sub {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #22
+ return a - (b<<118);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static long SubLargeShift64Bit(long a, long b)
+ {
+ //ARM64-FULL-LINE: sub {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, LSL #54
+ return a - (b<<118);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int Subs(int a, int b)
+ {
+ //ARM64-FULL-LINE: subs {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
+ if (a - b == 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int SubsLSL(int a, int b)
+ {
+ //ARM64-FULL-LINE: subs {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #1
+ if (a - (b<<1) == 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int SubsLSR(uint a, uint b)
+ {
+ //ARM64-FULL-LINE: subs {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSR #31
+ if (a - (b>>31) == 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int SubsASR(int a, int b)
+ {
+ //ARM64-FULL-LINE: subs {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, ASR #20
+ if (a - (b>>20) == 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int SubsLargeShift(int a, int b)
+ {
+ //ARM64-FULL-LINE: subs {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, LSL #1
+ if (a - (b<<33) == 0) {
+ return 1;
+ }
+ return -1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int SubsLargeShift64Bit(long a, long b)
+ {
+ //ARM64-FULL-LINE: subs {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, LSL #32
+ if (a - (b<<96) == 0) {
+ return 1;
+ }
+ return -1;
+ }
+ }
+}
diff --git a/src/tests/JIT/opt/InstructionCombining/Sub.csproj b/src/tests/JIT/opt/InstructionCombining/Sub.csproj
new file mode 100644
index 00000000000000..fdea1deaa97d69
--- /dev/null
+++ b/src/tests/JIT/opt/InstructionCombining/Sub.csproj
@@ -0,0 +1,17 @@
+
+
+
+ true
+
+
+ None
+ True
+
+
+
+ true
+
+
+
+
+