Commit 3b08cde8 by Eric Botcazou Committed by Eric Botcazou

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
parent bf2df7a9
2016-11-24 Eric Botcazou <ebotcazou@adacore.com>
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.
2016-11-24 Martin Liska <mliska@suse.cz> 2016-11-24 Martin Liska <mliska@suse.cz>
* print-tree.c (struct bucket): Remove. * print-tree.c (struct bucket): Remove.
2016-11-24 Eric Botcazou <ebotcazou@adacore.com>
* gcc.c-torture/compile/20161124-1.c: New test.
2016-11-24 Jakub Jelinek <jakub@redhat.com> 2016-11-24 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/78493 PR bootstrap/78493
......
/* PR middle-end/78429 */
/* Testcase by Chengnian Sun <chengniansun@gmail.com> */
int a[6];
char b;
unsigned c;
short d;
volatile int e;
int foo (void)
{
int f;
for (; c <= 2; c++) {
d = 3;
for (; d >= 0; d--) {
int g = b;
f = a[d] || b;
}
f || e;
}
return 0;
}
...@@ -9144,10 +9144,10 @@ int_fits_type_p (const_tree c, const_tree type) ...@@ -9144,10 +9144,10 @@ int_fits_type_p (const_tree c, const_tree type)
bool ok_for_low_bound, ok_for_high_bound; bool ok_for_low_bound, ok_for_high_bound;
signop sgn_c = TYPE_SIGN (TREE_TYPE (c)); signop sgn_c = TYPE_SIGN (TREE_TYPE (c));
/* Short-circuit boolean types since various transformations assume that /* Non-standard boolean types can have arbitrary precision but various
they can only take values 0 and 1. */ transformations assume that they can only take values 0 and +/-1. */
if (TREE_CODE (type) == BOOLEAN_TYPE) if (TREE_CODE (type) == BOOLEAN_TYPE)
return integer_zerop (c) || integer_onep (c); return wi::fits_to_boolean_p (c, type);
retry: retry:
type_low_bound = TYPE_MIN_VALUE (type); type_low_bound = TYPE_MIN_VALUE (type);
......
...@@ -5296,6 +5296,9 @@ wi::extended_tree <N>::get_len () const ...@@ -5296,6 +5296,9 @@ wi::extended_tree <N>::get_len () const
namespace wi namespace wi
{ {
template <typename T> 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); bool fits_to_tree_p (const T &x, const_tree);
wide_int min_value (const_tree); wide_int min_value (const_tree);
...@@ -5305,14 +5308,21 @@ namespace wi ...@@ -5305,14 +5308,21 @@ namespace wi
template <typename T> template <typename T>
bool 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) wi::fits_to_tree_p (const T &x, const_tree type)
{ {
/* Short-circuit boolean types since various transformations assume that /* Non-standard boolean types can have arbitrary precision but various
they can only take values 0 and 1. */ transformations assume that they can only take values 0 and +/-1. */
if (TREE_CODE (type) == BOOLEAN_TYPE) 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))); return eq_p (x, zext (x, TYPE_PRECISION (type)));
else else
return eq_p (x, sext (x, TYPE_PRECISION (type))); return eq_p (x, sext (x, TYPE_PRECISION (type)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment