2017-06-09 Tamar Christina <tamar.christina@arm.com>
[official-gcc.git] / gcc / testsuite / gcc.target / arm / sdiv_costs_1.c
blob76086ab9ce28fceb37a4e8a615a38923fa7b985a
1 /* { dg-do compile } */
2 /* { dg-options "-O3 -march=armv8-a" } */
4 /* Both sdiv and udiv can be used here, so prefer udiv. */
5 int f1 (unsigned char *p)
7 return 100 / p[1];
10 int f2 (unsigned char *p, unsigned short x)
12 return x / p[0];
15 int f3 (unsigned char *p, int x)
17 x &= 0x7fffffff;
18 return x / p[0];
21 int f5 (unsigned char *p, unsigned short x)
23 return x % p[0];
26 /* This should only generate signed divisions. */
27 int f4 (unsigned char *p)
29 return -100 / p[1];
32 int f6 (unsigned char *p, short x)
34 return x % p[0];
37 /* { dg-final { scan-assembler-times "udiv\tr\[0-9\]+, r\[0-9\]+, r\[0-9\]+" 4 } } */
38 /* { dg-final { scan-assembler-times "sdiv\tr\[0-9\]+, r\[0-9\]+, r\[0-9\]+" 2 } } */