X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Ftest%2Flocalopts.c;h=2851d10705b8c087377323ff9b6e44acd38fccbd;hb=93da909d12b7bec51aa36ee5f05966c331f90fb9;hp=ef02a73c098c348feec2cd0737acfbcd36345774;hpb=f5a3f400ba7f56f419399b380e21c06146d0f09a;p=libfirm diff --git a/ir/be/test/localopts.c b/ir/be/test/localopts.c index ef02a73c0..2851d1070 100644 --- a/ir/be/test/localopts.c +++ b/ir/be/test/localopts.c @@ -1,5 +1,6 @@ /*$ -fno-inline $*/ #include +#include #define CONST 42 @@ -47,6 +48,11 @@ int sub4(int x) { return 6 - ~x; } +int addmul(int x, int y) +{ + +} + int cmp1(int x, int y) { return -x == -y; } @@ -87,6 +93,14 @@ int cmp10(int x) { return -x != 3; } +int cmp11(int x, int y) { + return x - y != x; +} + +int cmp12(int x, int y) { + return x + y == x && y + x == y; +} + int and1(int a, int b) { return (a|b)&a; } @@ -99,6 +113,22 @@ int and3(int a) { return (a & 2) == 2; } +int and4(int a) { + return (a & 2) == 4; +} + +int and5(int a) { + return (a & 2) != 4; +} + +int or1(int a) { + return (a | 2) != 0; +} + +int or2(int a) { + return (a | 7) == 0; +} + int add1(int x) { return x + ~x; } @@ -151,6 +181,46 @@ int shrs4(int a) { return (a >> 3) == (1 << 29); } +int conv1(signed char a) { + return (int)a < 0; +} + +int conv2(unsigned char a) { + return (int)a > 0; +} + +int conv3(signed char a) { + return (unsigned)a != 0; +} + +int phi1(int x) { + int a = x ? 23 : 42; + int b = x ? 42 : 23; + return a + b; +} + +int phi2(int x) { + int a = x ? 16 : 8; + int b = x ? 4 : 2; + return a / b; +} + +int phi3(int x) { + int a = x ? 5 : 9; + int b = x ? 2 : 4; + return a % b; +} + +int phi4(int x) { + int a = x ? 5 : 9; + int b = x ? 2 : 4; + return (a / b) + (a % b); +} + +int abs1(int x) { + return abs(-x); +} + int main(void) { #define TU(func,x,expect) \ @@ -179,6 +249,11 @@ int main(void) TT(cmp8, 42, 17, -4, 1); TU(cmp9, -3, 1); TU(cmp10, -3, 0); + TB(cmp11, 5, 5, 1); + TB(cmp11, 42, 0, 0); + TB(cmp12, 0, 0, 1); + TB(cmp12, 42, 5, 0); + TB(cmp12, 5, 5, 0); TB(and1, 42, 17, 42); TB(and2, 42, 17, 42^17); TU(and3, 34, 1); @@ -199,4 +274,16 @@ int main(void) TU(shrs3, -5<<3, 1); TU(shrs3, -6<<3, 0); TU(shrs4, 5, 0); + TU(conv1, 3, 0); + TU(conv2, 3, 1); + TU(conv3, 3, 1); + TU(and4, 7, 0); + TU(and5, 7, 1); + TU(or1, 7, 1); + TU(or2, 7, 0); + TU(phi1, 1, 65); + TU(phi2, 1, 4); + TU(phi3, 1, 1); + TU(phi4, 1, 3); + TU(abs1, 1, 1); }