aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
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;
}