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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.dg/] [tree-ssa/] [pr32327.C] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
// { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } }
2
// { dg-options "-O2" }
3
 
4
typedef unsigned long long uint64;
5
typedef __SIZE_TYPE__ size_t;
6
 
7
extern "C" {
8
extern void *memcpy (void *__restrict __dest,
9
      __const void *__restrict __src, size_t __n) /*throw ()*/;
10
extern void abort (void);
11
}
12
 
13
extern void foo (void* p);
14
 
15
inline uint64
16
ghtonll(uint64 x)
17
{
18
 // __r is allocated the same stack slot as dest below
19
 union { unsigned long long int __ll;
20
         unsigned long int __l[2]; } __w, __r;
21
 __w.__ll = x;
22
 __r.__l[0] = (
23
   {
24
     register unsigned int __v;
25
     __asm__ __volatile__ ("bswap %0" : "=r" (__v) :
26
                           "0" ((unsigned int) (__w.__l[1])));
27
     __v; });
28
 
29
 __r.__l[1] = (
30
   {
31
     register unsigned int __v;
32
     __asm__ __volatile__ ("bswap %0" : "=r" (__v) :
33
                           "0" ((unsigned int) (__w.__l[0])));
34
     __v; });
35
 
36
 return __r.__ll;
37
}
38
 
39
inline uint64
40
double_2_uint64 (const double *source)
41
{
42
 uint64 dest;  // allocated the same stack slot as __r above
43
 memcpy(&dest, source, sizeof(dest));
44
 return dest;
45
}
46
 
47
inline void
48
KeyFromUint64(uint64 fp) {
49
 uint64 norder;
50
 norder = ghtonll (fp);
51
 foo((char*)(&norder));
52
}
53
 
54
void
55
KeyFromDouble(double x) {
56
 uint64 n = double_2_uint64 (&x);
57
 if (n >= 42) {
58
   n += 1;
59
 }
60
 
61
 KeyFromUint64(n);
62
}
63
 
64
#define NUM             0x0123456789abcdefll
65
#define EXPECTED        0xe0bc9a7856347243ll
66
 
67
void foo (void *x)
68
{
69
  if (*((uint64 *)x) != (uint64) EXPECTED)
70
    abort ();
71
}
72
 
73
int main ()
74
{
75
  if (sizeof (double) != sizeof (uint64))
76
    return 0;
77
 
78
  if (sizeof (uint64) == sizeof (unsigned long int))
79
    return 0;
80
 
81
  KeyFromDouble ((double)NUM);
82
 
83
  return 0;
84
}

powered by: WebSVN 2.1.0

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