new cases for stuff I have been working on
authorBen Maurer <benm@mono-cvs.ximian.com>
Thu, 13 May 2004 21:22:39 +0000 (21:22 -0000)
committerBen Maurer <benm@mono-cvs.ximian.com>
Thu, 13 May 2004 21:22:39 +0000 (21:22 -0000)
svn path=/trunk/mono/; revision=27312

mono/benchmark/Makefile.am
mono/benchmark/cmov1.cs [new file with mode: 0644]
mono/benchmark/cmov2.cs [new file with mode: 0644]
mono/benchmark/cmov3.cs [new file with mode: 0644]
mono/benchmark/cmov4.cs [new file with mode: 0644]
mono/benchmark/cmov5.cs [new file with mode: 0644]
mono/benchmark/max-min.cs [new file with mode: 0644]
mono/benchmark/regalloc-2.cs [new file with mode: 0644]
mono/benchmark/regalloc.cs [new file with mode: 0644]

index 10217ab9f84b2e7d1bccd9bf46d52436412c866d..62354f9311ead393b1b6d4e16f4f534c3b2ba313 100644 (file)
@@ -8,6 +8,11 @@ TESTSRC=                       \
        fib.cs                  \
        life.cs                 \
        castclass.cs            \
+       cmov1.cs                \
+       cmov2.cs                \
+       cmov3.cs                \
+       cmov4.cs                \
+       cmov5.cs                \
        commute.cs              \
        isinst.cs               \
        sbperf1.cs              \
@@ -20,6 +25,7 @@ TESTSRC=                      \
        inline5.cs              \
        inline6.cs              \
        inline-readonly.cs      \
+       max-min.cs              \
        muldiv.cs               \
        loops.cs                \
        initlocals.cs           \
@@ -30,6 +36,8 @@ TESTSRC=                      \
        readonly-byte-array.cs  \
        readonly-inst.cs        \
        readonly-vt.cs          \
+       regalloc.cs             \
+       regalloc-2.cs           \
        bulkcpy.il              \
        math.cs                 \
        boxtest.cs              \
