re PR target/54089 ([SH] Refactor shift patterns)
[gcc.git] / gcc / testsuite / gcc.target / sh / pr54089-3.c
1 /* The dynamic shift library functions truncate the shift count to 5 bits.
2 Verify that this is taken into account and no extra shift count
3 truncations are generated before the library call. */
4 /* { dg-do compile { target "sh*-*-*" } } */
5 /* { dg-options "-O1" } */
6 /* { dg-skip-if "" { "sh*-*-*" } { "*" } { "-m1*" "-m2" "-m2e*" } } */
7 /* { dg-final { scan-assembler-not "and" } } */
8 /* { dg-final { scan-assembler-not "31" } } */
9
10 int
11 test00 (unsigned int a, int* b, int c, int* d, unsigned int e)
12 {
13 int s = 0;
14 int i;
15 for (i = 0; i < c; ++i)
16 s += d[i] + b[i] + (e << (i & 31));
17 return s;
18 }
19
20 int
21 test01 (unsigned int a, int* b, int c, int* d, unsigned int e)
22 {
23 int s = 0;
24 int i;
25 for (i = 0; i < c; ++i)
26 s += d[i] + b[i] + (e >> (i & 31));
27 return s;
28 }
29
30 int
31 test03 (unsigned int a, unsigned int b)
32 {
33 return b << (a & 31);
34 }
35
36 unsigned int
37 test04 (unsigned int a, int b)
38 {
39 return a >> (b & 31);
40 }