Commit bf9a1a07 by Ilya Verbin Committed by Ilya Verbin

AVX-512F: Add vectorizer support builtins

gcc/
	* config/i386/i386-builtin-types.def: Add V16SI_FTYPE_V16SF,
	V8DF_FTYPE_V8DF_ROUND, V16SF_FTYPE_V16SF_ROUND, V16SI_FTYPE_V16SF_ROUND.
	* config/i386/i386.c (enum ix86_builtins): Add
	IX86_BUILTIN_CVTPS2DQ512_MASK, IX86_BUILTIN_FLOORPS512,
	IX86_BUILTIN_FLOORPD512, IX86_BUILTIN_CEILPS512, IX86_BUILTIN_CEILPD512,
	IX86_BUILTIN_TRUNCPS512, IX86_BUILTIN_TRUNCPD512,
	IX86_BUILTIN_CVTPS2DQ512, IX86_BUILTIN_VEC_PACK_SFIX512,
	IX86_BUILTIN_FLOORPS_SFIX512, IX86_BUILTIN_CEILPS_SFIX512,
	IX86_BUILTIN_ROUNDPS_AZ_SFIX512.
	(builtin_description bdesc_args): Add __builtin_ia32_floorps512,
	__builtin_ia32_ceilps512, __builtin_ia32_truncps512,
	__builtin_ia32_floorpd512, __builtin_ia32_ceilpd512,
	__builtin_ia32_truncpd512, __builtin_ia32_cvtps2dq512,
	__builtin_ia32_vec_pack_sfix512, __builtin_ia32_roundps_az_sfix512,
	__builtin_ia32_floorps_sfix512, __builtin_ia32_ceilps_sfix512.
	Change IX86_BUILTIN_CVTPS2DQ512 to IX86_BUILTIN_CVTPS2DQ512_MASK for
	__builtin_ia32_cvtps2dq512_mask.
	(ix86_expand_args_builtin): Handle V8DF_FTYPE_V8DF_ROUND,
	V16SF_FTYPE_V16SF_ROUND, V16SI_FTYPE_V16SF_ROUND, V16SI_FTYPE_V16SF.
	(ix86_builtin_vectorized_function): Handle builtins mentioned above.
	* config/i386/sse.md
	(<mask_codefor>avx512f_fix_notruncv16sfv16si<mask_name><round_name>):
	Rename to ...
	(avx512f_fix_notruncv16sfv16si<mask_name><round_name>): ... this.
	(<mask_codefor>avx512f_cvtpd2dq512<mask_name><round_name>): Rename
	to ...
	(avx512f_cvtpd2dq512<mask_name><round_name>): ... this.
	(avx512f_vec_pack_sfix_v8df): New define_expand.
	(avx512f_roundpd512): Rename to ...
	(avx512f_round<castmode>512): ... this.  Change iterator.
	(avx512f_roundps512_sfix): New define_expand.
	(round<mode>2_sfix): Change iterator.
gcc/testsuite/
	* gcc.target/i386/avx512f-ceil-vec-1.c: New test.
	* gcc.target/i386/avx512f-ceil-vec-2.c: New test.
	* gcc.target/i386/avx512f-ceilf-sfix-vec-1.c: New test.
	* gcc.target/i386/avx512f-ceilf-sfix-vec-2.c: New test.
	* gcc.target/i386/avx512f-ceilf-vec-1.c: New test.
	* gcc.target/i386/avx512f-ceilf-vec-2.c: New test.
	* gcc.target/i386/avx512f-floor-vec-1.c: New test.
	* gcc.target/i386/avx512f-floor-vec-2.c: New test.
	* gcc.target/i386/avx512f-floorf-sfix-vec-1.c: New test.
	* gcc.target/i386/avx512f-floorf-sfix-vec-2.c: New test.
	* gcc.target/i386/avx512f-floorf-vec-1.c: New test.
	* gcc.target/i386/avx512f-floorf-vec-2.c: New test.
	* gcc.target/i386/avx512f-rint-sfix-vec-1.c: New test.
	* gcc.target/i386/avx512f-rint-sfix-vec-2.c: New test.
	* gcc.target/i386/avx512f-rintf-sfix-vec-1.c: New test.
	* gcc.target/i386/avx512f-rintf-sfix-vec-2.c: New test.
	* gcc.target/i386/avx512f-round-sfix-vec-1.c: New test.
	* gcc.target/i386/avx512f-round-sfix-vec-2.c: New test.
	* gcc.target/i386/avx512f-roundf-sfix-vec-1.c: New test.
	* gcc.target/i386/avx512f-roundf-sfix-vec-2.c: New test.
	* gcc.target/i386/avx512f-trunc-vec-1.c: New test.
	* gcc.target/i386/avx512f-trunc-vec-2.c: New test.
	* gcc.target/i386/avx512f-truncf-vec-1.c: New test.
	* gcc.target/i386/avx512f-truncf-vec-2.c: New test.

