From 7413a13251eaeedb7e4a41b7110b9c064188816c Mon Sep 17 00:00:00 2001 From: Hans-Peter Nilsson Date: Thu, 22 Jul 2004 10:08:29 +0000 Subject: [PATCH] cris-peep2-xsrand.c, [...]: New tests. * gcc.dg/cris-peep2-xsrand.c, gcc.dg/cris-peep2-andu1.c, gcc.dg/cris-peep2-andu2.c: New tests. From-SVN: r85040 --- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/cris-peep2-andu1.c | 42 ++++++++++++++++++++++++ gcc/testsuite/gcc.dg/cris-peep2-andu2.c | 32 ++++++++++++++++++ gcc/testsuite/gcc.dg/cris-peep2-xsrand.c | 32 ++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/cris-peep2-andu1.c create mode 100644 gcc/testsuite/gcc.dg/cris-peep2-andu2.c create mode 100644 gcc/testsuite/gcc.dg/cris-peep2-xsrand.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 501da15db6f..650195c3ea2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-07-22 Hans-Peter Nilsson + + * gcc.dg/cris-peep2-xsrand.c, gcc.dg/cris-peep2-andu1.c, + gcc.dg/cris-peep2-andu2.c: New tests. + 2004-07-22 Joseph S. Myers PR c/15052 diff --git a/gcc/testsuite/gcc.dg/cris-peep2-andu1.c b/gcc/testsuite/gcc.dg/cris-peep2-andu1.c new file mode 100644 index 00000000000..2e546e6256d --- /dev/null +++ b/gcc/testsuite/gcc.dg/cris-peep2-andu1.c @@ -0,0 +1,42 @@ +/* { dg-do compile { target cris-*-* } } */ +/* { dg-final { scan-assembler-not "and.d " } } */ +/* { dg-final { scan-assembler-not "move.d " } } */ +/* { dg-final { scan-assembler "cLear.b" } } */ +/* { dg-final { scan-assembler "movu.b" } } */ +/* { dg-final { scan-assembler "and.b" } } */ +/* { dg-final { scan-assembler "movu.w" } } */ +/* { dg-final { scan-assembler "and.w" } } */ +/* { dg-final { scan-assembler "andq" } } */ +/* { dg-options "-O2" } */ + +/* Test the "andu" peephole2 trivially, memory operand. */ + +int +clearb (int x, int *y) +{ + return *y & 0xff00; +} + +int +andb (int x, int *y) +{ + return *y & 0x3f; +} + +int +andw (int x, int *y) +{ + return *y & 0xfff; +} + +int +andq (int x, int *y) +{ + return *y & 0xf0; +} + +int +andq2 (int x, int *y) +{ + return *y & 0xfff0; +} diff --git a/gcc/testsuite/gcc.dg/cris-peep2-andu2.c b/gcc/testsuite/gcc.dg/cris-peep2-andu2.c new file mode 100644 index 00000000000..4f687cc081c --- /dev/null +++ b/gcc/testsuite/gcc.dg/cris-peep2-andu2.c @@ -0,0 +1,32 @@ +/* { dg-do compile { target cris-*-* } } */ +/* { dg-final { scan-assembler "movu.w \\\$r10,\\\$r" } } */ +/* { dg-final { scan-assembler "and.w 2047,\\\$r" } } */ +/* { dg-final { scan-assembler-not "move.d \\\$r10,\\\$r" } } */ +/* { dg-final { scan-assembler "movu.b \\\$r10,\\\$r" } } */ +/* { dg-final { scan-assembler "and.b 95,\\\$r" } } */ +/* { dg-final { scan-assembler "andq -2,\\\$r" } } */ +/* { dg-options "-O2" } */ + +/* Test the "andu" peephole2 trivially, register operand. */ + +unsigned int +and_peep2_hi (unsigned int y, unsigned int *x) +{ + *x = y & 0x7ff; + return y; +} + +unsigned int +and_peep2_qi (unsigned int y, unsigned int *x) +{ + *x = y & 0x5f; + return y; +} + + +unsigned int +and_peep2_q (unsigned int y, unsigned int *x) +{ + *x = y & 0xfe; + return y; +} diff --git a/gcc/testsuite/gcc.dg/cris-peep2-xsrand.c b/gcc/testsuite/gcc.dg/cris-peep2-xsrand.c new file mode 100644 index 00000000000..9cfe40fb6e1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cris-peep2-xsrand.c @@ -0,0 +1,32 @@ +/* { dg-do compile { target cris-*-* } } */ +/* { dg-final { scan-assembler "and.w " } } */ +/* { dg-final { scan-assembler "and.b " } } */ +/* { dg-final { scan-assembler-not "and.d" } } */ +/* { dg-options "-O2" } */ + +/* Test the "asrandb", "asrandw", "lsrandb" and "lsrandw" peephole2:s + trivially. */ + +unsigned int +andwlsr (unsigned int x) +{ + return (x >> 17) & 0x7ff; +} + +unsigned int +andblsr (unsigned int x) +{ + return (x >> 25) & 0x5f; +} + +int +andwasr (int x) +{ + return (x >> 17) & 0x7ff; +} + +int +andbasr (int x) +{ + return (x >> 25) & 0x5f; +} -- 2.30.2