On 05/13/2016 12:50 PM, Marc Glisse wrote:
Hello,
when VRP does some transforms, it may create new SSA_NAMEs, but doesn't
give them range information. This can prevent cascading transformations
in a single VRP pass. With this patch, I assign range information to the
variable introduced by one transformation, and in another
transformation, I get range information through get_range_info instead
of get_value_range in order to have access to the new information.
Some notes:
- get_range_info only applies to integers, not pointers. I hope we are
not losing much by restricting this transformation. I could also call
get_value_range and only fall back to get_range_info if that failed (and
we don't have a pointer), but it doesn't seem worth it.
It probably isn't worth it.
- Now that I think of it, maybe I should check that the variable is not
a pointer before calling set_range_info? Having range [0, 1] makes it
unlikely, but who knows...
Maybe using an assert would be better.
Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c (revision 236194)
+++ gcc/tree-vrp.c (working copy)
@@ -8933,20 +8933,24 @@ simplify_truth_ops_using_ranges (gimple_
gimple_assign_set_rhs_with_ops (gsi,
need_conversion
? NOP_EXPR : TREE_CODE (op0), op0);
/* For A != B we substitute A ^ B. Either with conversion. */
else if (need_conversion)
{
tree tem = make_ssa_name (TREE_TYPE (op0));
gassign *newop
= gimple_build_assign (tem, BIT_XOR_EXPR, op0, op1);
gsi_insert_before (gsi, newop, GSI_SAME_STMT);
+ if (TYPE_PRECISION (TREE_TYPE (tem)) > 1)
+ set_range_info (tem, VR_RANGE,
+ wi::zero (TYPE_PRECISION (TREE_TYPE (tem))),
+ wi::one (TYPE_PRECISION (TREE_TYPE (tem))));
Is there actually a case where TYPE_PRECISION (TREE_TYPE (tem)) > 1 is
ever false? Would an assert make more sense here?
/* Simplify an integral conversion from an SSA name in STMT. */
static bool
simplify_conversion_using_ranges (gimple *stmt)
Your ChangeLog mentions simplify_switch_using_ranges, not
simplify_conversion_using_ranges.
This is OK for the trunk -- your call on asserting the variable is not a
pointer before calling set_range_info. Similarly on the check that the
TYPE_PRECISION (TREE_TYPE (tem)) > 1.
Jeff