aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2018-12-17 21:26:39 +0000
committerTom de Vries <vries@gcc.gnu.org>2018-12-17 21:26:39 +0000
commitec6c865c6dc342dd6e99842377da5c18706a74ee (patch)
tree983e41c328af15f8c6280942d254b9a94f4c8ead
parentc764b12ccaaa84226682b9c19a448d51501ca56b (diff)
downloadgcc-ec6c865c6dc342dd6e99842377da5c18706a74ee.zip
gcc-ec6c865c6dc342dd6e99842377da5c18706a74ee.tar.gz
gcc-ec6c865c6dc342dd6e99842377da5c18706a74ee.tar.bz2
[nvptx] Rewrite nvptx_goacc_validate_dims to use predicate vars
The function nvptx_goacc_validate_dims has arguments decl and fn_level which together describe different situations. Introduce a predicate var for each situation, and use them, allowing to understand what the function does in each situation without having to know the way the situations are encoded in the args. Build and reg-tested on x86_64 with nvptx accelerator. 2018-12-17 Tom de Vries <tdevries@suse.de> * config/nvptx/nvptx.c (nvptx_goacc_validate_dims): Rewrite using predicate vars. From-SVN: r267212
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/nvptx/nvptx.c32
2 files changed, 34 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 637baa8..7281f42 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2018-12-17 Tom de Vries <tdevries@suse.de>
+
+ * config/nvptx/nvptx.c (nvptx_goacc_validate_dims): Rewrite using
+ predicate vars.
+
2018-12-17 Steve Ellcey <sellcey@cavium.com>
* config/aarch64/aarch64-protos.h (aarch64_use_simple_return_insn_p):
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 9903a27..746d8bf 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -5187,13 +5187,39 @@ static bool
nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
{
bool changed = false;
+ bool oacc_default_dims_p = false;
+ bool oacc_min_dims_p = false;
+ bool offload_region_p = false;
+ bool routine_p = false;
+ bool routine_seq_p = false;
+
+ if (decl == NULL_TREE)
+ {
+ if (fn_level == -1)
+ oacc_default_dims_p = true;
+ else if (fn_level == -2)
+ oacc_min_dims_p = true;
+ else
+ gcc_unreachable ();
+ }
+ else if (fn_level == -1)
+ offload_region_p = true;
+ else if (0 <= fn_level && fn_level <= GOMP_DIM_MAX)
+ {
+ routine_p = true;
+ routine_seq_p = fn_level == GOMP_DIM_MAX;
+ }
+ else
+ gcc_unreachable ();
/* The vector size must be 32, unless this is a SEQ routine. */
- if (fn_level <= GOMP_DIM_VECTOR && fn_level >= -1
+ if ((offload_region_p || oacc_default_dims_p
+ || (routine_p && !routine_seq_p))
&& dims[GOMP_DIM_VECTOR] >= 0
&& dims[GOMP_DIM_VECTOR] != PTX_VECTOR_LENGTH)
{
- if (fn_level < 0 && dims[GOMP_DIM_VECTOR] >= 0)
+ if ((offload_region_p || oacc_default_dims_p)
+ && dims[GOMP_DIM_VECTOR] >= 0)
warning_at (decl ? DECL_SOURCE_LOCATION (decl) : UNKNOWN_LOCATION, 0,
dims[GOMP_DIM_VECTOR]
? G_("using vector_length (%d), ignoring %d")
@@ -5213,7 +5239,7 @@ nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
changed = true;
}
- if (!decl)
+ if (oacc_default_dims_p || oacc_min_dims_p)
{
dims[GOMP_DIM_VECTOR] = PTX_VECTOR_LENGTH;
if (dims[GOMP_DIM_WORKER] < 0)