Example #1
0
void exec_vceq_p8(void)
{
  DECL_VARIABLE(vector, poly, 8, 8);
  DECL_VARIABLE(vector, poly, 8, 16);

  DECL_VARIABLE(vector2, poly, 8, 8);
  DECL_VARIABLE(vector2, poly, 8, 16);

  DECL_VARIABLE(vector_res, uint, 8, 8);
  DECL_VARIABLE(vector_res, uint, 8, 16);

  clean_results ();

  VLOAD(vector, buffer, , poly, p, 8, 8);
  VLOAD(vector, buffer, q, poly, p, 8, 16);

  VDUP(vector2, , poly, p, 8, 8, 0xF3);
  VDUP(vector2, q, poly, p, 8, 16, 0xF4);

  TEST_VCOMP(INSN_NAME, , poly, p, uint, 8, 8);
  TEST_VCOMP(INSN_NAME, q, poly, p, uint, 8, 16);

  CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_p8, "p8");
  CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_q_p8, "p8");
}
int main (void)
{
  DECL_VARIABLE_128BITS_VARIANTS(vreint_vector);
  DECL_VARIABLE(vreint_vector, poly, 64, 2);
  DECL_VARIABLE_128BITS_VARIANTS(vreint_vector_res);
  DECL_VARIABLE(vreint_vector_res, poly, 64, 2);

  clean_results ();

  TEST_MACRO_128BITS_VARIANTS_2_5(VLOAD, vreint_vector, buffer);
  VLOAD(vreint_vector, buffer, q, poly, p, 64, 2);
  VLOAD(vreint_vector, buffer, q, float, f, 16, 8);
  VLOAD(vreint_vector, buffer, q, float, f, 32, 4);

  /* vreinterpretq_p128_* tests.  */
#undef TEST_MSG
#define TEST_MSG "VREINTERPRETQ_P128_*"

  /* Since there is no way to store a poly128_t value, convert to
     poly64x2_t before storing. This means that we are not able to
     test vreinterpretq_p128* alone, and that errors in
     vreinterpretq_p64_p128 could compensate for errors in
     vreinterpretq_p128*.  */
#define TEST_VREINTERPRET128(Q, T1, T2, W, N, TS1, TS2, WS, NS, EXPECTED) \
  VECT_VAR(vreint_vector_res, poly, 64, 2) =  vreinterpretq_p64_p128(	\
    vreinterpret##Q##_##T2##W##_##TS2##WS(VECT_VAR(vreint_vector, TS1, WS, NS))); \
  vst1##Q##_##T2##64(VECT_VAR(result, poly, 64, 2),			\
                     VECT_VAR(vreint_vector_res, poly, 64, 2));		\
  CHECK(TEST_MSG, T1, 64, 2, PRIx##64, EXPECTED, "");

  TEST_VREINTERPRET128(q, poly, p, 128, 1, int, s, 8, 16, vreint_expected_q_p128_s8);
  TEST_VREINTERPRET128(q, poly, p, 128, 1, int, s, 16, 8, vreint_expected_q_p128_s16);
  TEST_VREINTERPRET128(q, poly, p, 128, 1, int, s, 32, 4, vreint_expected_q_p128_s32);
  TEST_VREINTERPRET128(q, poly, p, 128, 1, int, s, 64, 2, vreint_expected_q_p128_s64);
  TEST_VREINTERPRET128(q, poly, p, 128, 1, uint, u, 8, 16, vreint_expected_q_p128_u8);
  TEST_VREINTERPRET128(q, poly, p, 128, 1, uint, u, 16, 8, vreint_expected_q_p128_u16);
  TEST_VREINTERPRET128(q, poly, p, 128, 1, uint, u, 32, 4, vreint_expected_q_p128_u32);
  TEST_VREINTERPRET128(q, poly, p, 128, 1, uint, u, 64, 2, vreint_expected_q_p128_u64);
  TEST_VREINTERPRET128(q, poly, p, 128, 1, poly, p, 8, 16, vreint_expected_q_p128_p8);
  TEST_VREINTERPRET128(q, poly, p, 128, 1, poly, p, 16, 8, vreint_expected_q_p128_p16);
  TEST_VREINTERPRET128(q, poly, p, 128, 1, float, f, 16, 8, vreint_expected_q_p128_f16);
  TEST_VREINTERPRET128(q, poly, p, 128, 1, float, f, 32, 4, vreint_expected_q_p128_f32);

  /* vreinterpretq_*_p128 tests.  */
#undef TEST_MSG
#define TEST_MSG "VREINTERPRETQ_*_P128"

  /* Since there is no way to load a poly128_t value, load a
     poly64x2_t and convert it to poly128_t. This means that we are
     not able to test vreinterpretq_*_p128 alone, and that errors in
     vreinterpretq_p128_p64 could compensate for errors in
     vreinterpretq_*_p128*.  */
#define TEST_VREINTERPRET_FROM_P128(Q, T1, T2, W, N, TS1, TS2, WS, NS, EXPECTED) \
  VECT_VAR(vreint_vector_res, T1, W, N) =				\
    vreinterpret##Q##_##T2##W##_##TS2##WS(				\
  vreinterpretq_p128_p64(VECT_VAR(vreint_vector, TS1, 64, 2)));		\
  vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N),				\
		    VECT_VAR(vreint_vector_res, T1, W, N));		\
  CHECK(TEST_MSG, T1, W, N, PRIx##W, EXPECTED, "");

#define TEST_VREINTERPRET_FP_FROM_P128(Q, T1, T2, W, N, TS1, TS2, WS, NS, EXPECTED) \
  VECT_VAR(vreint_vector_res, T1, W, N) =				\
    vreinterpret##Q##_##T2##W##_##TS2##WS(				\
  vreinterpretq_p128_p64(VECT_VAR(vreint_vector, TS1, 64, 2)));		\
  vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N),				\
		    VECT_VAR(vreint_vector_res, T1, W, N));		\
  CHECK_FP(TEST_MSG, T1, W, N, PRIx##W, EXPECTED, "");

  TEST_VREINTERPRET_FROM_P128(q, int, s, 8, 16, poly, p, 128, 1, vreint_expected_q_s8_p128);
  TEST_VREINTERPRET_FROM_P128(q, int, s, 16, 8, poly, p, 128, 1, vreint_expected_q_s16_p128);
  TEST_VREINTERPRET_FROM_P128(q, int, s, 32, 4, poly, p, 128, 1, vreint_expected_q_s32_p128);
  TEST_VREINTERPRET_FROM_P128(q, int, s, 64, 2, poly, p, 128, 1, vreint_expected_q_s64_p128);
  TEST_VREINTERPRET_FROM_P128(q, uint, u, 8, 16, poly, p, 128, 1, vreint_expected_q_u8_p128);
  TEST_VREINTERPRET_FROM_P128(q, uint, u, 16, 8, poly, p, 128, 1, vreint_expected_q_u16_p128);
  TEST_VREINTERPRET_FROM_P128(q, uint, u, 32, 4, poly, p, 128, 1, vreint_expected_q_u32_p128);
  TEST_VREINTERPRET_FROM_P128(q, uint, u, 64, 2, poly, p, 128, 1, vreint_expected_q_u64_p128);
  TEST_VREINTERPRET_FROM_P128(q, poly, p, 8, 16, poly, p, 128, 1, vreint_expected_q_p8_p128);
  TEST_VREINTERPRET_FROM_P128(q, poly, p, 16, 8, poly, p, 128, 1, vreint_expected_q_p16_p128);
  TEST_VREINTERPRET_FP_FROM_P128(q, float, f, 16, 8, poly, p, 128, 1, vreint_expected_q_f16_p128);
  TEST_VREINTERPRET_FP_FROM_P128(q, float, f, 32, 4, poly, p, 128, 1, vreint_expected_q_f32_p128);

  return 0;
}
Example #3
0
void exec_vrsqrte(void)
{
  int i;

  /* Basic test: y=vrsqrte(x), then store the result.  */
#define TEST_VRSQRTE(Q, T1, T2, W, N)			\
  VECT_VAR(vector_res, T1, W, N) =			\
    vrsqrte##Q##_##T2##W(VECT_VAR(vector, T1, W, N));	\
  vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N),		\
		    VECT_VAR(vector_res, T1, W, N))

  DECL_VARIABLE(vector, uint, 32, 2);
  DECL_VARIABLE(vector, float, 32, 2);
  DECL_VARIABLE(vector, uint, 32, 4);
  DECL_VARIABLE(vector, float, 32, 4);

  DECL_VARIABLE(vector_res, uint, 32, 2);
  DECL_VARIABLE(vector_res, float, 32, 2);
  DECL_VARIABLE(vector_res, uint, 32, 4);
  DECL_VARIABLE(vector_res, float, 32, 4);

  clean_results ();

  /* Choose init value arbitrarily.  */
  VDUP(vector, , uint, u, 32, 2, 0x12345678);
  VDUP(vector, , float, f, 32, 2, 25.799999f);
  VDUP(vector, q, uint, u, 32, 4, 0xABCDEF10);
  VDUP(vector, q, float, f, 32, 4, 18.2f);

  /* Apply the operator.  */
  TEST_VRSQRTE(, uint, u, 32, 2);
  TEST_VRSQRTE(, float, f, 32, 2);
  TEST_VRSQRTE(q, uint, u, 32, 4);
  TEST_VRSQRTE(q, float, f, 32, 4);