From-SVN: r236709
parent a23faf7a
2016-05-25 Ilya Verbin <ilya.verbin@intel.com>
* config/i386/i386-builtin-types.def: Add V16SI_FTYPE_V16SF,
V8DF_FTYPE_V8DF_ROUND, V16SF_FTYPE_V16SF_ROUND, V16SI_FTYPE_V16SF_ROUND.
* config/i386/i386.c (enum ix86_builtins): Add
IX86_BUILTIN_CVTPS2DQ512_MASK, IX86_BUILTIN_FLOORPS512,
IX86_BUILTIN_FLOORPD512, IX86_BUILTIN_CEILPS512, IX86_BUILTIN_CEILPD512,
IX86_BUILTIN_TRUNCPS512, IX86_BUILTIN_TRUNCPD512,
IX86_BUILTIN_CVTPS2DQ512, IX86_BUILTIN_VEC_PACK_SFIX512,
IX86_BUILTIN_FLOORPS_SFIX512, IX86_BUILTIN_CEILPS_SFIX512,
IX86_BUILTIN_ROUNDPS_AZ_SFIX512.
(builtin_description bdesc_args): Add __builtin_ia32_floorps512,
__builtin_ia32_ceilps512, __builtin_ia32_truncps512,
__builtin_ia32_floorpd512, __builtin_ia32_ceilpd512,
__builtin_ia32_truncpd512, __builtin_ia32_cvtps2dq512,
__builtin_ia32_vec_pack_sfix512, __builtin_ia32_roundps_az_sfix512,
__builtin_ia32_floorps_sfix512, __builtin_ia32_ceilps_sfix512.
Change IX86_BUILTIN_CVTPS2DQ512 to IX86_BUILTIN_CVTPS2DQ512_MASK for
__builtin_ia32_cvtps2dq512_mask.
(ix86_expand_args_builtin): Handle V8DF_FTYPE_V8DF_ROUND,
V16SF_FTYPE_V16SF_ROUND, V16SI_FTYPE_V16SF_ROUND, V16SI_FTYPE_V16SF.
(ix86_builtin_vectorized_function): Handle builtins mentioned above.
* config/i386/sse.md
(<mask_codefor>avx512f_fix_notruncv16sfv16si<mask_name><round_name>):
Rename to ...
(avx512f_fix_notruncv16sfv16si<mask_name><round_name>): ... this.
(<mask_codefor>avx512f_cvtpd2dq512<mask_name><round_name>): Rename
to ...
(avx512f_cvtpd2dq512<mask_name><round_name>): ... this.
(avx512f_vec_pack_sfix_v8df): New define_expand.
(avx512f_roundpd512): Rename to ...
(avx512f_round<castmode>512): ... this. Change iterator.
(avx512f_roundps512_sfix): New define_expand.
(round<mode>2_sfix): Change iterator.
2016-05-25 Nick Clifton <nickc@redhat.com> 2016-05-25 Nick Clifton <nickc@redhat.com>
* config/msp430/msp430.c (msp430_attr): Produce an error if a * config/msp430/msp430.c (msp430_attr): Produce an error if a
......
...@@ -294,6 +294,7 @@ DEF_FUNCTION_TYPE (V8DF, V4DF) ...@@ -294,6 +294,7 @@ DEF_FUNCTION_TYPE (V8DF, V4DF)
DEF_FUNCTION_TYPE (V8DF, V2DF) DEF_FUNCTION_TYPE (V8DF, V2DF)
DEF_FUNCTION_TYPE (V16SI, V4SI) DEF_FUNCTION_TYPE (V16SI, V4SI)
DEF_FUNCTION_TYPE (V16SI, V8SI) DEF_FUNCTION_TYPE (V16SI, V8SI)
DEF_FUNCTION_TYPE (V16SI, V16SF)
DEF_FUNCTION_TYPE (V16SI, V16SI, V16SI, UHI) DEF_FUNCTION_TYPE (V16SI, V16SI, V16SI, UHI)
DEF_FUNCTION_TYPE (V8DI, V8DI, V8DI, UQI) DEF_FUNCTION_TYPE (V8DI, V8DI, V8DI, UQI)
DEF_FUNCTION_TYPE (V8DI, PV8DI) DEF_FUNCTION_TYPE (V8DI, PV8DI)
...@@ -1061,14 +1062,17 @@ DEF_FUNCTION_TYPE (VOID, QI, V8DI, PCINT, INT, INT) ...@@ -1061,14 +1062,17 @@ DEF_FUNCTION_TYPE (VOID, QI, V8DI, PCINT, INT, INT)
DEF_FUNCTION_TYPE_ALIAS (V2DF_FTYPE_V2DF, ROUND) DEF_FUNCTION_TYPE_ALIAS (V2DF_FTYPE_V2DF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (V4DF_FTYPE_V4DF, ROUND) DEF_FUNCTION_TYPE_ALIAS (V4DF_FTYPE_V4DF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (V8DF_FTYPE_V8DF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (V4SF_FTYPE_V4SF, ROUND) DEF_FUNCTION_TYPE_ALIAS (V4SF_FTYPE_V4SF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (V8SF_FTYPE_V8SF, ROUND) DEF_FUNCTION_TYPE_ALIAS (V8SF_FTYPE_V8SF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (V16SF_FTYPE_V16SF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (V4SI_FTYPE_V2DF_V2DF, ROUND) DEF_FUNCTION_TYPE_ALIAS (V4SI_FTYPE_V2DF_V2DF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (V8SI_FTYPE_V4DF_V4DF, ROUND) DEF_FUNCTION_TYPE_ALIAS (V8SI_FTYPE_V4DF_V4DF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (V16SI_FTYPE_V8DF_V8DF, ROUND) DEF_FUNCTION_TYPE_ALIAS (V16SI_FTYPE_V8DF_V8DF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (V4SI_FTYPE_V4SF, ROUND) DEF_FUNCTION_TYPE_ALIAS (V4SI_FTYPE_V4SF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (V8SI_FTYPE_V8SF, ROUND) DEF_FUNCTION_TYPE_ALIAS (V8SI_FTYPE_V8SF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (V16SI_FTYPE_V16SF, ROUND)
DEF_FUNCTION_TYPE_ALIAS (INT_FTYPE_V2DF_V2DF, PTEST) DEF_FUNCTION_TYPE_ALIAS (INT_FTYPE_V2DF_V2DF, PTEST)
DEF_FUNCTION_TYPE_ALIAS (INT_FTYPE_V2DI_V2DI, PTEST) DEF_FUNCTION_TYPE_ALIAS (INT_FTYPE_V2DI_V2DI, PTEST)
......
...@@ -4242,7 +4242,7 @@ ...@@ -4242,7 +4242,7 @@
(set_attr "prefix" "maybe_vex") (set_attr "prefix" "maybe_vex")
(set_attr "mode" "<sseinsnmode>")]) (set_attr "mode" "<sseinsnmode>")])
(define_insn "<mask_codefor>avx512f_fix_notruncv16sfv16si<mask_name><round_name>" (define_insn "avx512f_fix_notruncv16sfv16si<mask_name><round_name>"
[(set (match_operand:V16SI 0 "register_operand" "=v") [(set (match_operand:V16SI 0 "register_operand" "=v")
(unspec:V16SI (unspec:V16SI
[(match_operand:V16SF 1 "<round_nimm_predicate>" "<round_constraint>")] [(match_operand:V16SF 1 "<round_nimm_predicate>" "<round_constraint>")]
...@@ -4799,7 +4799,7 @@ ...@@ -4799,7 +4799,7 @@
(set_attr "prefix" "maybe_vex") (set_attr "prefix" "maybe_vex")
(set_attr "mode" "V2DF")]) (set_attr "mode" "V2DF")])
(define_insn "<mask_codefor>avx512f_cvtpd2dq512<mask_name><round_name>" (define_insn "avx512f_cvtpd2dq512<mask_name><round_name>"
[(set (match_operand:V8SI 0 "register_operand" "=v") [(set (match_operand:V8SI 0 "register_operand" "=v")
(unspec:V8SI (unspec:V8SI
[(match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")] [(match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")]
...@@ -5802,6 +5802,23 @@ ...@@ -5802,6 +5802,23 @@
DONE; DONE;
}) })
(define_expand "avx512f_vec_pack_sfix_v8df"
[(match_operand:V16SI 0 "register_operand")
(match_operand:V8DF 1 "nonimmediate_operand")
(match_operand:V8DF 2 "nonimmediate_operand")]
"TARGET_AVX512F"
{
rtx r1, r2;
r1 = gen_reg_rtx (V8SImode);
r2 = gen_reg_rtx (V8SImode);
emit_insn (gen_avx512f_cvtpd2dq512 (r1, operands[1]));
emit_insn (gen_avx512f_cvtpd2dq512 (r2, operands[2]));
emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
DONE;
})
(define_expand "vec_pack_sfix_v4df" (define_expand "vec_pack_sfix_v4df"
[(match_operand:V8SI 0 "register_operand") [(match_operand:V8SI 0 "register_operand")
(match_operand:V4DF 1 "nonimmediate_operand") (match_operand:V4DF 1 "nonimmediate_operand")
...@@ -15027,13 +15044,25 @@ ...@@ -15027,13 +15044,25 @@
DONE; DONE;
}) })
(define_expand "avx512f_roundpd512" (define_expand "avx512f_round<castmode>512"
[(match_operand:V8DF 0 "register_operand") [(match_operand:VF_512 0 "register_operand")
(match_operand:V8DF 1 "nonimmediate_operand") (match_operand:VF_512 1 "nonimmediate_operand")
(match_operand:SI 2 "const_0_to_15_operand")]
"TARGET_AVX512F"
{
emit_insn (gen_avx512f_rndscale<mode> (operands[0], operands[1], operands[2]));
DONE;
})
(define_expand "avx512f_roundps512_sfix"
[(match_operand:V16SI 0 "register_operand")
(match_operand:V16SF 1 "nonimmediate_operand")
(match_operand:SI 2 "const_0_to_15_operand")] (match_operand:SI 2 "const_0_to_15_operand")]
"TARGET_AVX512F" "TARGET_AVX512F"
{ {
emit_insn (gen_avx512f_rndscalev8df (operands[0], operands[1], operands[2])); rtx tmp = gen_reg_rtx (V16SFmode);
emit_insn (gen_avx512f_rndscalev16sf (tmp, operands[1], operands[2]));
emit_insn (gen_fix_truncv16sfv16si2 (operands[0], tmp));
DONE; DONE;
}) })
...@@ -15134,7 +15163,7 @@ ...@@ -15134,7 +15163,7 @@
(define_expand "round<mode>2_sfix" (define_expand "round<mode>2_sfix"
[(match_operand:<sseintvecmode> 0 "register_operand") [(match_operand:<sseintvecmode> 0 "register_operand")
(match_operand:VF1_128_256 1 "register_operand")] (match_operand:VF1 1 "register_operand")]
"TARGET_ROUND && !flag_trapping_math" "TARGET_ROUND && !flag_trapping_math"
{ {
rtx tmp = gen_reg_rtx (<MODE>mode); rtx tmp = gen_reg_rtx (<MODE>mode);
......
2016-05-25 Ilya Verbin <ilya.verbin@intel.com>
* gcc.target/i386/avx512f-ceil-vec-1.c: New test.
* gcc.target/i386/avx512f-ceil-vec-2.c: New test.
* gcc.target/i386/avx512f-ceilf-sfix-vec-1.c: New test.
* gcc.target/i386/avx512f-ceilf-sfix-vec-2.c: New test.
* gcc.target/i386/avx512f-ceilf-vec-1.c: New test.
* gcc.target/i386/avx512f-ceilf-vec-2.c: New test.
* gcc.target/i386/avx512f-floor-vec-1.c: New test.
* gcc.target/i386/avx512f-floor-vec-2.c: New test.
* gcc.target/i386/avx512f-floorf-sfix-vec-1.c: New test.
* gcc.target/i386/avx512f-floorf-sfix-vec-2.c: New test.
* gcc.target/i386/avx512f-floorf-vec-1.c: New test.
* gcc.target/i386/avx512f-floorf-vec-2.c: New test.
* gcc.target/i386/avx512f-rint-sfix-vec-1.c: New test.
* gcc.target/i386/avx512f-rint-sfix-vec-2.c: New test.
* gcc.target/i386/avx512f-rintf-sfix-vec-1.c: New test.
* gcc.target/i386/avx512f-rintf-sfix-vec-2.c: New test.
* gcc.target/i386/avx512f-round-sfix-vec-1.c: New test.
* gcc.target/i386/avx512f-round-sfix-vec-2.c: New test.
* gcc.target/i386/avx512f-roundf-sfix-vec-1.c: New test.
* gcc.target/i386/avx512f-roundf-sfix-vec-2.c: New test.
* gcc.target/i386/avx512f-trunc-vec-1.c: New test.
* gcc.target/i386/avx512f-trunc-vec-2.c: New test.
* gcc.target/i386/avx512f-truncf-vec-1.c: New test.
* gcc.target/i386/avx512f-truncf-vec-2.c: New test.
2016-05-25 Marek Polacek <polacek@redhat.com> 2016-05-25 Marek Polacek <polacek@redhat.com>
PR c/71265 PR c/71265
......
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (double *src)
{
int i, sign = 1;
double f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
double a[NUM];
double r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = ceil (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != ceil (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-ceil-vec-1.c"
/* { dg-final { scan-assembler-times "vrndscalepd\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (float *src)
{
int i, sign = 1;
float f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
float a[NUM];
int r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = (int) ceilf (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != (int) ceilf (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-ceilf-sfix-vec-1.c"
/* { dg-final { scan-assembler-times "vrndscaleps\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-final { scan-assembler-times "vcvttps2dq\[^\n\]+zmm\[0-9\].{7}(?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (float *src)
{
int i, sign = 1;
float f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
float a[NUM];
float r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = ceilf (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != ceilf (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-ceilf-vec-1.c"
/* { dg-final { scan-assembler-times "vrndscaleps\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (double *src)
{
int i, sign = 1;
double f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
double a[NUM];
double r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = floor (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != floor (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-floor-vec-1.c"
/* { dg-final { scan-assembler-times "vrndscalepd\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (float *src)
{
int i, sign = 1;
float f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
float a[NUM];
int r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = (int) floorf (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != (int) floorf (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-floorf-sfix-vec-1.c"
/* { dg-final { scan-assembler-times "vrndscaleps\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-final { scan-assembler-times "vcvttps2dq\[^\n\]+zmm\[0-9\].{7}(?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (float *src)
{
int i, sign = 1;
float f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
float a[NUM];
float r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = floorf (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != floorf (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-floorf-vec-1.c"
/* { dg-final { scan-assembler-times "vrndscaleps\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (double *src)
{
int i, sign = 1;
double f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
double a[NUM];
int r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = (int) rint (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != (int) rint (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-rint-sfix-vec-1.c"
/* { dg-final { scan-assembler-times "vcvtpd2dq\[^\n\]+ymm\[0-9\](?:\n|\[ \\t\]+#)" 2 } } */
/* { dg-final { scan-assembler-times "vinserti64x4\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (float *src)
{
int i, sign = 1;
float f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
float a[NUM];
int r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = (int) rintf (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != (int) rintf (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-rintf-sfix-vec-1.c"
/* { dg-final { scan-assembler-times "vcvtps2dq\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (double *src)
{
int i, sign = 1;
double f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
double a[NUM];
int r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = (int) round (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != (int) round (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-round-sfix-vec-1.c"
/* { dg-final { scan-assembler-times "vrndscalepd\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 2 } } */
/* { dg-final { scan-assembler-times "vcvttpd2dq\[^\n\]+zmm\[0-9\].{7}(?:\n|\[ \\t\]+#)" 2 } } */
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (float *src)
{
int i, sign = 1;
float f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
float a[NUM];
int r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = (int) roundf (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != (int) roundf (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-roundf-sfix-vec-1.c"
/* { dg-final { scan-assembler-times "vrndscaleps\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-final { scan-assembler-times "vcvttps2dq\[^\n\]+zmm\[0-9\].{7}(?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (double *src)
{
int i, sign = 1;
double f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
double a[NUM];
double r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = trunc (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != trunc (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-trunc-vec-1.c"
/* { dg-final { scan-assembler-times "vrndscalepd\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
/* { dg-require-effective-target avx512f } */
/* { dg-skip-if "no M_PI" { vxworks_kernel } } */
#define __NO_MATH_INLINES
#include <math.h>
#include "avx512f-check.h"
#define NUM 64
static void
__attribute__((__target__("fpmath=sse")))
init_src (float *src)
{
int i, sign = 1;
float f = rand ();
for (i = 0; i < NUM; i++)
{
src[i] = (i + 1) * f * M_PI * sign;
if (i < (NUM / 2))
{
if ((i % 6) == 0)
f = f * src[i];
}
else if (i == (NUM / 2))
f = rand ();
else if ((i % 6) == 0)
f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
sign = -sign;
}
}
static void
__attribute__((__target__("fpmath=387")))
avx512f_test (void)
{
float a[NUM];
float r[NUM];
int i;
init_src (a);
for (i = 0; i < NUM; i++)
r[i] = truncf (a[i]);
/* check results: */
for (i = 0; i < NUM; i++)
if (r[i] != truncf (a[i]))
abort();
}
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
#include "avx512f-truncf-vec-1.c"
/* { dg-final { scan-assembler-times "vrndscaleps\[^\n\]+zmm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment