summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/cris/peep2-xsrand.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.target/cris/peep2-xsrand.c')
-rw-r--r--gcc/testsuite/gcc.target/cris/peep2-xsrand.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/cris/peep2-xsrand.c b/gcc/testsuite/gcc.target/cris/peep2-xsrand.c
new file mode 100644
index 000000000..df0e76886
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/peep2-xsrand.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { 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;
+}