Exemple #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");
}
Exemple #2
0
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);
}
Exemple #4
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);
}
Exemple #5
0
void exec_vqtbX (void)
{
    int i;

    /* In this case, input variables are arrays of vectors.  */
#define DECL_VQTBX(T1, W, N, X)						\
  VECT_ARRAY_TYPE(T1, W, N, X) VECT_ARRAY_VAR(table_vector, T1, W, N, X)

    /* The vqtbl1 variant is different from vqtbl{2,3,4} because it takes a
       vector as 1st param, instead of an array of vectors.  */
#define TEST_VQTBL1(T1, T2, T3, W, N1, N2)		\
  VECT_VAR(table_vector, T1, W, N2) =			\
    vld1##q_##T2##W((T1##W##_t *)lookup_table);		\
							\
  VECT_VAR(vector_res, T1, W, N1) =			\
    vqtbl1_##T2##W(VECT_VAR(table_vector, T1, W, N2),	\
		   VECT_VAR(vector, T3, W, N1));	\
  vst1_##T2##W(VECT_VAR(result, T1, W, N1),		\
	       VECT_VAR(vector_res, T1, W, N1));

#define TEST_VQTBL1Q(T1, T2, T3, W, N1, N2)		\
  VECT_VAR(table_vector, T1, W, N2) =			\
    vld1##q_##T2##W((T1##W##_t *)lookup_table);		\
							\
  VECT_VAR(vector_res, T1, W, N1) =			\
    vqtbl1q_##T2##W(VECT_VAR(table_vector, T1, W, N2),	\
		    VECT_VAR(vector, T3, W, N1));	\
  vst1q_##T2##W(VECT_VAR(result, T1, W, N1),		\
	       VECT_VAR(vector_res, T1, W, N1));

#define TEST_VQTBLX(T1, T2, T3, W, N1, N2, X)				\
  VECT_ARRAY_VAR(table_vector, T1, W, N2, X) =				\
    vld##X##q_##T2##W((T1##W##_t *)lookup_table);			\
									\
  VECT_VAR(vector_res, T1, W, N1) =					\
    vqtbl##X##_##T2##W(VECT_ARRAY_VAR(table_vector, T1, W, N2, X),	\
		       VECT_VAR(vector, T3, W, N1));			\
  vst1_##T2##W(VECT_VAR(result, T1, W, N1),				\
		VECT_VAR(vector_res, T1, W, N1));

#define TEST_VQTBLXQ(T1, T2, T3, W, N1, N2, X)				\
  VECT_ARRAY_VAR(table_vector, T1, W, N2, X) =				\
    vld##X##q_##T2##W((T1##W##_t *)lookup_table);			\
									\
  VECT_VAR(vector_res, T1, W, N1) =					\
    vqtbl##X##q_##T2##W(VECT_ARRAY_VAR(table_vector, T1, W, N2, X),	\
			VECT_VAR(vector, T3, W, N1));			\
  vst1q_##T2##W(VECT_VAR(result, T1, W, N1),				\
		VECT_VAR(vector_res, T1, W, N1));

    /* We need to define a lookup table large enough.  */
    int8_t lookup_table[4*16];

    /* For vqtblX.  */
    DECL_VARIABLE(vector, int, 8, 8);
    DECL_VARIABLE(vector, uint, 8, 8);
    DECL_VARIABLE(vector, poly, 8, 8);
    DECL_VARIABLE(vector_res, int, 8, 8);
    DECL_VARIABLE(vector_res, uint, 8, 8);
    DECL_VARIABLE(vector_res, poly, 8, 8);

    /* For vqtblXq.  */
    DECL_VARIABLE(vector, int, 8, 16);
    DECL_VARIABLE(vector, uint, 8, 16);
    DECL_VARIABLE(vector, poly, 8, 16);
    DECL_VARIABLE(vector_res, int, 8, 16);
    DECL_VARIABLE(vector_res, uint, 8, 16);
    DECL_VARIABLE(vector_res, poly, 8, 16);

    /* For vqtbl1.  */
    DECL_VARIABLE(table_vector, int, 8, 16);
    DECL_VARIABLE(table_vector, uint, 8, 16);
    DECL_VARIABLE(table_vector, poly, 8, 16);

    /* For vqtbx*.  */
    DECL_VARIABLE(default_vector, int, 8, 8);
    DECL_VARIABLE(default_vector, uint, 8, 8);
    DECL_VARIABLE(default_vector, poly, 8, 8);

    /* For vqtbx*q.  */
    DECL_VARIABLE(default_vector, int, 8, 16);
    DECL_VARIABLE(default_vector, uint, 8, 16);
    DECL_VARIABLE(default_vector, poly, 8, 16);

    /* We need only 8 bits variants.  */
#define DECL_ALL_VQTBLX(X)			\
  DECL_VQTBX(int, 8, 16, X);			\
  DECL_VQTBX(uint, 8, 16, X);			\
  DECL_VQTBX(poly, 8, 16, X)

