+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
}
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
&& 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;