#define CMT ""
  CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, CMT);
  CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, CMT);
  CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected, CMT);
  CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected, CMT);


  /* Don't test FP variants with negative inputs.  */
  /* Use input with various values of bits 30 and 31.  */
  VDUP(vector, , uint, u, 32, 2, 0xFFFFFFFF);
  VDUP(vector, q, uint, u, 32, 4, 0x89081234);

  /* Apply the operator.  */
  TEST_VRSQRTE(, uint, u, 32, 2);
  TEST_VRSQRTE(q, uint, u, 32, 4);

#undef CMT
#define CMT " (large uint #1)"
  CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_1, CMT);
  CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_1, CMT);


  /* Choose init value arbitrarily.  */
  VDUP(vector, , uint, u, 32, 2, 0x80000000);
  VDUP(vector, q, uint, u, 32, 4, 0x4ABCDEF0);

  /* Apply the operator.  */
  TEST_VRSQRTE(, uint, u, 32, 2);
  TEST_VRSQRTE(q, uint, u, 32, 4);

#undef CMT
#define CMT " (large uint #2)"
  CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_2, CMT);
  CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_2, CMT);


  /* Test FP variants with special input values (NaNs, ...).  */
  VDUP(vector, , float, f, 32, 2, NAN);
  VDUP(vector, q, float, f, 32, 4, 0.0f);

  /* Apply the operator.  */
  TEST_VRSQRTE(, float, f, 32, 2);
  TEST_VRSQRTE(q, float, f, 32, 4);

