aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2019-01-03 15:08:06 +0000
committerTom de Vries <vries@gcc.gnu.org>2019-01-03 15:08:06 +0000
commit5f57c8f347352a8c9fd8cfbf253a545f272850d6 (patch)
treeb5d8d9aae6325d56c3c3d2d910eef6e71f319cd3
parented72c2e3b39a30ece53f0896c594160c6aa53330 (diff)
downloadgcc-5f57c8f347352a8c9fd8cfbf253a545f272850d6.zip
gcc-5f57c8f347352a8c9fd8cfbf253a545f272850d6.tar.gz
gcc-5f57c8f347352a8c9fd8cfbf253a545f272850d6.tar.bz2
[nvptx] Eliminate changed local var in nvptx_goacc_validate_dims
The TARGET_GOACC_VALIDATE_DIMS hook requires an implementation to return a bool indicating whether the dims parameter has changed. Factor nvptx_goacc_validate_dims_1 out of nvptx_goacc_validate_dims, and calculate the return value in nvptx_goacc_validate_dims. 2019-01-03 Tom de Vries <tdevries@suse.de> * config/nvptx/nvptx.c (nvptx_goacc_validate_dims_1): New function, factored out of ... (nvptx_goacc_validate_dims): ... here. From-SVN: r267555
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/nvptx/nvptx.c38
2 files changed, 32 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1cf696b..4f1150f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2019-01-03 Tom de Vries <tdevries@suse.de>
+
+ * config/nvptx/nvptx.c (nvptx_goacc_validate_dims_1): New function,
+ factored out of ...
+ (nvptx_goacc_validate_dims): ... here.
+
2019-01-03 Jan Hubicka <hubicka@ucw.cz>
PR tree-optimization/85574
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 9baf4ab..0b9701d 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -5188,15 +5188,12 @@ nvptx_simt_vf ()
return PTX_WARP_SIZE;
}
-/* Validate compute dimensions of an OpenACC offload or routine, fill
- in non-unity defaults. FN_LEVEL indicates the level at which a
- routine might spawn a loop. It is negative for non-routines. If
- DECL is null, we are validating the default dimensions. */
+/* As nvptx_goacc_validate_dims, but does not return bool to indicate whether
+ DIMS has changed. */
-static bool
-nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
+static void
+nvptx_goacc_validate_dims_1 (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;
@@ -5255,7 +5252,6 @@ nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
dims[GOMP_DIM_VECTOR] = fn_level > GOMP_DIM_VECTOR ? 1 : 0;
dims[GOMP_DIM_WORKER] = fn_level > GOMP_DIM_WORKER ? 1 : 0;
dims[GOMP_DIM_GANG] = fn_level > GOMP_DIM_GANG ? 1 : 0;
- changed = true;
}
/* The vector size must be 32, unless this is a SEQ routine. */
@@ -5272,7 +5268,6 @@ nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
: G_("using vector_length (%d), ignoring runtime setting"),
PTX_VECTOR_LENGTH, dims[GOMP_DIM_VECTOR]);
dims[GOMP_DIM_VECTOR] = PTX_VECTOR_LENGTH;
- changed = true;
}
/* Check the num workers is not too large. */
@@ -5282,7 +5277,6 @@ nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
"using num_workers (%d), ignoring %d",
PTX_WORKER_LENGTH, dims[GOMP_DIM_WORKER]);
dims[GOMP_DIM_WORKER] = PTX_WORKER_LENGTH;
- changed = true;
}
if (oacc_default_dims_p || oacc_min_dims_p)
@@ -5292,10 +5286,30 @@ nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
dims[GOMP_DIM_WORKER] = PTX_DEFAULT_RUNTIME_DIM;
if (dims[GOMP_DIM_GANG] < 0)
dims[GOMP_DIM_GANG] = PTX_DEFAULT_RUNTIME_DIM;
- changed = true;
}
+}
+
+/* Validate compute dimensions of an OpenACC offload or routine, fill
+ in non-unity defaults. FN_LEVEL indicates the level at which a
+ routine might spawn a loop. It is negative for non-routines. If
+ DECL is null, we are validating the default dimensions. */
+
+static bool
+nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
+{
+ int old_dims[GOMP_DIM_MAX];
+ unsigned int i;
- return changed;
+ for (i = 0; i < GOMP_DIM_MAX; ++i)
+ old_dims[i] = dims[i];
+
+ nvptx_goacc_validate_dims_1 (decl, dims, fn_level);
+
+ for (i = 0; i < GOMP_DIM_MAX; ++i)
+ if (old_dims[i] != dims[i])
+ return true;
+
+ return false;
}
/* Return maximum dimension size, or zero for unbounded. */