OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [divconst-2.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
long
2
f (long x)
3
{
4
  return x / (-0x7fffffffL - 1L);
5
}
6
 
7
long
8
r (long x)
9
{
10
  return x % (-0x7fffffffL - 1L);
11
}
12
 
13
/* Since we have a negative divisor, this equation must hold for the
14
   results of / and %; no specific results are guaranteed.  */
15
long
16
std_eqn (long num, long denom, long quot, long rem)
17
{
18
  /* For completeness, a check for "ABS (rem) < ABS (denom)" belongs here,
19
     but causes trouble on 32-bit machines and isn't worthwhile.  */
20
  return quot * (-0x7fffffffL - 1L) + rem == num;
21
}
22
 
23
long nums[] =
24
{
25
  -1L, 0x7fffffffL, -0x7fffffffL - 1L
26
};
27
 
28
main ()
29
{
30
  int i;
31
 
32
  for (i = 0;
33
       i < sizeof (nums) / sizeof (nums[0]);
34
       i++)
35
    if (std_eqn (nums[i], -0x7fffffffL - 1L, f (nums[i]), r (nums[i])) == 0)
36
      abort ();
37
 
38
  exit (0);
39
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.