#undef CMT
#define CMT " FP special (NaN, 0)"
  CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_fp1, CMT);
  CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_fp1, CMT);


  /* Test FP variants with special input values (negative, infinity).  */
  VDUP(vector, , float, f, 32, 2, -1.0f);
  VDUP(vector, q, float, f, 32, 4, HUGE_VALF);

  /* Apply the operator.  */
  TEST_VRSQRTE(, float, f, 32, 2);
  TEST_VRSQRTE(q, float, f, 32, 4);

#undef CMT
#define CMT " FP special (negative, infinity)"
  CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_fp2, CMT);
  CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_fp2, CMT);

  /* Test FP variants with special input values (-0, -infinity).  */
  VDUP(vector, , float, f, 32, 2, -0.0f);
  VDUP(vector, q, float, f, 32, 4, -HUGE_VALF);

  /* Apply the operator.  */
  TEST_VRSQRTE(, float, f, 32, 2);
  TEST_VRSQRTE(q, float, f, 32, 4);

#undef CMT
#define CMT " FP special (-0, -infinity)"
  CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_fp3, CMT);
  CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_fp3, CMT);
}
Example #4
0
File: vrecpe.c Project: 0day-ci/gcc
void exec_vrecpe(void)
{
  int i;

  /* Basic test: y=vrecpe(x), then store the result.  */
#define TEST_VRECPE(Q, T1, T2, W, N)			\
  VECT_VAR(vector_res, T1, W, N) =			\
    vrecpe##Q##_##T2##W(VECT_VAR(vector, T1, W, N));	\
  vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N),		\
		    VECT_VAR(vector_res, T1, W, N))

  /* No need for 64 bits variants.  */
  DECL_VARIABLE(vector, uint, 32, 2);
  DECL_VARIABLE(vector, uint, 32, 4);
  DECL_VARIABLE(vector, float, 32, 2);
  DECL_VARIABLE(vector, float, 32, 4);

  DECL_VARIABLE(vector_res, uint, 32, 2);
  DECL_VARIABLE(vector_res, uint, 32, 4);
  DECL_VARIABLE(vector_res, float, 32, 2);
  DECL_VARIABLE(vector_res, float, 32, 4);

  clean_results ();

  /* Choose init value arbitrarily, positive.  */
  VDUP(vector, , uint, u, 32, 2, 0x12345678);
  VDUP(vector, , float, f, 32, 2, 1.9f);
  VDUP(vector, q, uint, u, 32, 4, 0xABCDEF10);
  VDUP(vector, q, float, f, 32, 4, 125.0f);

  /* Apply the operator.  */
  TEST_VRECPE(, uint, u, 32, 2);
  TEST_VRECPE(, float, f, 32, 2);
  TEST_VRECPE(q, uint, u, 32, 4);
  TEST_VRECPE(q, float, f, 32, 4);

