amdgcn: OpenMP SIMD routine support

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.
This commit is contained in:
Andrew Stubbs 2022-07-14 11:31:31 +01:00
parent f134a25ee8
commit b73c49f6f8
7 changed files with 72 additions and 0 deletions

View file

@ -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

View file

@ -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 } */

View file

@ -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 } */

View file

@ -43,3 +43,4 @@ main ()
return 0;
}
/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } 15 } */

View file

@ -46,3 +46,4 @@ main ()
return 0;
}
/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } 17 } */

View file

@ -41,3 +41,4 @@ main ()
return 0;
}
/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } 15 } */

View file

@ -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 } */