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.target/] [mips/] [mips-3d-1.c] - Blame information for rev 321

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 321 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-O2 -mips3d" } */
3
 
4
/* Test MIPS-3D builtin functions */
5
#include <stdlib.h>
6
#include <stdio.h>
7
 
8
typedef float v2sf __attribute__ ((vector_size(8)));
9
 
10
NOMIPS16 int main ()
11
{
12
  int little_endian;
13
  v2sf a, b, c, d;
14
  float f1, f2, f3, f4, f5, f6;
15
  double d1, d2, d3, d4, d5, d6, d7, d8, d9;
16
  v2sf ps1, ps2, ps3, ps4, ps5, ps6;
17
 
18
  union { long long ll; int i[2]; } endianness_test;
19
  endianness_test.ll = 1;
20
  little_endian = endianness_test.i[0];
21
 
22
  /* addr.ps */
23
  a = (v2sf) {12, 34};
24
  b = (v2sf) {45, 67};
25
  c = __builtin_mips_addr_ps (a, b);
26
  if (little_endian)
27
    d = (v2sf) {112, 46};
28
  else
29
    d = (v2sf) {46, 112};
30
 
31
  if (!__builtin_mips_all_c_eq_ps(c, d))
32
     abort ();
33
 
34
  /* mulr.ps */
35
  a = (v2sf) {12, 34};
36
  b = (v2sf) {45, 67};
37
  c = __builtin_mips_mulr_ps (a, b);
38
  if (little_endian)
39
    d = (v2sf) {3015, 408};
40
  else
41
    d = (v2sf) {408, 3015};
42
 
43
  if (!__builtin_mips_all_c_eq_ps(c, d))
44
     abort ();
45
 
46
  /* cvt.pw.ps */
47
  a = (v2sf) {12345.34, 67890.45};
48
  b = __builtin_mips_cvt_pw_ps (a);
49
 
50
  /* cvt.ps.pw */
51
  c = __builtin_mips_cvt_ps_pw (b);
52
  d = (v2sf) {12345.0, 67890.0};
53
 
54
  if (!__builtin_mips_all_c_eq_ps(c, d))
55
     abort ();
56
 
57
  /* recip1.s recip2.s */
58
  f1 = 40;
59
  f2 = __builtin_mips_recip1_s (f1);
60
  f3 = __builtin_mips_recip2_s (f2, f1);
61
  f4 = f2 + f2 * f3;
62
  f5 = 0.025;
63
 
64
  if (f4 != f5)
65
    abort ();
66
 
67
  /* recip1.d recip2.d */
68
  d1 = 80;
69
  d2 = __builtin_mips_recip1_d (d1);
70
  d3 = __builtin_mips_recip2_d (d2, d1);
71
  d4 = d2 + d2 * d3;
72
  d5 = __builtin_mips_recip2_d (d4, d1);
73
  d6 = d4 + d4 * d5;
74
  d7 = 0.0125;
75
 
76
  if (d6 != d7)
77
    abort ();
78
 
79
  /* recip1.ps recip2.ps */
80
  ps1 = (v2sf) {100, 200};
81
  ps2 = __builtin_mips_recip1_ps (ps1);
82
  ps3 = __builtin_mips_recip2_ps (ps2, ps1);
83
  ps4 = ps2 + ps2 * ps3;
84
  ps5 = (v2sf) {0.01, 0.005};
85
 
86
  if (!__builtin_mips_all_c_eq_ps(ps4, ps5))
87
    abort ();
88
 
89
  /* rsqrt1.s rsqrt2.s */
90
  f1 = 400;
91
  f2 = __builtin_mips_rsqrt1_s (f1);
92
  f3 = f2 * f1;
93
  f4 = __builtin_mips_rsqrt2_s (f3, f2);
94
  f5 = f2 + f2 * f4;
95
  f6 = 0.05;
96
 
97
  if (f5 != f6)
98
    abort ();
99
 
100
  /* rsqrt1.d rsqrt2.d */
101
  d1 = 1600;
102
  d2 = __builtin_mips_rsqrt1_d (d1);
103
  d3 = d2 * d1;
104
  d4 = __builtin_mips_rsqrt2_d (d3, d2);
105
  d5 = d2 + d2 * d4;
106
  d6 = d1 * d5;
107
  d7 = __builtin_mips_rsqrt2_d (d6, d5);
108
  d8 = d5 + d5 * d7;
109
  d9 = 0.025;
110
 
111
  if (d8 != d9)
112
    abort ();
113
 
114
  /* rsqrt1.ps rsqrt2.ps */
115
  ps1 = (v2sf) {400, 100};
116
  ps2 = __builtin_mips_rsqrt1_ps (ps1);
117
  ps3 = ps2 * ps1;
118
  ps4 = __builtin_mips_rsqrt2_ps (ps3, ps2);
119
  ps5 = ps2 + ps2 * ps4;
120
  ps6 = (v2sf) {0.05, 0.1};
121
 
122
  if (!__builtin_mips_all_c_eq_ps(ps5, ps6))
123
     abort ();
124
 
125
  printf ("Test Passes\n");
126
  exit (0);
127
}

powered by: WebSVN 2.1.0

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