#define TEST_ALL_VQTBL1()			\
  TEST_VQTBL1(int, s, uint, 8, 8, 16);		\
  TEST_VQTBL1(uint, u, uint, 8, 8, 16);		\
  TEST_VQTBL1(poly, p, uint, 8, 8, 16);		\
  TEST_VQTBL1Q(int, s, uint, 8, 16, 16);	\
  TEST_VQTBL1Q(uint, u, uint, 8, 16, 16);	\
  TEST_VQTBL1Q(poly, p, uint, 8, 16, 16)

#define TEST_ALL_VQTBLX(X)			\
  TEST_VQTBLX(int, s, uint, 8, 8, 16, X);	\
  TEST_VQTBLX(uint, u, uint, 8, 8, 16, X);	\
  TEST_VQTBLX(poly, p, uint, 8, 8, 16, X);	\
  TEST_VQTBLXQ(int, s, uint, 8, 16, 16, X);	\
  TEST_VQTBLXQ(uint, u, uint, 8, 16, 16, X);	\
  TEST_VQTBLXQ(poly, p, uint, 8, 16, 16, X)

    /* Declare the temporary buffers / variables.  */
    DECL_ALL_VQTBLX(2);
    DECL_ALL_VQTBLX(3);
    DECL_ALL_VQTBLX(4);

    /* Fill the lookup table.  */
    for (i=0; i<4*16; i++) {
        lookup_table[i] = i-15;
    }

    /* Choose init value arbitrarily, will be used as table index.  */
    VDUP(vector, , uint, u, 8, 8, 2);
    VDUP(vector, q, uint, u, 8, 16, 2);

    /* To ensure coverage, add some indexes larger than 8, 16 and 32
       except: lane 0 (index 10), lane 4 (index 20) and lane 5 (index
       40).  */
    VSET_LANE(vector, , uint, u, 8, 8, 0, 10);
    VSET_LANE(vector, , uint, u, 8, 8, 4, 20);
    VSET_LANE(vector, , uint, u, 8, 8, 5, 40);

    VSET_LANE(vector, q, uint, u, 8, 16, 0, 10);
    VSET_LANE(vector, q, uint, u, 8, 16, 4, 20);
    VSET_LANE(vector, q, uint, u, 8, 16, 5, 40);

    /* Check vqtbl1.  */
    clean_results ();
#define TEST_MSG "VQTBL1"
    TEST_ALL_VQTBL1();

    CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbl1, "");
    CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbl1, "");
    CHECK(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbl1, "");

#undef TEST_MSG
#define TEST_MSG "VQTBL1Q"
    CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbl1q, "");
    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbl1q, "");
    CHECK(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbl1q, "");

    /* Check vqtbl2.  */
    clean_results ();
#undef TEST_MSG
#define TEST_MSG "VQTBL2"
    TEST_ALL_VQTBLX(2);

    CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbl2, "");
    CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbl2, "");
    CHECK(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbl2, "");

#undef TEST_MSG
#define TEST_MSG "VQTBL2Q"
    CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbl2q, "");
    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbl2q, "");
    CHECK(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbl2q, "");

    /* Check vqtbl3.  */
    clean_results ();
#undef TEST_MSG
#define TEST_MSG "VQTBL3"
    TEST_ALL_VQTBLX(3);

    CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbl3, "");
    CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbl3, "");
    CHECK(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbl3, "");

#undef TEST_MSG
#define TEST_MSG "VQTBL3Q"
    CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbl3q, "");
    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbl3q, "");
    CHECK(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbl3q, "");

    /* Check vqtbl4.  */
    clean_results ();
#undef TEST_MSG
#define TEST_MSG "VQTBL4"
    TEST_ALL_VQTBLX(4);

    CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbl4, "");
    CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbl4, "");
    CHECK(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbl4, "");

#undef TEST_MSG
#define TEST_MSG "VQTBL4Q"
    CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbl4q, "");
    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbl4q, "");
    CHECK(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbl4q, "");


    /* Now test VQTBX.  */

    /* The vqtbx1 variant is different from vqtbx{2,3,4} because it takes a
       vector as 1st param, instead of an array of vectors.  */
#define TEST_VQTBX1(T1, T2, T3, W, N1, N2)		\
  VECT_VAR(table_vector, T1, W, N2) =			\
    vld1##q_##T2##W((T1##W##_t *)lookup_table);		\
    							\
  VECT_VAR(vector_res, T1, W, N1) =		       	\
    vqtbx1_##T2##W(VECT_VAR(default_vector, T1, W, N1),	\
		   VECT_VAR(table_vector, T1, W, N2),	\
		   VECT_VAR(vector, T3, W, N1));	\
  vst1_##T2##W(VECT_VAR(result, T1, W, N1),		\
	       VECT_VAR(vector_res, T1, W, N1));

#define TEST_VQTBX1Q(T1, T2, T3, W, N1, N2)		\
  VECT_VAR(table_vector, T1, W, N2) =			\
    vld1##q_##T2##W((T1##W##_t *)lookup_table);		\
    							\
  VECT_VAR(vector_res, T1, W, N1) =			\
    vqtbx1q_##T2##W(VECT_VAR(default_vector, T1, W, N1),\
		    VECT_VAR(table_vector, T1, W, N2),	\
		    VECT_VAR(vector, T3, W, N1));	\
    vst1q_##T2##W(VECT_VAR(result, T1, W, N1),		\
		  VECT_VAR(vector_res, T1, W, N1));

