aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2017-11-17 09:25:22 -0700
committerJeff Law <law@gcc.gnu.org>2017-11-17 09:25:22 -0700
commitf432e4fc930be596b266f160480514aa7f026e82 (patch)
tree0280065703b6104143b2dbc2f7c4f4be71636ddf /gcc
parent4f2a94e68ebd12c85a98c4cf3e840c61094aad34 (diff)
downloadgcc-f432e4fc930be596b266f160480514aa7f026e82.zip
gcc-f432e4fc930be596b266f160480514aa7f026e82.tar.gz
gcc-f432e4fc930be596b266f160480514aa7f026e82.tar.bz2
vr-values.h (get_output_for_vrp): Prototype.
* vr-values.h (get_output_for_vrp): Prototype. * vr-values.c (get_output_for_vrp): New function extracted from vrp_visit_assignment_or_call and extract_range_from_stmt. (vrp_visit_assignment_or_call): Use get_output_for_vrp. Simplify. From-SVN: r254880
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/vr-values.c36
-rw-r--r--gcc/vr-values.h1
3 files changed, 34 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 38101fa..82111ba 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2017-11-17 Jeff Law <law@redhat.com>
+
+ * vr-values.h (get_output_for_vrp): Prototype.
+ * vr-values.c (get_output_for_vrp): New function extracted from
+ vrp_visit_assignment_or_call and extract_range_from_stmt.
+ (vrp_visit_assignment_or_call): Use get_output_for_vrp. Simplify.
+
2017-11-17 Luis Machado <luis.machado@linaro.org>
* config/aarch64/aarch64.c
diff --git a/gcc/vr-values.c b/gcc/vr-values.c
index d4434de..3e760a3 100644
--- a/gcc/vr-values.c
+++ b/gcc/vr-values.c
@@ -1955,19 +1955,18 @@ vrp_valueize_1 (tree name)
}
return name;
}
-/* Visit assignment STMT. If it produces an interesting range, record
- the range in VR and set LHS to OUTPUT_P. */
-void
-vr_values::vrp_visit_assignment_or_call (gimple *stmt, tree *output_p,
- value_range *vr)
+/* Given STMT, an assignment or call, return its LHS if the type
+ of the LHS is suitable for VRP analysis, else return NULL_TREE. */
+
+tree
+get_output_for_vrp (gimple *stmt)
{
- tree lhs;
- enum gimple_code code = gimple_code (stmt);
- lhs = gimple_get_lhs (stmt);
- *output_p = NULL_TREE;
+ if (!is_gimple_assign (stmt) && !is_gimple_call (stmt))
+ return NULL_TREE;
/* We only keep track of ranges in integral and pointer types. */
+ tree lhs = gimple_get_lhs (stmt);
if (TREE_CODE (lhs) == SSA_NAME
&& ((INTEGRAL_TYPE_P (TREE_TYPE (lhs))
/* It is valid to have NULL MIN/MAX values on a type. See
@@ -1975,8 +1974,25 @@ vr_values::vrp_visit_assignment_or_call (gimple *stmt, tree *output_p,
&& TYPE_MIN_VALUE (TREE_TYPE (lhs))
&& TYPE_MAX_VALUE (TREE_TYPE (lhs)))
|| POINTER_TYPE_P (TREE_TYPE (lhs))))
+ return lhs;
+
+ return NULL_TREE;
+}
+
+/* Visit assignment STMT. If it produces an interesting range, record
+ the range in VR and set LHS to OUTPUT_P. */
+
+void
+vr_values::vrp_visit_assignment_or_call (gimple *stmt, tree *output_p,
+ value_range *vr)
+{
+ tree lhs = get_output_for_vrp (stmt);
+ *output_p = lhs;
+
+ /* We only keep track of ranges in integral and pointer types. */
+ if (lhs)
{
- *output_p = lhs;
+ enum gimple_code code = gimple_code (stmt);
/* Try folding the statement to a constant first. */
x_vr_values = this;
diff --git a/gcc/vr-values.h b/gcc/vr-values.h
index 20bd6c5..24f013a 100644
--- a/gcc/vr-values.h
+++ b/gcc/vr-values.h
@@ -118,4 +118,5 @@ class vr_values
#define VR_INITIALIZER { VR_UNDEFINED, NULL_TREE, NULL_TREE, NULL }
+extern tree get_output_for_vrp (gimple *);
#endif /* GCC_VR_VALUES_H */