aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/s390/combine-shift-rotate-add-mod.c
blob: dc63bfa148161a75a30d19b8bb16a2bb01d4cd1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* Check shift via address-style displacement.  There should not be any
   and operations that the instructions perform implicitly anyway.*/

/* { dg-options "-O1 -m64" } */

/* { dg-final { scan-assembler-not "risbg\t%r.+,.*63" } } */
/* { dg-final { scan-assembler "rllg\t%r.+,3.%r.+" } } */
/* { dg-final { scan-assembler "sllg\t%r.+,2.%r.+" } } */

unsigned long rotlmodp (unsigned long in, unsigned long sh)
{
   sh = (sh + 3) % 64;
   return (in << sh) | (in >> (64 - sh));
}

unsigned long shiftmodp (unsigned long in, unsigned long sh)
{
   sh = (sh + 2) % 64;
   return (in << sh);
}

/* We expect a displacement of 1 here since combine simplifies
   modulo 255 when substituting into a QImode subreg.  */
/* { dg-final { scan-assembler "sllg\t%r.+,1.%r.+" } } */
unsigned long shiftp (unsigned long in, unsigned long sh)
{
   sh = sh + 4097;
   return (in << sh);
}