aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.h
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2016-10-25 17:11:49 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2016-10-25 17:11:49 +0000
commit90e261e494a5f1fda83b815f513c5621fa5f8c83 (patch)
tree287ecd3c49a6b519376afa6b2ba709f33d37870a /gcc/tree.h
parentcef026ecafe169871284fded6494efe33e763950 (diff)
downloadgcc-90e261e494a5f1fda83b815f513c5621fa5f8c83.zip
gcc-90e261e494a5f1fda83b815f513c5621fa5f8c83.tar.gz
gcc-90e261e494a5f1fda83b815f513c5621fa5f8c83.tar.bz2
tree.h (wi::fits_to_tree_p): Accept only 0 and 1 for boolean types.
* tree.h (wi::fits_to_tree_p): Accept only 0 and 1 for boolean types. * tree.c (int_fits_type_p): Likewise. Adjust head comment. From-SVN: r241529
Diffstat (limited to 'gcc/tree.h')
-rw-r--r--gcc/tree.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/tree.h b/gcc/tree.h
index 9624a01..c494f23 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -5295,6 +5295,11 @@ 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. */
+ if (TREE_CODE (type) == BOOLEAN_TYPE)
+ return eq_p (x, 0) || eq_p (x, 1);
+
if (TYPE_SIGN (type) == UNSIGNED)
return eq_p (x, zext (x, TYPE_PRECISION (type)));
else