summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2017-11-17 02:38:11 -0500
committerAldy Hernandez <aldyh@redhat.com>2017-11-17 02:38:11 -0500
commit2cb1a2872f69509868f63aa9a5ceeb5528f46649 (patch)
treee344de7f02de058e050fafcf6590cadeb3fd79fc
parentb903f857502c5f96d3d2d5343f8a86dbee5be4e4 (diff)
parentfd3d0e9507235a523c2199d24c032be495b60153 (diff)
downloadgcc-2cb1a2872f69509868f63aa9a5ceeb5528f46649.tar.gz
Merge remote-tracking branch 'remotes/svn/range-gen3' into threader
-rw-r--r--gcc/range.h2
-rw-r--r--gcc/ssa-def-chain.c5
-rw-r--r--gcc/ssa-range-stmt.c40
-rw-r--r--gcc/ssa-range-stmt.h3
4 files changed, 31 insertions, 19 deletions
diff --git a/gcc/range.h b/gcc/range.h
index 18deb88219d..3929b929cf6 100644
--- a/gcc/range.h
+++ b/gcc/range.h
@@ -249,6 +249,7 @@ class GTY((variable_size)) irange_storage
{ irange_storage *stow = static_cast<irange_storage *> (ggc_internal_alloc
(size (precision)));
stow->trailing_bounds.set_precision (precision);
+ stow->set_nonzero_bits (wi::shwi (-1, precision));
return stow;
}
/* Like irange_storage::ggc_alloc (), but initialize the storage to
@@ -259,6 +260,7 @@ class GTY((variable_size)) irange_storage
irange_storage *stow = static_cast<irange_storage *> (ggc_internal_alloc
(size (precision)));
stow->set_irange (ir);
+ stow->set_nonzero_bits (wi::shwi (-1, precision));
return stow;
}
/* Extract the current range onto OUTPUT with a type of TYP.
diff --git a/gcc/ssa-def-chain.c b/gcc/ssa-def-chain.c
index b7cf53356c4..332d43f4f37 100644
--- a/gcc/ssa-def-chain.c
+++ b/gcc/ssa-def-chain.c
@@ -117,7 +117,6 @@ ssa_define_chain::process_op (tree operand, unsigned version, basic_block bb)
/* Make sure defintion chain exists for operand. */
term = generate_def_chain (operand);
- // terminal[op_index] = term; set by generate isnt it?
/* If it has a chain, add them to this one. */
ret = def_chain [op_index];
@@ -160,9 +159,9 @@ ssa_define_chain::generate_def_chain (tree name)
ret = process_op (ssa1, index, bb);
if (ssa2)
tmp = process_op (ssa2, index, bb);
- /* If there are 2 terminal results, there is no terminal. */
+ /* If there are 2 different terminal results, this is the terminal. */
if (ret && tmp && ret != tmp)
- ret = NULL_TREE;
+ ret = name;
else
if (!ret)
ret = tmp;
diff --git a/gcc/ssa-range-stmt.c b/gcc/ssa-range-stmt.c
index 37fee082a33..7d43c9a986c 100644
--- a/gcc/ssa-range-stmt.c
+++ b/gcc/ssa-range-stmt.c
@@ -105,20 +105,13 @@ range_stmt::validate_operands ()
ssa1 = valid_irange_ssa (op1);
ssa2 = valid_irange_ssa (op2);
- if (!op2)
- {
- if (ssa1 || (TREE_CODE (op1) == INTEGER_CST && !TREE_OVERFLOW (op1)))
- return true;
- }
- else
- {
- if (ssa1 && ssa2 && ((code >= LT_EXPR && code <= NE_EXPR)
- || logical_expr_p (TREE_TYPE (op1))))
- return true;
- if ((ssa1 || (TREE_CODE (op1) == INTEGER_CST && !TREE_OVERFLOW (op1)))
- && (ssa2 || (TREE_CODE (op2) == INTEGER_CST && !TREE_OVERFLOW (op2))))
- return true;
- }
+ if (ssa1 || (TREE_CODE (op1) == INTEGER_CST && !TREE_OVERFLOW (op1)))
+ {
+ if (!op2)
+ return true;
+ if (ssa2 || (TREE_CODE (op2) == INTEGER_CST && !TREE_OVERFLOW (op2)))
+ return true;
+ }
return false;
}
@@ -166,6 +159,23 @@ range_stmt::from_stmt (gimple *s)
}
+// Transition of expression type from non-boolean to boolean are considered
+// anchor statements for range generation. Meaning we evaluate the range of the
+// operand for this block, and then make any adjustments to that range for
+// ssa-Names in the definition chain
+bool
+range_stmt::logical_transition_p () const
+{
+ // a boolean LHS and non-boolean RHS. Relationals dont alwsy have a LHS.
+ if (code >= LT_EXPR && code <= NE_EXPR)
+ return true;
+ tree lhs = gimple_get_lhs (g);
+ if (lhs && TREE_CODE (TREE_TYPE (lhs)) == BOOLEAN_TYPE &&
+ TREE_CODE (TREE_TYPE (op1)) != BOOLEAN_TYPE)
+ return true;
+ return false;
+}
+
bool
range_stmt::logical_expr_p (tree type) const
{
@@ -192,7 +202,7 @@ range_stmt::logical_expr_p (tree type) const
bool
range_stmt::logical_expr (irange& r, const irange& lhs, const irange& op1_true,
const irange& op1_false, const irange& op2_true,
- const irange& op2_false)
+ const irange& op2_false) const
{
gcc_checking_assert (logical_expr_p (TREE_TYPE (op1)));
diff --git a/gcc/ssa-range-stmt.h b/gcc/ssa-range-stmt.h
index 4c3de26c541..3be1fe673a2 100644
--- a/gcc/ssa-range-stmt.h
+++ b/gcc/ssa-range-stmt.h
@@ -59,10 +59,11 @@ public:
tree ssa_operand1 () const;
tree ssa_operand2 () const;
+ bool logical_transition_p () const;
bool logical_expr_p (tree type) const;
bool logical_expr (irange& r, const irange& lhs, const irange& op1_true,
const irange& op1_false, const irange& op2_true,
- const irange& op2_false);
+ const irange& op2_false) const;
bool fold (irange& res) const;
bool fold (irange& res, tree name, const irange& name_range) const;
bool fold (irange& res, const irange& r1) const;