aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssanames.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2016-01-15 15:32:05 -0700
committerJeff Law <law@gcc.gnu.org>2016-01-15 15:32:05 -0700
commit40c43acacc1765416278e6636c20c5e3a78a7384 (patch)
tree0c5e0c93ef87ace7d5ef512867efe2303ef79439 /gcc/tree-ssanames.c
parentcebeb718fed641f5c6b093e487c5e93c9b41ce02 (diff)
downloadgcc-40c43acacc1765416278e6636c20c5e3a78a7384.zip
gcc-40c43acacc1765416278e6636c20c5e3a78a7384.tar.gz
gcc-40c43acacc1765416278e6636c20c5e3a78a7384.tar.bz2
re PR tree-optimization/69270 (DOM should exploit range information to create more equivalences)
PR tree-optimization/69270 * tree-ssanames.c (ssa_name_has_boolean_range): Moved here from tree-ssa-dom.c. Improve test for [0..1] ranve from VRP. * tree-ssa-dom.c (ssa_name_has_boolean_range): Remove. * tree-ssanames.h (ssa_name_has_boolean_range): Prototype. * tree-ssa-uncprop.c (associate_equivalences_with_edges): Use ssa_name_has_boolean_range and constant_boolean_node. PR tree-optimization/69270 * gcc.dg/tree-ssa/pr69270-2.c: New test. * gcc.dg/tree-ssa/pr69270-3.c: New test. From-SVN: r232453
Diffstat (limited to 'gcc/tree-ssanames.c')
-rw-r--r--gcc/tree-ssanames.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index 82866b2..b6f72e2 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -411,6 +411,40 @@ get_nonzero_bits (const_tree name)
return ri->get_nonzero_bits ();
}
+/* Return TRUE is OP, an SSA_NAME has a range of values [0..1], false
+ otherwise.
+
+ This can be because it is a boolean type, any unsigned integral
+ type with a single bit of precision, or has known range of [0..1]
+ via VRP analysis. */
+
+bool
+ssa_name_has_boolean_range (tree op)
+{
+ gcc_assert (TREE_CODE (op) == SSA_NAME);
+
+ /* Boolean types always have a range [0..1]. */
+ if (TREE_CODE (TREE_TYPE (op)) == BOOLEAN_TYPE)
+ return true;
+
+ /* An integral type with a single bit of precision. */
+ if (INTEGRAL_TYPE_P (TREE_TYPE (op))
+ && TYPE_UNSIGNED (TREE_TYPE (op))
+ && TYPE_PRECISION (TREE_TYPE (op)) == 1)
+ return true;
+
+ /* An integral type with more precision, but the object
+ only takes on values [0..1] as determined by VRP
+ analysis. */
+ if (INTEGRAL_TYPE_P (TREE_TYPE (op))
+ && (TYPE_PRECISION (TREE_TYPE (op)) > 1
+ || TYPE_UNSIGNED (TREE_TYPE (op)))
+ && wi::eq_p (get_nonzero_bits (op), 1))
+ return true;
+
+ return false;
+}
+
/* We no longer need the SSA_NAME expression VAR, release it so that
it may be reused.