#define CMT " (positive input)"
  CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_positive, CMT);
  CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_positive, CMT);
  CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_positive, CMT);
  CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_positive, CMT);

  /* Choose init value arbitrarily,negative.  */
  VDUP(vector, , uint, u, 32, 2, 0xFFFFFFFF);
  VDUP(vector, , float, f, 32, 2, -10.0f);
  VDUP(vector, q, uint, u, 32, 4, 0x89081234);
  VDUP(vector, q, float, f, 32, 4, -125.0f);

  /* Apply the operator.  */
  TEST_VRECPE(, uint, u, 32, 2);
  TEST_VRECPE(, float, f, 32, 2);
  TEST_VRECPE(q, uint, u, 32, 4);
  TEST_VRECPE(q, float, f, 32, 4);

#undef CMT
#define CMT " (negative input)"
  CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_negative, CMT);
  CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_negative, CMT);
  CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_negative, CMT);
  CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_negative, CMT);

  /* Test FP variants with special input values (NaN, infinity).  */
  VDUP(vector, , float, f, 32, 2, NAN);
  VDUP(vector, q, float, f, 32, 4, HUGE_VALF);

  /* Apply the operator.  */
  TEST_VRECPE(, float, f, 32, 2);
  TEST_VRECPE(q, float, f, 32, 4);

#undef CMT
#define CMT " FP special (NaN, infinity)"
  CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_fp1, CMT);
  CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_fp1, CMT);

  /* Test FP variants with special input values (zero, large value).  */
  VDUP(vector, , float, f, 32, 2, 0.0f);
  VDUP(vector, q, float, f, 32, 4, 8.97229e37f /*9.0e37f*/);

  /* Apply the operator.  */
  TEST_VRECPE(, float, f, 32, 2);
  TEST_VRECPE(q, float, f, 32, 4);

#undef CMT
#define CMT " FP special (zero, large value)"
  CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_fp2, CMT);
  CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_fp2, CMT);

  /* Test FP variants with special input values (-0, -infinity).  */
  VDUP(vector, , float, f, 32, 2, -0.0f);
  VDUP(vector, q, float, f, 32, 4, -HUGE_VALF);

  /* Apply the operator.  */
  TEST_VRECPE(, float, f, 32, 2);
  TEST_VRECPE(q, float, f, 32, 4);

#undef CMT
#define CMT " FP special (-0, -infinity)"
  CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_fp3, CMT);
  CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_fp3, CMT);

  /* Test FP variants with special input values (large negative value).  */
  VDUP(vector, , float, f, 32, 2, -9.0e37f);

  /* Apply the operator.  */
  TEST_VRECPE(, float, f, 32, 2);

