Created attachment 27538 [details] reduced testcase Starting program: /dev/shm/portage/sys-devel/gcc-4.6.3/work/build/gcc/cc1 -O2 -fprefetch-loop-arrays /ice_416991.i wctomb mbstowcs luma_render /ice_416991.i: In function 'luma_render': /ice_416991.i:28:20: warning: incompatible implicit declaration of built-in function 'malloc' [enabled by default] Analyzing compilation unit Performing interprocedural optimizations <*free_lang_data> <visibility> <early_local_cleanups> <whole-program> <ipa-profile> <cp> <inline> <pure-const> <static-var>Assembling functions: wctomb mbstowcs luma_render Breakpoint 1, 0x00000000005ba3e4 in fancy_abort () (gdb) bt #0 0x00000000005ba3e4 in fancy_abort () #1 0x00000000009bf92b in build2_stat () #2 0x000000000064370e in build2_stat_loc () #3 0x000000000067967c in fold_build2_stat_loc () #4 0x000000000091022c in determine_exit_conditions () #5 0x0000000000910549 in tree_transform_and_unroll_loop () #6 0x000000000091107c in tree_unroll_loop () #7 0x0000000000ddfc64 in loop_prefetch_arrays () #8 0x0000000000ddffc5 in tree_ssa_prefetch_arrays () #9 0x000000000091a47d in tree_ssa_loop_prefetch () #10 0x0000000000759059 in execute_one_pass () #11 0x0000000000759233 in execute_pass_list () #12 0x0000000000759254 in execute_pass_list () #13 0x0000000000759254 in execute_pass_list () #14 0x000000000088eae1 in tree_rest_of_compilation () #15 0x0000000000a49d0b in cgraph_expand_function () #16 0x0000000000a49eca in cgraph_expand_all_functions () #17 0x0000000000a4a533 in cgraph_optimize () #18 0x0000000000a48b22 in cgraph_finalize_compilation_unit () #19 0x000000000049de30 in c_write_global_declarations () #20 0x000000000083006e in compile_file () #21 0x0000000000832000 in do_compile () #22 0x0000000000832146 in toplev_main () #23 0x0000000000521118 in main () Downstream bug: https://bugs.gentoo.org/show_bug.cgi?id=416991 I've checked that it also fails with gcc-4.4.6, however it works fine with gcc-4.5.3.
Confirmed.
Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161655 (aka MEM_REF). Guess the bug is that step's type is POINTER_TYPE, it should probably be some integer type instead.
I'd think --- tree-ssa-loop-niter.c.jj 2012-05-30 14:38:55.000000000 +0200 +++ tree-ssa-loop-niter.c 2012-06-01 14:27:43.202456745 +0200 @@ -1276,13 +1276,14 @@ number_of_iterations_cond (struct loop * practice, but it is simple enough to manage. */ if (!integer_zerop (iv0->step) && !integer_zerop (iv1->step)) { + tree step_type = POINTER_TYPE_P (type) ? sizetype : type; if (code != NE_EXPR) return false; - iv0->step = fold_binary_to_constant (MINUS_EXPR, type, + iv0->step = fold_binary_to_constant (MINUS_EXPR, step_type, iv0->step, iv1->step); iv0->no_overflow = false; - iv1->step = build_int_cst (type, 0); + iv1->step = build_int_cst (step_type, 0); iv1->no_overflow = true; } would match what tree-chrec.c is doing.
Created attachment 27540 [details] gcc48-pr53550.patch Full patch (untested).
Author: jakub Date: Mon Jun 4 09:23:27 2012 New Revision: 188169 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188169 Log: PR tree-optimization/53550 * tree-ssa-loop-niter.c (number_of_iterations_cond): If type is POINTER_TYPE_P, use sizetype as step type instead of type. * gcc.dg/pr53550.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr53550.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-loop-niter.c
Author: jakub Date: Mon Jun 4 09:27:00 2012 New Revision: 188170 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188170 Log: PR tree-optimization/53550 * tree-ssa-loop-niter.c (number_of_iterations_cond): If type is POINTER_TYPE_P, use sizetype as step type instead of type. * gcc.dg/pr53550.c: New test. Added: branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/pr53550.c Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/testsuite/ChangeLog branches/gcc-4_7-branch/gcc/tree-ssa-loop-niter.c
Fixed for 4.7+ so far.
The 4.6 branch has been closed, fixed in GCC 4.7.1.