aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/pr108338.c
blob: 5f2f62866ee1c0016e5d60a6c66581ec624d3b94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* { dg-do run } */
/* { dg-require-effective-target hard_float } */
/* { dg-options "-O2 -save-temps" } */

/* Under lp64, parameter 'v' is in DI regs, then bitcast sub DI to SF. */
/* { dg-final { scan-assembler-times {\mxscvspdpn\M} 2 { target { lp64 && has_arch_pwr8 } } } } */
/* { dg-final { scan-assembler-times {\mmtvsrd\M} 2 { target { lp64 && { has_arch_pwr8 && { ! has_arch_pwr9 } } } } } } */
/* { dg-final { scan-assembler-times {\mmtvsrd\M} 1 { target { lp64 && has_arch_pwr9 } } } } */
/* { dg-final { scan-assembler-times {\mmtvsrws\M} 1 { target { lp64 && has_arch_pwr9 } } } } */
/* { dg-final { scan-assembler-times {\mrldicr\M} 1 { target { lp64 && has_arch_pwr8 } } } } */
/* { dg-final { scan-assembler-times {\msldi\M} 1 { target { lp64 && { has_arch_pwr8 && { ! has_arch_pwr9 } } } } } } */

struct di_sf_sf
{
  float f1; float f2; long long l;
};

float __attribute__ ((noipa))
sf_from_high32bit_di (struct di_sf_sf v)
{
#ifdef __LITTLE_ENDIAN__
  return v.f2;
#else
  return v.f1;
#endif
}

float __attribute__ ((noipa))
sf_from_low32bit_di (struct di_sf_sf v)
{
#ifdef __LITTLE_ENDIAN__
  return v.f1;
#else
  return v.f2;
#endif
}

int main()
{
  struct di_sf_sf v;
  v.f1 = v.f2 = 0.0f;
#ifdef __LITTLE_ENDIAN__
  v.f1 = 1.0f;
  v.f2 = 2.0f;
#else
  v.f1 = 2.0f;
  v.f2 = 1.0f;
#endif
  if (sf_from_high32bit_di (v) != 2.0f || sf_from_low32bit_di (v) != 1.0f)
    __builtin_abort ();
  return 0;
}