From 67e3d2b7b9c3cc2b406fce8b159ba357107b89c5 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 13 Sep 2007 12:23:41 +0000 Subject: [PATCH] more tests for localopts [r15780] --- ir/be/test/localopts.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 ir/be/test/localopts.c diff --git a/ir/be/test/localopts.c b/ir/be/test/localopts.c new file mode 100644 index 000000000..90b8cefe8 --- /dev/null +++ b/ir/be/test/localopts.c @@ -0,0 +1,39 @@ +/*$ -fno-inline $*/ +#include + +#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); +} -- 2.20.1