#define TEST_VQTBXX(T1, T2, T3, W, N1, N2, X)				\
  VECT_ARRAY_VAR(table_vector, T1, W, N2, X) =				\
    vld##X##q_##T2##W((T1##W##_t *)lookup_table);			\
									\
  VECT_VAR(vector_res, T1, W, N1) =					\
    vqtbx##X##_##T2##W(VECT_VAR(default_vector, T1, W, N1),		\
			VECT_ARRAY_VAR(table_vector, T1, W, N2, X),	\
			VECT_VAR(vector, T3, W, N1));			\
  vst1_##T2##W(VECT_VAR(result, T1, W, N1),				\
		VECT_VAR(vector_res, T1, W, N1));

#define TEST_VQTBXXQ(T1, T2, T3, W, N1, N2, X)				\
  VECT_ARRAY_VAR(table_vector, T1, W, N2, X) =				\
    vld##X##q_##T2##W((T1##W##_t *)lookup_table);			\
									\
  VECT_VAR(vector_res, T1, W, N1) =					\
    vqtbx##X##q_##T2##W(VECT_VAR(default_vector, T1, W, N1),		\
			VECT_ARRAY_VAR(table_vector, T1, W, N2, X),	\
			VECT_VAR(vector, T3, W, N1));			\
  vst1q_##T2##W(VECT_VAR(result, T1, W, N1),				\
		VECT_VAR(vector_res, T1, W, N1));

#define TEST_ALL_VQTBX1()			\
  TEST_VQTBX1(int, s, uint, 8, 8, 16);		\
  TEST_VQTBX1(uint, u, uint, 8, 8, 16);		\
  TEST_VQTBX1(poly, p, uint, 8, 8, 16);		\
  TEST_VQTBX1Q(int, s, uint, 8, 16, 16);	\
  TEST_VQTBX1Q(uint, u, uint, 8, 16, 16);	\
  TEST_VQTBX1Q(poly, p, uint, 8, 16, 16)

#define TEST_ALL_VQTBXX(X)			\
  TEST_VQTBXX(int, s, uint, 8, 8, 16, X);	\
  TEST_VQTBXX(uint, u, uint, 8, 8, 16, X);	\
  TEST_VQTBXX(poly, p, uint, 8, 8, 16, X);	\
  TEST_VQTBXXQ(int, s, uint, 8, 16, 16, X);	\
  TEST_VQTBXXQ(uint, u, uint, 8, 16, 16, X);	\
  TEST_VQTBXXQ(poly, p, uint, 8, 16, 16, X)

    /* Choose init value arbitrarily, will be used as default value.  */
    VDUP(default_vector, , int, s, 8, 8, 0x33);
    VDUP(default_vector, , uint, u, 8, 8, 0xCC);
    VDUP(default_vector, , poly, p, 8, 8, 0xCC);
    VDUP(default_vector, q, int, s, 8, 16, 0x33);
    VDUP(default_vector, q, uint, u, 8, 16, 0xCC);
    VDUP(default_vector, q, poly, p, 8, 16, 0xCC);

    /* Check vqtbx1.  */
    clean_results ();
#undef TEST_MSG
#define TEST_MSG "VQTBX1"
    TEST_ALL_VQTBX1();

    CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbx1, "");
    CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbx1, "");
    CHECK(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbx1, "");

#undef TEST_MSG
#define TEST_MSG "VQTBX1Q"
    CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbx1q, "");
    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbx1q, "");
    CHECK(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbx1q, "");

    /* Check vqtbx2.  */
    clean_results ();
#undef TEST_MSG
#define TEST_MSG "VQTBX2"
    TEST_ALL_VQTBXX(2);

    CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbx2, "");
    CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbx2, "");
    CHECK(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbx2, "");

#undef TEST_MSG
#define TEST_MSG "VQTBX2Q"
    CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbx2q, "");
    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbx2q, "");
    CHECK(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbx2q, "");

    /* Check vqtbx3.  */
    clean_results ();
#undef TEST_MSG
#define TEST_MSG "VQTBX3"
    TEST_ALL_VQTBXX(3);

    CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbx3, "");
    CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbx3, "");
    CHECK(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbx3, "");

#undef TEST_MSG
#define TEST_MSG "VQTBX3Q"
    CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbx3q, "");
    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbx3q, "");
    CHECK(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbx3q, "");

    /* Check vqtbx4.  */
    clean_results ();
#undef TEST_MSG
#define TEST_MSG "VQTBX4"
    TEST_ALL_VQTBXX(4);

    CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbx4, "");
    CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbx4, "");
    CHECK(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbx4, "");

#undef TEST_MSG
#define TEST_MSG "VQTBX4Q"
    CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbx4q, "");
    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbx4q, "");
    CHECK(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbx4q, "");
}