more tests for localopts
authorMatthias Braun <matze@braunis.de>
Thu, 13 Sep 2007 12:23:41 +0000 (12:23 +0000)
committerMatthias Braun <matze@braunis.de>
Thu, 13 Sep 2007 12:23:41 +0000 (12:23 +0000)
[r15780]

ir/be/test/localopts.c [new file with mode: 0644]

diff --git a/ir/be/test/localopts.c b/ir/be/test/localopts.c
new file mode 100644 (file)
index 0000000..90b8cef
--- /dev/null
@@ -0,0 +1,39 @@
+/*$ -fno-inline $*/
+#include <stdio.h>
+
+#define CONST 42
+
+int mul0(int x)
+{
+       return -x * CONST;
+}
+
+int mul1(int x, int y)
+{
+       return -x * -y;
+}
+
+int mul2(int x, int y, int z)
+{
+       return -x * (y - z);
+}
+
+int mul3(int x, int y, int z)
+{
+       return (x - y) * z;
+}
+
+int main(void)
+{
+#define TU(func,x,expect) \
+       printf("%s(%d) = %d (should be %d)\n", #func, x, func(x), expect);
+#define TB(func,x,y,expect) \
+       printf("%s(%d,%d) = %d (should be %d)\n", #func, x, y, func(x,y), expect);
+#define TT(func,x,y,z,expect) \
+       printf("%s(%d,%d,%d) = %d (should be %d)\n", #func, x, y, z, func(x,y,z), expect);
+
+       TU(mul0, 3, -126);
+       TB(mul1, 20, 3, 60);
+       TT(mul2, 9, 2, 5, 27);
+       TT(mul3, 5, 2, 9, 27);
+}