aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2020-12-13 13:56:30 +0000
committerTamar Christina <tamar.christina@arm.com>2020-12-13 14:10:07 +0000
commit2f05dadaeda6068ad570117be21f2c16e2f4fa10 (patch)
treebac00efe447b3c60468c2c693ebd9c0a6b6e5cfe /gcc
parent3ed472af6bc9f83b7a8ac553b282f659a0bf53f7 (diff)
downloadgcc-2f05dadaeda6068ad570117be21f2c16e2f4fa10.zip
gcc-2f05dadaeda6068ad570117be21f2c16e2f4fa10.tar.gz
gcc-2f05dadaeda6068ad570117be21f2c16e2f4fa10.tar.bz2
Arm: Add support for auto-vectorization using HF mode.
This adds support to the auto-vectorizer to support HFmode vectorization for AArch32. This is supported when +fp16 is used. I wonder if I should disable the returning of the type if the option isn't enabled. At the moment it will be returned but the vectorizer will try and fail to use it. It wastes a few compile cycles but doesn't result in bad code. gcc/ChangeLog: * config/arm/arm.c (arm_preferred_simd_mode): Add E_HFmode. gcc/testsuite/ChangeLog: * gcc.target/arm/vect-half-floats.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/arm/arm.c2
-rw-r--r--gcc/testsuite/gcc.target/arm/vect-half-floats.c14
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 2f0ef3b..7115c0a 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -29130,6 +29130,8 @@ arm_preferred_simd_mode (scalar_mode mode)
if (TARGET_NEON)
switch (mode)
{
+ case E_HFmode:
+ return TARGET_NEON_VECTORIZE_DOUBLE ? V4HFmode : V8HFmode;
case E_SFmode:
return TARGET_NEON_VECTORIZE_DOUBLE ? V2SFmode : V4SFmode;
case E_SImode:
diff --git a/gcc/testsuite/gcc.target/arm/vect-half-floats.c b/gcc/testsuite/gcc.target/arm/vect-half-floats.c
new file mode 100644
index 0000000..ebfe7f9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/vect-half-floats.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target target_float16 } */
+/* { dg-require-effective-target arm_fp16_ok } */
+/* { dg-add-options for_float16 } */
+/* { dg-additional-options "-Ofast -ftree-vectorize -fdump-tree-vect-all -std=c11" } */
+
+void foo (_Float16 n1[], _Float16 n2[], _Float16 r[], int n)
+{
+ for (int i = 0; i < n; i++)
+ r[i] = n1[i] + n2[i];
+}
+
+/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */
+