Commit 785cf02f by Matthew Wahab Committed by Matthew Wahab

[PATCH 15/17][ARM] Add tests for ARMv8.2-A FP16 support.

testsuite/
2016-09-23  Matthew Wahab  <matthew.wahab@arm.com>

	* gcc.target/arm/armv8_2-fp16-neon-1.c: New.
	* gcc.target/arm/armv8_2-fp16-scalar-1.c: New.
	* gcc.target/arm/armv8_2-fp16-scalar-2.c: New.
	* gcc.target/arm/attr-fp16-arith-1.c: Add a test of intrinsics
	support.

From-SVN: r240425
parent de955a69
2016-09-23 Matthew Wahab <matthew.wahab@arm.com>
* gcc.target/arm/armv8_2-fp16-neon-1.c: New.
* gcc.target/arm/armv8_2-fp16-scalar-1.c: New.
* gcc.target/arm/armv8_2-fp16-scalar-2.c: New.
* gcc.target/arm/attr-fp16-arith-1.c: Add a test of intrinsics
support.
2016-09-23 Kugan Vivekanandarajah <kuganv@linaro.org>
PR ipa/77677
......
/* { dg-do compile } */
/* { dg-require-effective-target arm_v8_2a_fp16_scalar_ok } */
/* { dg-options "-O2" } */
/* { dg-add-options arm_v8_2a_fp16_scalar } */
/* Test instructions generated for the FP16 scalar intrinsics. */
#include <arm_fp16.h>
#define MSTRCAT(L, str) L##str
#define UNOP_TEST(insn) \
float16_t \
MSTRCAT (test_##insn, 16) (float16_t a) \
{ \
return MSTRCAT (insn, h_f16) (a); \
}
#define BINOP_TEST(insn) \
float16_t \
MSTRCAT (test_##insn, 16) (float16_t a, float16_t b) \
{ \
return MSTRCAT (insn, h_f16) (a, b); \
}
#define TERNOP_TEST(insn) \
float16_t \
MSTRCAT (test_##insn, 16) (float16_t a, float16_t b, float16_t c) \
{ \
return MSTRCAT (insn, h_f16) (a, b, c); \
}
float16_t
test_vcvth_f16_s32 (int32_t a)
{
return vcvth_f16_s32 (a);
}
float16_t
test_vcvth_n_f16_s32 (int32_t a)
{
return vcvth_n_f16_s32 (a, 1);
}
/* { dg-final { scan-assembler-times {vcvt\.f16\.s32\ts[0-9]+, s[0-9]+} 2 } } */
/* { dg-final { scan-assembler-times {vcvt\.f16\.s32\ts[0-9]+, s[0-9]+, #1} 1 } } */
float16_t
test_vcvth_f16_u32 (uint32_t a)
{
return vcvth_f16_u32 (a);
}
float16_t
test_vcvth_n_f16_u32 (uint32_t a)
{
return vcvth_n_f16_u32 (a, 1);
}
/* { dg-final { scan-assembler-times {vcvt\.f16\.u32\ts[0-9]+, s[0-9]+} 2 } } */
/* { dg-final { scan-assembler-times {vcvt\.f16\.u32\ts[0-9]+, s[0-9]+, #1} 1 } } */
uint32_t
test_vcvth_u32_f16 (float16_t a)
{
return vcvth_u32_f16 (a);
}
/* { dg-final { scan-assembler-times {vcvt\.u32\.f16\ts[0-9]+, s[0-9]+} 2 } } */
uint32_t
test_vcvth_n_u32_f16 (float16_t a)
{
return vcvth_n_u32_f16 (a, 1);
}
/* { dg-final { scan-assembler-times {vcvt\.u32\.f16\ts[0-9]+, s[0-9]+, #1} 1 } } */
int32_t
test_vcvth_s32_f16 (float16_t a)
{
return vcvth_s32_f16 (a);
}
int32_t
test_vcvth_n_s32_f16 (float16_t a)
{
return vcvth_n_s32_f16 (a, 1);
}
/* { dg-final { scan-assembler-times {vcvt\.s32\.f16\ts[0-9]+, s[0-9]+} 2 } } */
/* { dg-final { scan-assembler-times {vcvt\.s32\.f16\ts[0-9]+, s[0-9]+, #1} 1 } } */
int32_t
test_vcvtah_s32_f16 (float16_t a)
{
return vcvtah_s32_f16 (a);
}
/* { dg-final { scan-assembler-times {vcvta\.s32\.f16\ts[0-9]+, s[0-9]+} 1 } } */
uint32_t
test_vcvtah_u32_f16 (float16_t a)
{
return vcvtah_u32_f16 (a);
}
/* { dg-final { scan-assembler-times {vcvta\.u32\.f16\ts[0-9]+, s[0-9]+} 1 } } */
int32_t
test_vcvtmh_s32_f16 (float16_t a)
{
return vcvtmh_s32_f16 (a);
}
/* { dg-final { scan-assembler-times {vcvtm\.s32\.f16\ts[0-9]+, s[0-9]+} 1 } } */
uint32_t
test_vcvtmh_u32_f16 (float16_t a)
{
return vcvtmh_u32_f16 (a);
}
/* { dg-final { scan-assembler-times {vcvtm\.u32\.f16\ts[0-9]+, s[0-9]+} 1 } }
*/
int32_t
test_vcvtnh_s32_f16 (float16_t a)
{
return vcvtnh_s32_f16 (a);
}
/* { dg-final { scan-assembler-times {vcvtn\.s32\.f16\ts[0-9]+, s[0-9]+} 1 } }
*/
uint32_t
test_vcvtnh_u32_f16 (float16_t a)
{
return vcvtnh_u32_f16 (a);
}
/* { dg-final { scan-assembler-times {vcvtn\.u32\.f16\ts[0-9]+, s[0-9]+} 1 } }
*/
int32_t
test_vcvtph_s32_f16 (float16_t a)
{
return vcvtph_s32_f16 (a);
}
/* { dg-final { scan-assembler-times {vcvtp\.s32\.f16\ts[0-9]+, s[0-9]+} 1 } }
*/
uint32_t
test_vcvtph_u32_f16 (float16_t a)
{
return vcvtph_u32_f16 (a);
}
/* { dg-final { scan-assembler-times {vcvtp\.u32\.f16\ts[0-9]+, s[0-9]+} 1 } }
*/
UNOP_TEST (vabs)
/* { dg-final { scan-assembler-times {vabs\.f16\ts[0-9]+, s[0-9]+} 1 } } */
UNOP_TEST (vneg)
/* { dg-final { scan-assembler-times {vneg\.f16\ts[0-9]+, s[0-9]+} 1 } } */
UNOP_TEST (vrnd)
/* { dg-final { scan-assembler-times {vrintz\.f16\ts[0-9]+, s[0-9]+} 1 } } */
UNOP_TEST (vrndi)
/* { dg-final { scan-assembler-times {vrintr\.f16\ts[0-9]+, s[0-9]+} 1 } } */
UNOP_TEST (vrnda)
/* { dg-final { scan-assembler-times {vrinta\.f16\ts[0-9]+, s[0-9]+} 1 } } */
UNOP_TEST (vrndm)
/* { dg-final { scan-assembler-times {vrinta\.f16\ts[0-9]+, s[0-9]+} 1 } } */
UNOP_TEST (vrndn)
/* { dg-final { scan-assembler-times {vrinta\.f16\ts[0-9]+, s[0-9]+} 1 } } */
UNOP_TEST (vrndp)
/* { dg-final { scan-assembler-times {vrinta\.f16\ts[0-9]+, s[0-9]+} 1 } } */
UNOP_TEST (vrndx)
/* { dg-final { scan-assembler-times {vrinta\.f16\ts[0-9]+, s[0-9]+} 1 } } */
UNOP_TEST (vsqrt)
/* { dg-final { scan-assembler-times {vsqrt\.f16\ts[0-9]+, s[0-9]+} 1 } } */
BINOP_TEST (vadd)
/* { dg-final { scan-assembler-times {vadd\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
BINOP_TEST (vdiv)
/* { dg-final { scan-assembler-times {vdiv\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
BINOP_TEST (vmaxnm)
/* { dg-final { scan-assembler-times {vmaxnm\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
BINOP_TEST (vminnm)
/* { dg-final { scan-assembler-times {vminnm\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
BINOP_TEST (vmul)
/* { dg-final { scan-assembler-times {vmul\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
BINOP_TEST (vsub)
/* { dg-final { scan-assembler-times {vsub\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
TERNOP_TEST (vfma)
/* { dg-final { scan-assembler-times {vfma\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
TERNOP_TEST (vfms)
/* { dg-final { scan-assembler-times {vfms\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
/* { dg-do compile } */
/* { dg-require-effective-target arm_v8_2a_fp16_scalar_ok } */
/* { dg-options "-O2 -std=c11" } */
/* { dg-add-options arm_v8_2a_fp16_scalar } */
/* Test compiler use of FP16 instructions. */
#include <arm_fp16.h>
float16_t
test_mov_imm_1 (float16_t a)
{
return 1.0;
}
float16_t
test_mov_imm_2 (float16_t a)
{
float16_t b = 1.0;
return b;
}
float16_t
test_vmov_imm_3 (float16_t a)
{
float16_t b = 1.0;
return vaddh_f16 (a, b);
}
float16_t
test_vmov_imm_4 (float16_t a)
{
return vaddh_f16 (a, 1.0);
}
/* { dg-final { scan-assembler-times {vmov.f16\ts[0-9]+, #1\.0e\+0} 4 } }
{ dg-final { scan-assembler-times {vadd.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 2 } } */
float16_t
test_vmla_1 (float16_t a, float16_t b, float16_t c)
{
return vaddh_f16 (vmulh_f16 (a, b), c);
}
/* { dg-final { scan-assembler-times {vmla\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
float16_t
test_vmla_2 (float16_t a, float16_t b, float16_t c)
{
return vsubh_f16 (vmulh_f16 (vnegh_f16 (a), b), c);
}
/* { dg-final { scan-assembler-times {vnmla\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
float16_t
test_vmls_1 (float16_t a, float16_t b, float16_t c)
{
return vsubh_f16 (c, vmulh_f16 (a, b));
}
float16_t
test_vmls_2 (float16_t a, float16_t b, float16_t c)
{
return vsubh_f16 (a, vmulh_f16 (b, c));
}
/* { dg-final { scan-assembler-times {vmls\.f16} 2 } } */
float16_t
test_vnmls_1 (float16_t a, float16_t b, float16_t c)
{
return vsubh_f16 (vmulh_f16 (a, b), c);
}
/* { dg-final { scan-assembler-times {vnmls\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
......@@ -28,6 +28,19 @@
#error Invalid value for __ARM_FP
#endif
#include "arm_neon.h"
float16_t
foo (float16x4_t b)
{
float16x4_t a = {2.0, 3.0, 4.0, 5.0};
float16x4_t res = vadd_f16 (a, b);
return res[0];
}
/* { dg-final { scan-assembler "vadd\\.f16\td\[0-9\]+, d\[0-9\]+" } } */
#pragma GCC pop_options
/* Check that the FP version is correctly reset to mfpu=fp-armv8. */
......
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