2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / testsuite / gcc.target / sh / pr54089-2.c
blobe6d6a0ed8e5ffcfaea5e81127b46457c9ee8c2dd
1 /* Check that for dynamic logical right shifts with a constant the negated
2 constant is loaded directly, instead of loading the postitive constant
3 and negating it separately. This was a case that happened at optimization
4 level -O2 and looked like:
5 cmp/eq r6,r5
6 mov #30,r1
7 neg r1,r1
8 shld r1,r4
9 mov r4,r0
10 rts
11 rotcr r0 */
12 /* { dg-do compile { target { has_dyn_shift } } } */
13 /* { dg-options "-O2" } */
14 /* { dg-final { scan-assembler-not "neg" } } */
16 unsigned int
17 test (unsigned int a, int b, int c)
19 unsigned char r = b == c;
20 return ((a >> 31) | (r << 31));