some testcases I didn't commit yet
authorMatthias Braun <matze@braunis.de>
Mon, 30 Jul 2007 11:31:13 +0000 (11:31 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 30 Jul 2007 11:31:13 +0000 (11:31 +0000)
[r15372]

ir/be/test/boolopts.c [new file with mode: 0644]
ir/be/test/broken_ones [deleted file]
ir/be/test/distributive.c [new file with mode: 0644]

diff --git a/ir/be/test/boolopts.c b/ir/be/test/boolopts.c
new file mode 100644 (file)
index 0000000..d695683
--- /dev/null
@@ -0,0 +1,126 @@
+/*$ -fno-inline $*/
+#include <limits.h>
+#include <stdio.h>
+
+int f(int a, int b)
+{
+       return a < 0 & b < 0;
+}
+
+int f2(short a, short b)
+{
+       return a < b && b < a;
+}
+
+int f3(short a, short b)
+{
+       return a < b && b > a;
+}
+
+int f4(short a, short b, short c)
+{
+       return (a <= c) & (b <= c);
+}
+
+int g(unsigned a, unsigned b)
+{
+       return ((a >> 12) | 5) & ((b >> 12) | 5);
+}
+
+int g2(unsigned a, unsigned b)
+{
+       return (a & 5) | (b & 5);
+}
+
+int g3(int a, int b, int z)
+{
+       return (a | z) & (b | z);
+}
+
+int af(int a)
+{
+       return (a ? 1 : 0) && !a;
+}
+
+int at(int a)
+{
+       return (a ? 1 : 0) || !a;
+}
+
+int main()
+{
+#define UOP(func,val,should_be)        { printf("%s(%d) -> %d (should be %d)\n", #func, val, func(val), should_be); }
+#define BOP(func,val1,val2,should_be) { printf("%s(%d,%d) -> %d (should be %d)\n", #func, val1, val2, func(val1,val2), should_be); }
+#define TOP(func,val1,val2,val3,should_be) { printf("%s(%d,%d,%d) -> %d (should be %d)\n", #func, val1, val2, val3, func(val1,val2,val3), should_be); }
+       BOP(f, 0, 0, 0);
+       BOP(f, -1, 0, 0);
+       BOP(f, 0, -42, 0);
+       BOP(f, -1, 1, 0);
+       BOP(f, -42, -23, 1);
+       BOP(f, 13, -1, 0);
+       BOP(f, -1, -1, 1);
+       BOP(f, INT_MIN, INT_MIN, 1);
+       BOP(f, INT_MIN, -1, 1);
+       BOP(f, -1, INT_MIN, 1);
+
+       BOP(f2, 0, 0, 0);
+       BOP(f2, -1, 0, 0);
+       BOP(f2, 0, -42, 0);
+       BOP(f2, -1, 1, 0);
+       BOP(f2, -42, -23, 0);
+       BOP(f2, 13, -1, 0);
+       BOP(f2, -1, -1, 0);
+       BOP(f2, SHRT_MIN, SHRT_MIN, 0);
+       BOP(f2, SHRT_MIN, -1, 0);
+       BOP(f2, -1, SHRT_MIN, 0);
+
+       BOP(f3, 0, 0, 0);
+       BOP(f3, -1, 0, 1);
+       BOP(f3, 0, -42, 0);
+       BOP(f3, -1, 1, 1);
+       BOP(f3, -42, -23, 1);
+       BOP(f3, 13, -1, 0);
+       BOP(f3, -1, -1, 0);
+       BOP(f3, SHRT_MIN, SHRT_MIN, 0);
+       BOP(f3, SHRT_MIN, -1, 1);
+       BOP(f3, -1, SHRT_MIN, 0);
+
+       TOP(f4, 1, 2, 3, 1);
+       TOP(f4, -1, -2, -3, 0);
+       TOP(f4, SHRT_MIN, SHRT_MIN, -1, 1);
+       TOP(f4, SHRT_MIN, SHRT_MIN, SHRT_MIN, 1);
+       TOP(f4, SHRT_MAX, SHRT_MIN, SHRT_MAX, 1);
+       TOP(f4, SHRT_MIN, SHRT_MIN, SHRT_MAX, 1);
+       TOP(f4, 13, 42, SHRT_MAX, 1);
+       TOP(f4, 0, 0, 0, 1);
+       TOP(f4, 1, 1, 1, 1);
+
+       BOP(g, UINT_MAX, UINT_MAX, 1048575);
+       BOP(g, 0, 0, 5);
+       BOP(g, 12345, 54321, 5);
+
+       BOP(g2, UINT_MAX, UINT_MAX, 5);
+       BOP(g2, 0, 0, 0);
+       BOP(g2, 12345, 54321, 1);
+
+       TOP(g3, 1, 2, 3, 3);
+       TOP(g3, -1, -2, -3, -1);
+       TOP(g3, INT_MIN, INT_MIN, -1, -1);
+       TOP(g3, INT_MIN, INT_MIN, INT_MIN, INT_MIN);
+       TOP(g3, INT_MAX, INT_MIN, INT_MAX, INT_MAX);
+       TOP(g3, INT_MIN, INT_MIN, INT_MAX, -1);
+       TOP(g3, 13, 42, INT_MAX, INT_MAX);
+       TOP(g3, 0, 0, 0, 0);
+       TOP(g3, 1, 1, 1, 1);
+
+       UOP(af, 0, 0);
+       UOP(af, 1, 0);
+       UOP(af, 42, 0);
+       UOP(af, -1, 0);
+
+       UOP(at, 0, 1);
+       UOP(at, 1, 1);
+       UOP(at, 42, 1);
+       UOP(at, -1, 1);
+       return 0;
+}
diff --git a/ir/be/test/broken_ones b/ir/be/test/broken_ones
deleted file mode 100644 (file)
index 1ca5e9f..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-=== compiling LongLong.c ===
-"LongLong.c", line 20: warning: variable "l1" was declared but never referenced
-      long long lmax, lmin, lmin1, limax, limin1, limin, l1, l;
-                                                         ^
-
-edgcpfe: ../../../../ir/be/ia32/ia32_emitter.c:1311: emit_ia32_Conv_I2I: Assertion `0 && "unsupported Conv_I2I"' failed.
-/afs/info.uni-karlsruhe.de/user/chriswue/local/bin/eccp: line 2:  6437 Aborted                 edgcpfe --gnu=30305 --c -I/usr/lib/gcc-lib/i586-suse-linux/3.3.5/include/ $*
-=== compiling bf_init.c ===
-edgcpfe: ../../../../ir/be/ia32/ia32_gen_decls.c:479: dump_global: Assertion `aipos >= 0 && "couldn't store entity"' failed.
-/afs/info.uni-karlsruhe.de/user/chriswue/local/bin/eccp: line 2:  6541 Aborted                 edgcpfe --gnu=30305 --c -I/usr/lib/gcc-lib/i586-suse-linux/3.3.5/include/ $*
-=== compiling bf_localinit.c ===
-"bf_localinit.c", line 1: catastrophic error: could not open source file
-          "dumpmem.h"
-  #include "dumpmem.h"
-                      ^
-
-1 catastrophic error detected in the compilation of "bf_localinit.c".
-Compilation terminated.
-rm: cannot remove `*.vcg': No such file or directory
-=== compiling bf_store.c ===
-"bf_store.c", line 1: catastrophic error: could not open source file
-          "dumpmem.h"
-  #include "dumpmem.h"
-                      ^
-
-1 catastrophic error detected in the compilation of "bf_store.c".
-Compilation terminated.
-rm: cannot remove `*.vcg': No such file or directory
-=== compiling bitfield.c ===
-edgcpfe: ../../../../ir/be/ia32/ia32_gen_decls.c:479: dump_global: Assertion `aipos >= 0 && "couldn't store entity"' failed.
-/afs/info.uni-karlsruhe.de/user/chriswue/local/bin/eccp: line 2:  6556 Aborted                 edgcpfe --gnu=30305 --c -I/usr/lib/gcc-lib/i586-suse-linux/3.3.5/include/ $*
-=== compiling scanner.c ===
-edgcpfe: ../../../ir/be/bechordal.c:496: handle_constraints: Assertion `assignment[i] >= 0 && "there must have been a register assigned"' failed.
-/afs/info.uni-karlsruhe.de/user/chriswue/local/bin/eccp: line 2: 12475 Aborted                 edgcpfe --gnu=30305 --c -I/usr/lib/gcc-lib/i586-suse-linux/3.3.5/include/ $*
-=== compiling sparam.c ===
-edgcpfe: ../../../../ir/be/ia32/ia32_emitter.c:136: get_in_reg: Assertion `reg && "no in register found"' failed.
-/afs/info.uni-karlsruhe.de/user/chriswue/local/bin/eccp: line 2:  6726 Aborted                 edgcpfe --gnu=30305 --c -I/usr/lib/gcc-lib/i586-suse-linux/3.3.5/include/ $*
diff --git a/ir/be/test/distributive.c b/ir/be/test/distributive.c
new file mode 100644 (file)
index 0000000..9c050dc
--- /dev/null
@@ -0,0 +1,37 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#define T_(op1, op2, va, vb, vc)       a = va; b = vb; c = vc; \
+       fprintf(stderr, "Test: (%d %s %d) %s (%d %s %d) -> ", a, #op1, c, #op2, b, #op1, c);\
+       fprintf(stderr, "%d\n", ((a op1 c) op2 (b op1 c)));
+
+#define T(op1, op2)    T_(op1, op2, rand(), rand(), rand()) T_(op1, op2, rand(), rand(), 42)
+
+#define TU_(op1, op2, va, vb)     a = va; b = vb; \
+       fprintf(stderr, "Test: (%s %d) %s (%s %d) -> ", #op1, a, #op2, #op1, b); \
+       fprintf(stderr, "%d\n", ((op1 a) op2 (op1 b)));
+
+#define TU(op1, op2) TU_(op1, op2, rand(), rand())
+
+#define TT(op) T(&,op); T(|,op); T(^,op); T(&&,op); T(||,op); T(*,op); T(/,op); T(%,op); T(+,op); T(-,op); TU(-,op); TU(!,op);
+
+#define TS(op)  T(&,op); T(|,op); T(^,op); T(&&,op); T(||,op); T(*,op); T(+,op); T(-,op); TU(-,op);
+
+int main()
+{
+       int a, b, c;
+       srand(1234);
+
+       TT(&);
+       TT(|);
+       TT(^);
+       TT(&&);
+       TT(||);
+       TT(*);
+       TS(/);
+       TS(%);
+       TT(+);
+       TT(-);
+
+       return 0;
+}