diff --git a/mono/benchmark/cmov1.cs b/mono/benchmark/cmov1.cs
new file mode 100644 (file)
index 0000000..d0c0d00
--- /dev/null
@@ -0,0 +1,29 @@
+using System;
+class T {
+       static void Main () {
+               int y = 0;
+               int z = 1;
+               for (int i = 0; i < 500000000; i ++) {
+                       if (y == 0)
+                               z = i;
+                       
+                       if (y == 4)
+                               y = i;
+                       
+                       if (z == 0)
+                               y = 1;
+                       
+                       if (y == 1)
+                               z = i;
+                       
+                       if (y == 1)
+                               y = i;
+                       
+                       if (z == 2)
+                               y = z;
+                       else
+                               y = i;
+               }
+       }
+       
+}
\ No newline at end of file
diff --git a/mono/benchmark/cmov2.cs b/mono/benchmark/cmov2.cs
new file mode 100644 (file)
index 0000000..b2d0706
--- /dev/null
@@ -0,0 +1,23 @@
+using System;
+class T {
+       static void Main () {
+               int a = 1, b = 2, c = 3, d = 4, e = 5;
+               for (int i = 0; i < 500000000; i ++) {
+                       // on the stack
+                       if (a == b)
+                               a = i;
+                       if (b == a)
+                               b = i;
+                       if (c == d)
+                               c = i;
+                       if (d == e)
+                               d = i;
+                       if (e == a)
+                               e = i;
+               }
+               
+               if ((a ^ b ^ c ^ d ^ e) == 12345)
+                       return;
+       }
+       
+}
\ No newline at end of file
diff --git a/mono/benchmark/cmov3.cs b/mono/benchmark/cmov3.cs
new file mode 100644 (file)
index 0000000..4cfc681
--- /dev/null
@@ -0,0 +1,14 @@
+using System;
+class T {
+       // test x ? A : B where A and B are constants.
+       static void Main () {
+               int a = 0, b = 0, c = 0, d = 0, e = 0;
+               for (int i = 0; i < 50000000; i ++) {                   
+                       a = b == 10 ?  1 :  1;
+                       b = b >  1  ?  9 :  8;
+                       c = b <= c  ?  1 :  2;
+                       d = d >  0  ?  1 :  0;
+                       e = e == 0  ? -1 :  0;
+               }
+       }
+}
\ No newline at end of file
diff --git a/mono/benchmark/cmov4.cs b/mono/benchmark/cmov4.cs
new file mode 100644 (file)
index 0000000..c00bc32
--- /dev/null
@@ -0,0 +1,33 @@
+using System;
+class T {
+       // some more advanced versions.
+       static void Main () {
+               int a = 0, b = 0, c = 0, d = 0, e = 0;
+               for (int i = 0; i < 50000000; i ++) {
+                       // sgn (x)
+                       if (a == 0)
+                               a = 0;
+                       else if (a < 0)
+                               a = -1;
+                       else
+                               a = 1;
+                       
+                       // cond incr
+                       if (a <= 0)
+                               a ++;
+                       
+                       // buffer ring
+                       if (b == 49)
+                               b = 0;
+                       else
+                               b ++;
+                       
+                       // max
+                       c = a > b ? a : b;
+                       
+                       // abs
+                       d = a > 0 ? a : -a;
+               }
+       }
+       
+}
\ No newline at end of file
diff --git a/mono/benchmark/cmov5.cs b/mono/benchmark/cmov5.cs
new file mode 100644 (file)
index 0000000..c3c6f08
--- /dev/null
@@ -0,0 +1,15 @@
+using System;
+class T {
+       static void Main () {
+               int a = 1, b = 2, c = 3, d = 4, e = 5;
+               for (int i = 0; i < 500000000; i ++) {
+                       // on the stack
+                       a = e == 1 ? b : c;
+                       b = a == 1 ? c : d;
+                       c = b == 1 ? d : e;
+                       d = c == 1 ? e : a;
+                       e = d == 1 ? a : b;
+               }
+       }
+       
+}
\ No newline at end of file
diff --git a/mono/benchmark/max-min.cs b/mono/benchmark/max-min.cs
new file mode 100644 (file)
index 0000000..a2f946b
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+mono max-min.exe              0m1.468s
+mono -O=inline max-min.exe    0m1.087s
+../mini/mono max-min.exe      0m0.511s
+*/
+
+class T {
+
+       static int DoIt (int a, int b) {
+               int x = 0;
+               for (int j = 0; j < 200000; j++) {
+                       x += System.Math.Max (a, b);
+                       x += System.Math.Max (a, b);
+                       x += System.Math.Max (j, b);
+                       x += System.Math.Max (j, b);
+                       x += System.Math.Min (System.Math.Max (j, x), b);
+                       x += System.Math.Min (System.Math.Max (j, x), b);
+               }
+               return x;
+       }
+       
+       static void Main () {
+               for (int i = 0; i < 50; i++)
+                       DoIt (1, 5);
+       }
+}
\ No newline at end of file
diff --git a/mono/benchmark/regalloc-2.cs b/mono/benchmark/regalloc-2.cs
new file mode 100644 (file)
index 0000000..f8b1eb6
--- /dev/null
@@ -0,0 +1,28 @@
+class T {
+       static void Main ()
+       {
+               int j = 0, k = 0, l = 0;
+               for (int i = 0; i < 50000000; i ++) {
+                       int a = i ^ 1;
+                       int b = a ^ 2;
+                       int c = b ^ 3;
+                       int d = c ^ 4;
+                       int e = d ^ 5;
+                       int f = e ^ 6;
+                       int g = f ^ 7;
+                       int h = g ^ 8;
+                       
+                       j ^= h;
+                       k ^= h + 1;
+                       l ^= h & 5;
+                       
+                       j ^= l;
+                       k ^= k + 1;
+                       l ^= j & 5;
+                       
+                       j ^= l;
+                       k ^= k + 1;
+                       l ^= j & 5;
+               }
+       }
+}
\ No newline at end of file
diff --git a/mono/benchmark/regalloc.cs b/mono/benchmark/regalloc.cs
new file mode 100644 (file)
index 0000000..d84753f
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// To do this test well, I think you need to move the int aX = 0...
+// lines down as far as possible. That way, the lifespan of the variables
+// is short, and they can go into registers.
+//
+
+class T {
+       static int Main ()
+       {
+               for (int r = 0; r < 50; r ++) {
+                       int a0 = 0, b0 = 0, c0 = 0, d0 = 0;
+                       int a1 = 0, b1 = 0, c1 = 0, d1 = 0;
+                       int a2 = 0, b2 = 0, c2 = 0, d2 = 0;
+                       int a3 = 0, b3 = 0, c3 = 0, d3 = 0;
+                       int a4 = 0, b4 = 0, c4 = 0, d4 = 0;
+                       
+                       int x = 0;
+                       
+                       for (int i = 0; i < 400000; i ++) a0 ++;
+                       for (int i = 0; i < 400000; i ++) b0 ++;
+                       for (int i = 0; i < 400000; i ++) c0 ++;
+                       for (int i = 0; i < 400000; i ++) d0 ++;
+                       x ^= a0 ^ b0 ^ c0 ^ d0;
+                       
+                       for (int i = 0; i < 400000; i ++) a1 ++;
+                       for (int i = 0; i < 400000; i ++) b1 ++;
+                       for (int i = 0; i < 400000; i ++) c1 ++;
+                       for (int i = 0; i < 400000; i ++) d1 ++;
+                       x ^= a1 ^ b1 ^ c1 ^ d1;
+                       
+                       for (int i = 0; i < 400000; i ++) a2 ++;
+                       for (int i = 0; i < 400000; i ++) b2 ++;
+                       for (int i = 0; i < 400000; i ++) c2 ++;
+                       for (int i = 0; i < 400000; i ++) d2 ++;
+                       x ^= a2 ^ b2 ^ c2 ^ d2;
+                       
+                       for (int i = 0; i < 400000; i ++) a3 ++;
+                       for (int i = 0; i < 400000; i ++) b3 ++;
+                       for (int i = 0; i < 400000; i ++) c3 ++;
+                       for (int i = 0; i < 400000; i ++) d3 ++;
+                       x ^= a3 ^ b3 ^ c3 ^ d3;
+                       
+                       for (int i = 0; i < 400000; i ++) a4 ++;
+                       for (int i = 0; i < 400000; i ++) b4 ++;
+                       for (int i = 0; i < 400000; i ++) c4 ++;
+                       for (int i = 0; i < 400000; i ++) d4 ++;
+                       x ^= a4 ^ b4 ^ c4 ^ d4;
+                       
+                       if (x != 0)
+                               return 1;
+               }
+               return 0;
+       }
+}
\ No newline at end of file