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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [tree-ssa/] [pr31966.c] - Blame information for rev 298

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* Contributed by Jack Lloyd  <lloyd@randombit.net> */
2
 
3
/* { dg-options "-O2 -ftree-vectorize" } */
4
/* { dg-options "-O2 -ftree-vectorize -march=nocona" { target { i?86-*-* x86_64-*-* } } } */
5
 
6
typedef unsigned long long word;
7
 
8
const unsigned int MP_WORD_BITS = 64;
9
const word MP_WORD_MASK = ~((word)0);
10
const word MP_WORD_TOP_BIT = (word)1 << (8*sizeof(word) - 1);
11
 
12
extern void abort (void);
13
 
14
word do_div(word n1, word n0, word d)
15
{
16
  word high = n1 % d, quotient = 0;
17
  unsigned int j;
18
 
19
  for(j = 0; j != MP_WORD_BITS; ++j)
20
    {
21
      word high_top_bit = (high & MP_WORD_TOP_BIT);
22
 
23
      high <<= 1;
24
      high |= (n0 >> (MP_WORD_BITS-1-j)) & 1;
25
      quotient <<= 1;
26
 
27
      if(high_top_bit || high >= d)
28
        {
29
          high -= d;
30
          quotient |= 1;
31
        }
32
    }
33
 
34
  return quotient;
35
}
36
 
37
int main()
38
{
39
  word result;
40
 
41
  result = do_div(0x0000000000200000ll,
42
                  0x0000000000000000ll,
43
                  0x86E53497CE000000ll);
44
 
45
 
46
  if (result != 0x3CBA83)
47
    abort ();
48
 
49
  return 0;
50
}

powered by: WebSVN 2.1.0

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