GCC 4.8.0 with "-O1 -ftree-vrp" option ICEs on the following code where sizeof(int) == 4. The failure occurs in Linux (x86_64 and i686) and Mac OS X (x86_64). $ cat error.c int g = 0; int main(void) { if ( (g>>31) < -1 ) { g++; } return 0; } $ x86_64-unknown-linux-gnu-gcc-4.8.0 error.c -O1 -ftree-vrp error.c: In function 'main': error.c:3:5: internal compiler error: in remove_range_assertions, at tree-vrp.c:6276 int main(void) ^ 0x936e7e remove_range_assertions ../../gcc/tree-vrp.c:6276 0x936e7e execute_vrp ../../gcc/tree-vrp.c:9299 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions.
Started with http://gcc.gnu.org/r184927
Created attachment 29887 [details] gcc49-pr56984.patch Untested fix. Another thing is that fold resp. gimple_fold aren't able to optimize (x >> N) < M into 0 if M << N is the minimum value, but that isn't something VRP should handle.
Author: jakub Date: Thu Apr 18 07:54:58 2013 New Revision: 198051 URL: http://gcc.gnu.org/viewcvs?rev=198051&root=gcc&view=rev Log: PR tree-optimization/56984 * tree-vrp.c (register_edge_assert_for_2): For (x >> M) < N and (x >> M) >= N don't register any assertion if N << M is the minimum value. * gcc.c-torture/compile/pr56984.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr56984.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-vrp.c Author: jakub Date: Thu Apr 18 07:56:03 2013 New Revision: 198052 URL: http://gcc.gnu.org/viewcvs?rev=198052&root=gcc&view=rev Log: PR tree-optimization/56984 * tree-vrp.c (register_edge_assert_for_2): For (x >> M) < N and (x >> M) >= N don't register any assertion if N << M is the minimum value. * gcc.c-torture/compile/pr56984.c: New test. Added: branches/gcc-4_8-branch/gcc/testsuite/gcc.c-torture/compile/pr56984.c Modified: branches/gcc-4_8-branch/gcc/ChangeLog branches/gcc-4_8-branch/gcc/testsuite/ChangeLog branches/gcc-4_8-branch/gcc/tree-vrp.c