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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
/* Test the `vmaxnmf32' ARM Neon intrinsic. */
/* { dg-do run } */
/* { dg-require-effective-target arm_v8_neon_hw } */
/* { dg-options "-save-temps -O3 -march=armv8-a" } */
/* { dg-add-options arm_v8_neon } */
#include "arm_neon.h"
extern void abort ();
void __attribute__ ((noinline))
test_vmaxnm_f32__regular_input1 ()
{
float32_t a1[] = {1,2};
float32_t b1[] = {3,4};
float32x2_t a = vld1_f32 (a1);
float32x2_t b = vld1_f32 (b1);
float32x2_t c = vmaxnm_f32 (a, b);
float32_t actual[2];
vst1_f32 (actual, c);
for (int i = 0; i < 2; ++i)
if (actual[i] != b1[i])
abort ();
}
void __attribute__ ((noinline))
test_vmaxnm_f32__regular_input2 ()
{
float32_t a1[] = {3,2};
float32_t b1[] = {1,4};
float32_t e[] = {3,4};
float32x2_t a = vld1_f32 (a1);
float32x2_t b = vld1_f32 (b1);
float32x2_t c = vmaxnm_f32 (a, b);
float32_t actual[2];
vst1_f32 (actual, c);
for (int i = 0; i < 2; ++i)
if (actual[i] != e[i])
abort ();
}
void __attribute__ ((noinline))
test_vmaxnm_f32__quiet_NaN_one_arg ()
{
/* When given a quiet NaN, vmaxnm returns the other operand.
In this test case we have NaNs in only one operand. */
float32_t n = __builtin_nanf ("");
float32_t a1[] = {1,2};
float32_t b1[] = {n,n};
float32_t e[] = {1,2};
float32x2_t a = vld1_f32 (a1);
float32x2_t b = vld1_f32 (b1);
float32x2_t c = vmaxnm_f32 (a, b);
float32_t actual[2];
vst1_f32 (actual, c);
for (int i = 0; i < 2; ++i)
if (actual[i] != e[i])
abort ();
}
void __attribute__ ((noinline))
test_vmaxnm_f32__quiet_NaN_both_args ()
{
/* When given a quiet NaN, vmaxnm returns the other operand.
In this test case we have NaNs in both operands. */
float32_t n = __builtin_nanf ("");
float32_t a1[] = {n,2};
float32_t b1[] = {1,n};
float32_t e[] = {1,2};
float32x2_t a = vld1_f32 (a1);
float32x2_t b = vld1_f32 (b1);
float32x2_t c = vmaxnm_f32 (a, b);
float32_t actual[2];
vst1_f32 (actual, c);
for (int i = 0; i < 2; ++i)
if (actual[i] != e[i])
abort ();
}
void __attribute__ ((noinline))
test_vmaxnm_f32__zero_both_args ()
{
/* For 0 and -0, vmaxnm returns 0. Since 0 == -0, check sign bit. */
float32_t a1[] = {0.0, 0.0};
float32_t b1[] = {-0.0, -0.0};
float32_t e[] = {0.0, 0.0};
float32x2_t a = vld1_f32 (a1);
float32x2_t b = vld1_f32 (b1);
float32x2_t c = vmaxnm_f32 (a, b);
float32_t actual1[2];
vst1_f32 (actual1, c);
for (int i = 0; i < 2; ++i)
if (actual1[i] != e[i] || __builtin_signbit (actual1[i]) != 0)
abort ();
}
void __attribute__ ((noinline))
test_vmaxnm_f32__inf_both_args ()
{
/* The max of inf and inf is inf. The max of -inf and -inf is -inf. */
float32_t inf = __builtin_huge_valf ();
float32_t a1[] = {inf, -inf};
float32_t b1[] = {inf, -inf};
float32_t e[] = {inf, -inf};
float32x2_t a = vld1_f32 (a1);
float32x2_t b = vld1_f32 (b1);
float32x2_t c = vmaxnm_f32 (a, b);
float32_t actual1[2];
vst1_f32 (actual1, c);
for (int i = 0; i < 2; ++i)
if (actual1[i] != e[i])
abort ();
}
void __attribute__ ((noinline))
test_vmaxnm_f32__two_quiet_NaNs_both_args ()
{
/* When given 2 NaNs, return a NaN. Since a NaN is not equal to anything,
not even another NaN, use __builtin_isnan () to check. */
float32_t n = __builtin_nanf ("");
float32_t a1[] = {n,n};
float32_t b1[] = {n,n};
float32_t e[] = {n,n};
float32x2_t a = vld1_f32 (a1);
float32x2_t b = vld1_f32 (b1);
float32x2_t c = vmaxnm_f32 (a, b);
float32_t actual[2];
vst1_f32 (actual, c);
for (int i = 0; i < 2; ++i)
if (!__builtin_isnan (actual[i]))
abort ();
}
int
main ()
{
test_vmaxnm_f32__regular_input1 ();
test_vmaxnm_f32__regular_input2 ();
test_vmaxnm_f32__quiet_NaN_one_arg ();
test_vmaxnm_f32__quiet_NaN_both_args ();
test_vmaxnm_f32__zero_both_args ();
test_vmaxnm_f32__inf_both_args ();
test_vmaxnm_f32__two_quiet_NaNs_both_args ();
return 0;
}
/* { dg-final { scan-assembler-times "vmaxnm\.f32\t\[dD\]\[0-9\]+, ?\[dD\]\[0-9\]+, ?\[dD\]\[0-9\]+\n" 7 } } */
|