https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68326
Bug ID: 68326 Summary: ICE at -O3 on x86_64-linux-gnu in set_value_range, at tree-vrp.c:380 Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu Target Milestone: --- The following code causes an ICE when compiled with the current gcc trunk at -O3 on x86_64-linux-gnu in both 32-bit and 64-bit modes. It is a regression from 5.2.x. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 6.0.0 20151112 (experimental) [trunk revision 230270] (GCC) $ $ gcc-trunk -O2 -c small.c small.c: In function ‘fn2’: small.c:12:27: warning: iteration 2147483638 invokes undefined behavior [-Waggressive-loop-optimizations] for (e = -10; e; e--) ^ small.c:12:9: note: within this loop for (e = -10; e; e--) ^ $ gcc-5.2 -O3 -c small.c $ gcc-5.2 -O2 -c small.c small.c: In function ‘fn2’: small.c:12:27: warning: iteration 2147483638u invokes undefined behavior [-Waggressive-loop-optimizations] for (e = -10; e; e--) ^ small.c:12:9: note: containing loop for (e = -10; e; e--) ^ $ $ gcc-trunk -O3 -c small.c small.c: In function ‘fn2’: small.c:6:1: internal compiler error: in set_value_range, at tree-vrp.c:380 fn2 () ^ 0xd5af36 set_value_range ../../gcc-trunk/gcc/tree-vrp.c:379 0xd6e5a1 adjust_range_with_scev ../../gcc-trunk/gcc/tree-vrp.c:4334 0xd6e5a1 vrp_visit_phi_node ../../gcc-trunk/gcc/tree-vrp.c:8853 0xc8f415 simulate_stmt ../../gcc-trunk/gcc/tree-ssa-propagate.c:327 0xc8f723 process_ssa_edge_worklist ../../gcc-trunk/gcc/tree-ssa-propagate.c:456 0xc90f2e ssa_propagate(ssa_prop_result (*)(gimple*, edge_def**, tree_node**), ssa_prop_result (*)(gphi*)) ../../gcc-trunk/gcc/tree-ssa-propagate.c:937 0xd6862c execute_vrp ../../gcc-trunk/gcc/tree-vrp.c:10315 0xd6862c execute ../../gcc-trunk/gcc/tree-vrp.c:10395 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. $ ----------------------------------------- int c, d, e, f, g, h; short fn1 () { } void fn2 () { unsigned int i = 4294967286; if (g) for (;;) { for (e = -10; e; e--) for (h = 1; h; h = fn1 ()) { if (f) { d = fn1 (); if (d) continue; } i = e; } break; } if (0) ; c = i; }