diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2012-01-14 14:23:26 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2012-01-14 14:23:26 +0000 |
commit | a82c9c0e4a0b8e37c9c3ea5ae99714982563606f (patch) | |
tree | 93b9999698a4cd47ec4cb5fcdcdfd215d62f8e9e /test/regression | |
parent | bb8f49c419eb8205ef541edcbe17f4d14aa99564 (diff) |
Merge of the nonstrict-ops branch:
- Most RTL operators now evaluate to Some Vundef instead of None
when undefined behavior occurs.
- More aggressive instruction selection.
- "Bertotization" of pattern-matchings now implemented by a proper preprocessor.
- Cast optimization moved to cfrontend/Cminorgen; removed backend/CastOptim.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1790 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/regression')
-rw-r--r-- | test/regression/Makefile | 3 | ||||
-rw-r--r-- | test/regression/Results/instrsel | 6 | ||||
-rw-r--r-- | test/regression/instrsel.c | 140 |
3 files changed, 148 insertions, 1 deletions
diff --git a/test/regression/Makefile b/test/regression/Makefile index 044e593..f3dcf4d 100644 --- a/test/regression/Makefile +++ b/test/regression/Makefile @@ -11,7 +11,8 @@ TESTS=attribs1 bitfields1 bitfields2 bitfields3 bitfields4 \ bitfields5 bitfields6 bitfields7 \ expr1 expr6 initializers volatile1 volatile2 volatile3 \ funct3 expr5 struct7 struct8 struct11 casts1 casts2 char1 \ - sizeof1 sizeof2 packedstruct1 packedstruct2 + sizeof1 sizeof2 packedstruct1 packedstruct2 \ + instrsel # Other tests: should compile to .s without errors (but expect warnings) EXTRAS=annot1 commaprec expr2 expr3 expr4 extern1 funct2 funptr1 init1 \ diff --git a/test/regression/Results/instrsel b/test/regression/Results/instrsel new file mode 100644 index 0000000..97d1a9d --- /dev/null +++ b/test/regression/Results/instrsel @@ -0,0 +1,6 @@ +bres = 135 214 210 255 135 135 135 135 135 135 +sbres = 12 -4 -46 -1 -121 -121 -121 -121 -121 0 +sres = 12 65532 1234 65279 54919 135 65415 54919 54919 135 +ssres = 12 -4 1234 -257 -10617 135 -121 -10617 -10617 0 +res = 135 -121 135 -121 54919 -10617 54919 -10617 135 135 -121 -121 135 135 -121 65415 12 12 12 -4 -4 1234 -257 0 135 12 12 12 12 12 243 0 44478 173 214 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +fres = 2.5 -3.14159 -3.14159 0 0 0 0 0 0 0 diff --git a/test/regression/instrsel.c b/test/regression/instrsel.c new file mode 100644 index 0000000..0dbe5e3 --- /dev/null +++ b/test/regression/instrsel.c @@ -0,0 +1,140 @@ +/* Testing instruction selection and cast optimizations */ + +typedef unsigned char U8; +typedef signed char S8; +typedef unsigned short U16; +typedef signed short S16; + +U8 b, bres[10]; +S8 sb, sbres[10]; +U16 s, sres[10]; +S16 ss, ssres[10]; +int i, res[50]; +unsigned int ui; +float f, fres[10]; +double d, dres[10]; + +#ifdef __COMPCERT__ +#define TEST(x) __builtin_annot(#x); x +#else +#define TEST(x) x +#endif + +void test(void) +{ + /* Telescoping casts */ + TEST(res[0] = (U8) (U8) i); + TEST(res[1] = (S8) (U8) i); + TEST(res[2] = (U8) (S8) i); + TEST(res[3] = (S8) (S8) i); + TEST(res[4] = (U16) (U16) i); + TEST(res[5] = (S16) (U16) i); + TEST(res[6] = (U16) (S16) i); + TEST(res[7] = (S16) (S16) i); + TEST(res[8] = (U16) (U8) i); + TEST(res[9] = (U8) (U16) i); + TEST(res[10] = (S16) (S8) i); + TEST(res[11] = (S8) (S16) i); + TEST(res[12] = (S16) (U8) i); + TEST(res[13] = (U8) (S16) i); + TEST(res[14] = (S8) (U16) i); + TEST(res[15] = (U16) (S8) i); + TEST(dres[0] = (float) (float) d); + /* Redundant casts after a load */ + TEST(res[16] = (U8) b); + TEST(res[17] = (U16) b); + TEST(res[18] = (S16) b); + TEST(res[19] = (S8) sb); + TEST(res[20] = (S16) sb); + TEST(res[21] = (U16) s); + TEST(res[22] = (S16) ss); + TEST(dres[1] = (float) f); + /* Redundant casts before a store */ + TEST(bres[0] = b); + TEST(bres[1] = sb); + TEST(bres[2] = s); + TEST(bres[3] = ss); + TEST(bres[4] = i); + TEST(bres[5] = (U8) i); + TEST(bres[6] = (S8) i); + TEST(bres[7] = (U16) i); + TEST(bres[8] = (S16) i); + TEST(bres[9] = i & 0xFF); + TEST(sbres[0] = b); + TEST(sbres[1] = sb); + TEST(sbres[2] = s); + TEST(sbres[3] = ss); + TEST(sbres[4] = i); + TEST(sbres[5] = (U8) i); + TEST(sbres[6] = (S8) i); + TEST(sbres[7] = (U16) i); + TEST(sbres[8] = (S16) i); + TEST(sres[0] = b); + TEST(sres[1] = sb); + TEST(sres[2] = s); + TEST(sres[3] = ss); + TEST(sres[4] = i); + TEST(sres[5] = (U8) i); + TEST(sres[6] = (S8) i); + TEST(sres[7] = (U16) i); + TEST(sres[8] = (S16) i); + TEST(sres[9] = i & 0xFF); + TEST(sres[10] = i & 0xFFFF); + TEST(ssres[0] = b); + TEST(ssres[1] = sb); + TEST(ssres[2] = s); + TEST(ssres[3] = ss); + TEST(ssres[4] = i); + TEST(ssres[5] = (U8) i); + TEST(ssres[6] = (S8) i); + TEST(ssres[7] = (U16) i); + TEST(ssres[8] = (S16) i); + TEST(fres[0] = f); + TEST(fres[1] = d); + TEST(fres[2] = (float) d); + /* Bitwise operations */ + TEST(res[23] = (U8) (b & 1)); + TEST(res[24] = (U8) (i & 0xFF)); + TEST(res[25] = (U8) (b & 0xFFFF)); + TEST(res[26] = (U8) (b & b)); + TEST(res[27] = (U8) (b | b)); + TEST(res[28] = (U8) (b | 0x8)); + TEST(res[29] = (U8) (b & b)); + TEST(res[30] = (U8) (b ^ 0xFF)); + TEST(res[31] = (U8) (b ^ b)); + /* Combining unsigned shifts */ + TEST(res[32] = (ui << 8) >> 16); + TEST(res[33] = (ui >> 16) & 0xFF); + /* Combining signed shifts */ + TEST(res[34] = (U8) ((i >> 8) & 0xFF)); + TEST(res[35] = (U8) (i >> 24)); +} + +#include <stdio.h> + +int main() +{ + int n; + b = 12; sb = -4; s = 1234; ss = -257; i = 1234567; ui = 0xDEADBEEF; + f = 2.5; d = -3.14159; + test(); + printf("bres = "); + for (n = 0; n < 10; n++) printf("%d ", bres[n]); + printf("\n"); + printf("sbres = "); + for (n = 0; n < 10; n++) printf("%d ", sbres[n]); + printf("\n"); + printf("sres = "); + for (n = 0; n < 10; n++) printf("%d ", sres[n]); + printf("\n"); + printf("ssres = "); + for (n = 0; n < 10; n++) printf("%d ", ssres[n]); + printf("\n"); + printf("res = "); + for (n = 0; n < 50; n++) printf("%d ", res[n]); + printf("\n"); + printf("fres = "); + for (n = 0; n < 10; n++) printf("%g ", fres[n]); + printf("\n"); + return 0; +} |