From: Andrew Pinski Date: Tue, 30 Dec 2008 16:27:29 +0000 (-0800) Subject: re PR tree-optimization/38661 (ICE: vector VEC(constructor_elt,base) push domain... X-Git-Tag: releases/gcc-4.4.0~1097 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7f2a9982659c7963ff213722e1feabbd7563118e;p=thirdparty%2Fgcc.git re PR tree-optimization/38661 (ICE: vector VEC(constructor_elt,base) push domain error, in build_constructors at tree-switch-conversion.c:450) 2008-12-30 Andrew Pinski PR middle-end/38661 * tree-switch-conversion.c (build_constructors): Test for wrapping of pos case. 2008-12-30 Andrew Pinski PR middle-end/38661 * gcc.c-torture/compile/pr38661.c: New testcase. * gcc.c-torture/compile/pr38661-1.c: New testcase. From-SVN: r142964 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 87d22b44efaa..89d19b09a17c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-12-30 Andrew Pinski + + PR middle-end/38661 + * tree-switch-conversion.c (build_constructors): Test for wrapping of + pos case. + 2008-12-30 Steven Bosscher PR middle-end/38584 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7c6dc8d5a1f3..81e86b30a1cb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-12-30 Andrew Pinski + + PR middle-end/38661 + * gcc.c-torture/compile/pr38661.c: New testcase. + * gcc.c-torture/compile/pr38661-1.c: New testcase. + 2008-12-30 Richard Guenther PR middle-end/38564 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr38661-1.c b/gcc/testsuite/gcc.c-torture/compile/pr38661-1.c new file mode 100644 index 000000000000..065f12010a73 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr38661-1.c @@ -0,0 +1,9 @@ +/* We used to ICE because we would wrap INT_MAX + into INT_MIN while doing the switch converison. */ + +const char *func(int val) { + switch (val) { + case - __INT_MAX__ -1 : return "foo"; + default: return ""; + } +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr38661.c b/gcc/testsuite/gcc.c-torture/compile/pr38661.c new file mode 100644 index 000000000000..5d243c6be51d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr38661.c @@ -0,0 +1,9 @@ +/* We used to ICE because we would wrap INT_MAX + into INT_MIN while doing the switch converison. */ + +const char *func(int val) { + switch (val) { + case __INT_MAX__: return "foo"; + default: return ""; + } +} diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index 798cf1615694..dba0c6f3de35 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -440,9 +440,10 @@ build_constructors (gimple swtch) { gimple phi = gsi_stmt (gsi); tree val = PHI_ARG_DEF_FROM_EDGE (phi, e); + tree low = CASE_LOW (cs); pos = CASE_LOW (cs); - while (!tree_int_cst_lt (high, pos)) + do { constructor_elt *elt; @@ -452,7 +453,7 @@ build_constructors (gimple swtch) elt->value = val; pos = int_const_binop (PLUS_EXPR, pos, integer_one_node, 0); - } + } while (!tree_int_cst_lt (high, pos) && tree_int_cst_lt (low, pos)); j++; } }