Debian Codegraph @

gcc/testsuite/g++.target/loongarch/vect-copysign-negconst-run.C

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2 -march=loongarch64 -mlasx -mno-strict-align" } */
3 /* { dg-require-effective-target loongarch_asx_hw } */
4
5 #include "vect-copysign-negconst.C"
6
7 double d[] = {1.2, -3.4, -5.6, 7.8};
8 float f[] = {1.2, -3.4, -5.6, 7.8, -9.0, -11.4, 51.4, 1919.810};
9
10 double _abs(double x) { return __builtin_fabs (x); }
11 float _abs(float x) { return __builtin_fabsf (x); }
12
13 template <class T>
14 void
15 check (T *arr, T *orig, int len)
16 {
17 for (int i = 0; i < len; i++)
18 {
19 if (arr[i] > 0)
20 __builtin_trap ();
21 if (_abs (arr[i]) != _abs (orig[i]))
22 __builtin_trap ();
23 }
24 }
25
26 int
27 main()
28 {
29 double test_d[4];
30 float test_f[8];
31
32 __builtin_memcpy (test_d, d, sizeof (test_d));
33 force_negative<2> (test_d);
34 check (test_d, d, 2);
35
36 __builtin_memcpy (test_d, d, sizeof (test_d));
37 force_negative<4> (test_d);
38 check (test_d, d, 4);
39
40 __builtin_memcpy (test_f, f, sizeof (test_f));
41 force_negative<4> (test_f);
42 check (test_f, f, 4);
43
44 __builtin_memcpy (test_f, f, sizeof (test_f));
45 force_negative<8> (test_f);
46 check (test_f, f, 8);
47 }