2017-06-12 Tamar Christina <tamar.christina@arm.com>
[official-gcc.git] / gcc / testsuite / gcc.target / arm / sdiv_costs_1.c
blob2ef397e22ca1643685ec7af31f76201746df5015
1 /* { dg-do compile } */
2 /* { dg-options "-O3 -march=armv8-a" } */
3 /* { dg-require-effective-target arm_hard_vfp_ok } */
5 /* Both sdiv and udiv can be used here, so prefer udiv. */
6 int f1 (unsigned char *p)
8 return 100 / p[1];
11 int f2 (unsigned char *p, unsigned short x)
13 return x / p[0];
16 int f3 (unsigned char *p, int x)
18 x &= 0x7fffffff;
19 return x / p[0];
22 int f5 (unsigned char *p, unsigned short x)
24 return x % p[0];
27 /* This should only generate signed divisions. */
28 int f4 (unsigned char *p)
30 return -100 / p[1];
33 int f6 (unsigned char *p, short x)
35 return x % p[0];
38 /* { dg-final { scan-assembler-times "udiv\tr\[0-9\]+, r\[0-9\]+, r\[0-9\]+" 4 } } */
39 /* { dg-final { scan-assembler-times "sdiv\tr\[0-9\]+, r\[0-9\]+, r\[0-9\]+" 2 } } */