#undef CMT
#define CMT " FP special (large negative value)"
  CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_fp4, CMT);
}
void exec_vrecpe(void)
{
  int i;

  /* Basic test: y=vrecpe(x), then store the result.  */
#define TEST_VRECPE(Q, T1, T2, W, N)					\
  VECT_VAR(vector_res, T1, W, N) =					\
    vrecpe##Q##_##T2##W(VECT_VAR(vector, T1, W, N));			\
  vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N),				\
		    VECT_VAR(vector_res, T1, W, N))

    /* With ARM RVCT, we need to declare variables before any executable
       statement  */

  /* No need for 64 bits variants */
  DECL_VARIABLE(vector, uint, 32, 2);
  DECL_VARIABLE(vector, uint, 32, 4);
  DECL_VARIABLE(vector, float, 32, 2);
  DECL_VARIABLE(vector, float, 32, 4);

  DECL_VARIABLE(vector_res, uint, 32, 2);
  DECL_VARIABLE(vector_res, uint, 32, 4);
  DECL_VARIABLE(vector_res, float, 32, 2);
  DECL_VARIABLE(vector_res, float, 32, 4);

  clean_results ();

  /* Choose init value arbitrarily */
  VDUP(vector, , uint, u, 32, 2, 0x12345678);
  VDUP(vector, , float, f, 32, 2, 1.9f);
  VDUP(vector, q, uint, u, 32, 4, 0xABCDEF10);
  VDUP(vector, q, float, f, 32, 4, 125.0f);

  /* Apply the operator */
  TEST_VRECPE(, uint, u, 32, 2);
  TEST_VRECPE(, float, f, 32, 2);
  TEST_VRECPE(q, uint, u, 32, 4);
  TEST_VRECPE(q, float, f, 32, 4);

  fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " (positive input)");
  DUMP(TEST_MSG, uint, 32, 2, PRIx32);
  DUMP(TEST_MSG, uint, 32, 4, PRIx32);
  DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
  DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);

  /* Choose init value arbitrarily */
  VDUP(vector, , uint, u, 32, 2, 0xFFFFFFFF);
  VDUP(vector, , float, f, 32, 2, -10.0f);
  VDUP(vector, q, uint, u, 32, 4, 0x89081234);
  VDUP(vector, q, float, f, 32, 4, -125.0f);

  /* Apply the operator */
  TEST_VRECPE(, uint, u, 32, 2);
  TEST_VRECPE(, float, f, 32, 2);
  TEST_VRECPE(q, uint, u, 32, 4);
  TEST_VRECPE(q, float, f, 32, 4);

  fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " (negative input)");
  DUMP(TEST_MSG, uint, 32, 2, PRIx32);
  DUMP(TEST_MSG, uint, 32, 4, PRIx32);
  DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
  DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);

  /* Test FP variants with special input values (NaN, infinity) */
  VDUP(vector, , float, f, 32, 2, NAN);
  VDUP(vector, q, float, f, 32, 4, HUGE_VALF);

  /* Apply the operator */
  TEST_VRECPE(, float, f, 32, 2);
  TEST_VRECPE(q, float, f, 32, 4);

  fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " FP special (NaN, infinity)");
  DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
  DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);

  /* Test FP variants with special input values (zero, large value) */
  VDUP(vector, , float, f, 32, 2, 0.0f);
  VDUP(vector, q, float, f, 32, 4, 9.0e37f);

  /* Apply the operator */
  TEST_VRECPE(, float, f, 32, 2);
  TEST_VRECPE(q, float, f, 32, 4);

  fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " FP special (zero, large value)");
  DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
  DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);

  /* Test FP variants with special input values (-0, -infinity) */
  VDUP(vector, , float, f, 32, 2, -0.0f);
  VDUP(vector, q, float, f, 32, 4, -HUGE_VALF);

  /* Apply the operator */
  TEST_VRECPE(, float, f, 32, 2);
  TEST_VRECPE(q, float, f, 32, 4);

  fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " FP special (-0, -infinity)");
  DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
  DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);

  /* Test FP variants with special input values (large negative value) */
  VDUP(vector, , float, f, 32, 2, -9.0e37f);

  /* Apply the operator */
  TEST_VRECPE(, float, f, 32, 2);

  fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " FP special (large negative value)");
  DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
}