aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2015-11-05 13:50:13 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2015-11-05 13:50:13 +0000
commitbd7519757549bb0f61433767be4587d1d287fbae (patch)
tree7e0c36ef8da7959fa24be13c6ac216e007bdfb80 /gcc/tree-vrp.c
parent337d2167ccf01c028e993852f6d3a4681a021505 (diff)
downloadgcc-bd7519757549bb0f61433767be4587d1d287fbae.zip
gcc-bd7519757549bb0f61433767be4587d1d287fbae.tar.gz
gcc-bd7519757549bb0f61433767be4587d1d287fbae.tar.bz2
target.def (goacc.dim_limit): New hook.
* target.def (goacc.dim_limit): New hook. * targhooks.h (default_goacc_dim_limit): Declare. * doc/tm.texi.in (TARGET_GOACC_DIM_LIMIT): Add. * doc/tm.texi: Rebuilt. * omp-low.h (get_oacc_fn_dim_size, get_oacc_ifn_dim_arg): Declare. * omp-low.c (get_oacc_fn_dim_size, get_oacc_ifn_dim_arg): New. (default_goacc_dim_limit): New. * config/nvptx/nvptx.c (PTX_VECTOR_LENGTH, PTX_WORKER_LENGTH): New. (nvptx_goacc_dim_limit) New. (TARGET_GOACC_DIM_LIMIT): Override. * tree-vrp.c: Include omp-low.h, target.h. (extract_range_basic): Add handling for IFN_GOACC_DIM_SIZE & IFN_GOACC_DIM_POS. From-SVN: r229809
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r--gcc/tree-vrp.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 807c6ec..c0b6cfc 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -55,8 +55,8 @@ along with GCC; see the file COPYING3. If not see
#include "tree-ssa-threadupdate.h"
#include "tree-ssa-scopedtables.h"
#include "tree-ssa-threadedge.h"
-
-
+#include "omp-low.h"
+#include "target.h"
/* Range of values that can be associated with an SSA_NAME after VRP
has executed. */
@@ -3973,7 +3973,9 @@ extract_range_basic (value_range *vr, gimple *stmt)
else if (is_gimple_call (stmt) && gimple_call_internal_p (stmt))
{
enum tree_code subcode = ERROR_MARK;
- switch (gimple_call_internal_fn (stmt))
+ unsigned ifn_code = gimple_call_internal_fn (stmt);
+
+ switch (ifn_code)
{
case IFN_UBSAN_CHECK_ADD:
subcode = PLUS_EXPR;
@@ -3984,6 +3986,28 @@ extract_range_basic (value_range *vr, gimple *stmt)
case IFN_UBSAN_CHECK_MUL:
subcode = MULT_EXPR;
break;
+ case IFN_GOACC_DIM_SIZE:
+ case IFN_GOACC_DIM_POS:
+ /* Optimizing these two internal functions helps the loop
+ optimizer eliminate outer comparisons. Size is [1,N]
+ and pos is [0,N-1]. */
+ {
+ bool is_pos = ifn_code == IFN_GOACC_DIM_POS;
+ int axis = get_oacc_ifn_dim_arg (stmt);
+ int size = get_oacc_fn_dim_size (current_function_decl, axis);
+
+ if (!size)
+ /* If it's dynamic, the backend might know a hardware
+ limitation. */
+ size = targetm.goacc.dim_limit (axis);
+
+ tree type = TREE_TYPE (gimple_call_lhs (stmt));
+ set_value_range (vr, VR_RANGE,
+ build_int_cst (type, is_pos ? 0 : 1),
+ size ? build_int_cst (type, size - is_pos)
+ : vrp_val_max (type), NULL);
+ }
+ return;
default:
break;
}