aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.h
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2016-11-24 12:02:53 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2016-11-24 12:02:53 +0000
commit3b08cde8dd2b27740e04a6f0e531f2c086a9ec1b (patch)
treeff79e8ab3cb9680654f64078b74a188db96fca41 /gcc/tree.h
parentbf2df7a9b39897740e6b2fc8c03b1b195748c98f (diff)
downloadgcc-3b08cde8dd2b27740e04a6f0e531f2c086a9ec1b.zip
gcc-3b08cde8dd2b27740e04a6f0e531f2c086a9ec1b.tar.gz
gcc-3b08cde8dd2b27740e04a6f0e531f2c086a9ec1b.tar.bz2
re PR middle-end/78429 (ICE in set_value_range, at tree-vrp.c on non-standard boolean)
PR middle-end/78429 * tree.h (wi::fits_to_boolean_p): New predicate. (wi::fits_to_tree_p): Use it for boolean types. * tree.c (int_fits_type_p): Likewise. From-SVN: r242829
Diffstat (limited to 'gcc/tree.h')
-rw-r--r--gcc/tree.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/gcc/tree.h b/gcc/tree.h
index b4ec3fd..62cd7bb 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -5296,6 +5296,9 @@ wi::extended_tree <N>::get_len () const
namespace wi
{
template <typename T>
+ bool fits_to_boolean_p (const T &x, const_tree);
+
+ template <typename T>
bool fits_to_tree_p (const T &x, const_tree);
wide_int min_value (const_tree);
@@ -5305,14 +5308,21 @@ namespace wi
template <typename T>
bool
+wi::fits_to_boolean_p (const T &x, const_tree type)
+{
+ return eq_p (x, 0) || eq_p (x, TYPE_UNSIGNED (type) ? 1 : -1);
+}
+
+template <typename T>
+bool
wi::fits_to_tree_p (const T &x, const_tree type)
{
- /* Short-circuit boolean types since various transformations assume that
- they can only take values 0 and 1. */
+ /* Non-standard boolean types can have arbitrary precision but various
+ transformations assume that they can only take values 0 and +/-1. */
if (TREE_CODE (type) == BOOLEAN_TYPE)
- return eq_p (x, 0) || eq_p (x, 1);
+ return fits_to_boolean_p (x, type);
- if (TYPE_SIGN (type) == UNSIGNED)
+ if (TYPE_UNSIGNED (type))
return eq_p (x, zext (x, TYPE_PRECISION (type)));
else
return eq_p (x, sext (x, TYPE_PRECISION (type)));