aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/i386/avx512f-helper.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.target/i386/avx512f-helper.h')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/i386/avx512f-helper.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/i386/avx512f-helper.h b/gcc-4.9/gcc/testsuite/gcc.target/i386/avx512f-helper.h
new file mode 100644
index 000000000..61b2e90d1
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/i386/avx512f-helper.h
@@ -0,0 +1,96 @@
+/* This file is used to reduce a number of runtime tests for AVX512F
+ instructions. Idea is to create one file per instruction -
+ avx512f-insn-2.c - using defines from this file instead of intrinsic
+ name, vector length etc. Then dg-options are set with appropriate
+ -Dwhatever options in that .c file producing tests for specific
+ length. */
+
+#if defined (AVX512F)
+#include "avx512f-check.h"
+#elif defined (AVX512ER)
+#include "avx512er-check.h"
+#elif defined (AVX512CD)
+#include "avx512cd-check.h"
+#endif
+
+/* Macros expansion. */
+#define CONCAT(a,b,c) a ## b ## c
+#define EVAL(a,b,c) CONCAT(a,b,c)
+
+/* Value to be written into destination.
+ We have one value for all types so it must be small enough
+ to fit into signed char. */
+#define DEFAULT_VALUE 117
+
+#define MAKE_MASK_MERGE(NAME, TYPE) \
+static void \
+__attribute__((noinline, unused)) \
+merge_masking_##NAME (TYPE *arr, unsigned long long mask, int size) \
+{ \
+ int i; \
+ for (i = 0; i < size; i++) \
+ { \
+ arr[i] = (mask & (1LL << i)) ? arr[i] : DEFAULT_VALUE; \
+ } \
+}
+
+MAKE_MASK_MERGE(i_b, char)
+MAKE_MASK_MERGE(i_w, short)
+MAKE_MASK_MERGE(i_d, int)
+MAKE_MASK_MERGE(i_q, long long)
+MAKE_MASK_MERGE(, float)
+MAKE_MASK_MERGE(d, double)
+
+#define MASK_MERGE(TYPE) merge_masking_##TYPE
+
+#define MAKE_MASK_ZERO(NAME, TYPE) \
+static void \
+__attribute__((noinline, unused)) \
+zero_masking_##NAME (TYPE *arr, unsigned long long mask, int size) \
+{ \
+ int i; \
+ for (i = 0; i < size; i++) \
+ { \
+ arr[i] = (mask & (1LL << i)) ? arr[i] : 0; \
+ } \
+}
+
+MAKE_MASK_ZERO(i_b, char)
+MAKE_MASK_ZERO(i_w, short)
+MAKE_MASK_ZERO(i_d, int)
+MAKE_MASK_ZERO(i_q, long long)
+MAKE_MASK_ZERO(, float)
+MAKE_MASK_ZERO(d, double)
+
+#define MASK_ZERO(TYPE) zero_masking_##TYPE
+
+/* Intrinsic being tested. */
+#define INTRINSIC(NAME) EVAL(_mm, AVX512F_LEN, NAME)
+/* Unions used for testing (for example union512d, union256d etc.). */
+#define UNION_TYPE(SIZE, NAME) EVAL(union, SIZE, NAME)
+/* Corresponding union check. */
+#define UNION_CHECK(SIZE, NAME) EVAL(check_union, SIZE, NAME)
+/* Corresponding fp union check. */
+#define UNION_FP_CHECK(SIZE, NAME) EVAL(check_fp_union, SIZE, NAME)
+/* Corresponding rough union check. */
+#define UNION_ROUGH_CHECK(SIZE, NAME) \
+ EVAL(check_rough_union, SIZE, NAME)
+/* Function which tests intrinsic for given length. */
+#define TEST EVAL(test_, AVX512F_LEN,)
+/* Function which calculates result. */
+#define CALC EVAL(calc_, AVX512F_LEN,)
+
+#define AVX512F_LEN 512
+#define AVX512F_LEN_HALF 256
+static void test_512 ();
+
+#if defined (AVX512F)
+void
+avx512f_test (void) { test_512 (); }
+#elif defined (AVX512CD)
+void
+avx512cd_test (void) { test_512 (); }
+#elif defined (AVX512ER)
+void
+avx512er_test (void) { test_512 (); }
+#endif