re PR c/10178 (ICE in tree_low_cst)

PR c/10178
	* stmt.c (expand_end_case_type): Check for overflow in range when
	determining whether to use a bit-test implementation.

	* gcc.c-torture/compile/20030323-1.c: New test case.

From-SVN: r64757
This commit is contained in:
Roger Sayle 2003-03-23 21:25:13 +00:00 committed by Roger Sayle
parent ef3e988690
commit 766dec0ecd
4 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2003-03-23 Roger Sayle <roger@eyesopen.com>
PR c/10178
* stmt.c (expand_end_case_type): Check for overflow in range when
determining whether to use a bit-test implementation.
2003-03-23 Richard Henderson <rth@redhat.com>
* cfgcleanup.c (try_optimize_cfg): Allow merging of tablejumps

View File

@ -5505,6 +5505,7 @@ expand_end_case_type (orig_index, orig_type)
else if (CASE_USE_BIT_TESTS
&& ! TREE_CONSTANT (index_expr)
&& compare_tree_int (range, GET_MODE_BITSIZE (word_mode)) < 0
&& compare_tree_int (range, 0) > 0
&& lshift_cheap_p ()
&& ((uniq == 1 && count >= 3)
|| (uniq == 2 && count >= 5)

View File

@ -1,3 +1,7 @@
2003-03-23 Roger Sayle <roger@eyesopen.com>
* gcc.c-torture/compile/20030323-1.c: New test case.
2003-03-22 Ulrich Weigand <uweigand@de.ibm.com>
* gcc.dg/20030321-1.c: New test.

View File

@ -0,0 +1,17 @@
/* PR c/10178. The following code would ICE because we didn't check for
overflow when computing the range of the switch-statment, and therefore
decided it could be implemented using bit-tests. */
int
banana(long citron)
{
switch (citron) {
case 0x80000000:
case 0x40000:
case 0x40001:
return 1;
break;
}
return 0;
}