[2/3] amdgcn: OpenMP SIMD routine support
Commit Message
Enable and configure SIMD clones for amdgcn. This affects both the __simd__
function attribute, and the OpenMP "declare simd" directive.
Note that the masked SIMD variants are generated, but the middle end doesn't
actually support calling them yet.
gcc/ChangeLog:
* config/gcn/gcn.cc (gcn_simd_clone_compute_vecsize_and_simdlen): New.
(gcn_simd_clone_adjust): New.
(gcn_simd_clone_usable): New.
(TARGET_SIMD_CLONE_ADJUST): New.
(TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN): New.
(TARGET_SIMD_CLONE_USABLE): New.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/vect-simd-clone-1.c: Add dg-warning.
* gcc.dg/vect/vect-simd-clone-2.c: Add dg-warning.
* gcc.dg/vect/vect-simd-clone-3.c: Add dg-warning.
* gcc.dg/vect/vect-simd-clone-4.c: Add dg-warning.
* gcc.dg/vect/vect-simd-clone-5.c: Add dg-warning.
* gcc.dg/vect/vect-simd-clone-8.c: Add dg-warning.
---
gcc/config/gcn/gcn.cc | 63 +++++++++++++++++++
gcc/testsuite/gcc.dg/vect/vect-simd-clone-1.c | 2 +
gcc/testsuite/gcc.dg/vect/vect-simd-clone-2.c | 2 +
gcc/testsuite/gcc.dg/vect/vect-simd-clone-3.c | 1 +
gcc/testsuite/gcc.dg/vect/vect-simd-clone-4.c | 1 +
gcc/testsuite/gcc.dg/vect/vect-simd-clone-5.c | 1 +
gcc/testsuite/gcc.dg/vect/vect-simd-clone-8.c | 2 +
7 files changed, 72 insertions(+)
Comments
On 09/08/2022 14:23, Andrew Stubbs wrote:
>
> Enable and configure SIMD clones for amdgcn. This affects both the __simd__
> function attribute, and the OpenMP "declare simd" directive.
>
> Note that the masked SIMD variants are generated, but the middle end doesn't
> actually support calling them yet.
>
> gcc/ChangeLog:
>
> * config/gcn/gcn.cc (gcn_simd_clone_compute_vecsize_and_simdlen): New.
> (gcn_simd_clone_adjust): New.
> (gcn_simd_clone_usable): New.
> (TARGET_SIMD_CLONE_ADJUST): New.
> (TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN): New.
> (TARGET_SIMD_CLONE_USABLE): New.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/vect/vect-simd-clone-1.c: Add dg-warning.
> * gcc.dg/vect/vect-simd-clone-2.c: Add dg-warning.
> * gcc.dg/vect/vect-simd-clone-3.c: Add dg-warning.
> * gcc.dg/vect/vect-simd-clone-4.c: Add dg-warning.
> * gcc.dg/vect/vect-simd-clone-5.c: Add dg-warning.
> * gcc.dg/vect/vect-simd-clone-8.c: Add dg-warning.
The dependency was approved, so this is now committed.
Andrew
@@ -52,6 +52,7 @@
#include "rtl-iter.h"
#include "dwarf2.h"
#include "gimple.h"
+#include "cgraph.h"
/* This file should be included last. */
#include "target-def.h"
@@ -4555,6 +4556,61 @@ gcn_vectorization_cost (enum vect_cost_for_stmt ARG_UNUSED (type_of_cost),
return 1;
}
+/* Implement TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN. */
+
+static int
+gcn_simd_clone_compute_vecsize_and_simdlen (struct cgraph_node *ARG_UNUSED (node),
+ struct cgraph_simd_clone *clonei,
+ tree base_type,
+ int ARG_UNUSED (num))
+{
+ unsigned int elt_bits = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (base_type));
+
+ if (known_eq (clonei->simdlen, 0U))
+ clonei->simdlen = 64;
+ else if (maybe_ne (clonei->simdlen, 64U))
+ {
+ /* Note that x86 has a similar message that is likely to trigger on
+ sizes that are OK for gcn; the user can't win. */
+ warning_at (DECL_SOURCE_LOCATION (node->decl), 0,
+ "unsupported simdlen %wd (amdgcn)",
+ clonei->simdlen.to_constant ());
+ return 0;
+ }
+
+ clonei->vecsize_mangle = 'n';
+ clonei->vecsize_int = 0;
+ clonei->vecsize_float = 0;
+
+ /* DImode ought to be more natural here, but VOIDmode produces better code,
+ at present, due to the shift-and-test steps not being optimized away
+ inside the in-branch clones. */
+ clonei->mask_mode = VOIDmode;
+
+ return 1;
+}
+
+/* Implement TARGET_SIMD_CLONE_ADJUST. */
+
+static void
+gcn_simd_clone_adjust (struct cgraph_node *ARG_UNUSED (node))
+{
+ /* This hook has to be defined when
+ TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN is defined, but we don't
+ need it to do anything yet. */
+}
+
+/* Implement TARGET_SIMD_CLONE_USABLE. */
+
+static int
+gcn_simd_clone_usable (struct cgraph_node *ARG_UNUSED (node))
+{
+ /* We don't need to do anything here because
+ gcn_simd_clone_compute_vecsize_and_simdlen currently only returns one
+ possibility. */
+ return 0;
+}
+
/* }}} */
/* {{{ md_reorg pass. */
@@ -6643,6 +6699,13 @@ gcn_dwarf_register_span (rtx rtl)
#define TARGET_SECTION_TYPE_FLAGS gcn_section_type_flags
#undef TARGET_SCALAR_MODE_SUPPORTED_P
#define TARGET_SCALAR_MODE_SUPPORTED_P gcn_scalar_mode_supported_p
+#undef TARGET_SIMD_CLONE_ADJUST
+#define TARGET_SIMD_CLONE_ADJUST gcn_simd_clone_adjust
+#undef TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN
+#define TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN \
+ gcn_simd_clone_compute_vecsize_and_simdlen
+#undef TARGET_SIMD_CLONE_USABLE
+#define TARGET_SIMD_CLONE_USABLE gcn_simd_clone_usable
#undef TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P
#define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P \
gcn_small_register_classes_for_mode_p
@@ -56,3 +56,5 @@ main ()
return 0;
}
+/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } 18 } */
+/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } 18 } */
@@ -50,3 +50,5 @@ main ()
return 0;
}
+/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } 18 } */
+/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } 18 } */
@@ -43,3 +43,4 @@ main ()
return 0;
}
+/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } 15 } */
@@ -46,3 +46,4 @@ main ()
return 0;
}
+/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } 17 } */
@@ -41,3 +41,4 @@ main ()
return 0;
}
+/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } 15 } */
@@ -92,3 +92,5 @@ main ()
return 0;
}
+/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } 17 } */
+/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } 24 } */