With the following code gcc-4.1 and 4.2 ICE when using "-O3 -ftree-vectorize". The latest checkout I have of 4.0 worked just fine. struct re_pattern_buffer { char *buffer; char *fastmap; long options; }; void ruby_re_compile_fastmap (struct re_pattern_buffer *bufp) { unsigned char *pattern = (unsigned char *) bufp->buffer; register char *fastmap = bufp->fastmap; register unsigned char *p = pattern; register int j; int options = bufp->options; while (p) { switch (*p++) { case 0: for (j = 0; j < (1 << 8); j++) { if (j != '\n' || (options & (((1L) << 1) << 1))) fastmap[j] = 1; } } } } gcc version 4.2.0 20060331 (experimental) gcc -O3 -ftree-vectorize ruby.c -c ruby.x.i: In function ‘ruby_re_compile_fastmap’: ruby.x.i:9: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions
Confirmed, reduced testcase: void ruby_re_compile_fastmap (char *fastmap, int options) { int j; for (j = 0; j < (1 << 8); j++) { if (j != '\n' || (options & 4)) fastmap[j] = 1; } } ----- you can get the error with -O1 -funswitch-loops -ftree-vectorize
We ICE in rename_use_op on if (TREE_CODE (USE_FROM_PTR (op_p)) != SSA_NAME) return; because *op_p->use is NULL and the stmt is broken: (gdb) call debug_generic_expr(op_p->stmt) SMT.6D.1867_40 = PHI <(13)>; #0 0x081ed569 in rename_use_op (op_p=0xb7de40a0) at /space/rguenther/src/svn/trunk/gcc/tree-vectorizer.c:201 #1 0x081ed840 in rename_variables_in_bb (bb=0xb7d35a50) at /space/rguenther/src/svn/trunk/gcc/tree-vectorizer.c:243 #2 0x081ee0d4 in rename_variables_in_loop (loop=0x896e8f0) at /space/rguenther/src/svn/trunk/gcc/tree-vectorizer.c:259 #3 0x081eff18 in slpeel_tree_peel_loop_to_edge (loop=0x8961658, loops=0x8948690, e=0xb7dd6820, first_niters=0xb7de3138, niters=0xb7dded68, update_first_loop_count=1 '\001') at /space/rguenther/src/svn/trunk/gcc/tree-vectorizer.c:1135 #4 0x08203066 in vect_do_peeling_for_alignment (loop_vinfo=0x895ff18, loops=0x8948690) at /space/rguenther/src/svn/trunk/gcc/tree-vect-transform.c:2813 #5 0x08203978 in vect_transform_loop (loop_vinfo=0x895ff18, loops=0x8948690) at /space/rguenther/src/svn/trunk/gcc/tree-vect-transform.c:3045 #6 0x081f29e5 in vectorize_loops (loops=0x8948690) at /space/rguenther/src/svn/trunk/gcc/tree-vectorizer.c:2046 #7 0x081dbdf1 in tree_vectorize ()
slpeel_update_phis_for_duplicate_loop does not do its job properly. It fails to update the PHI nodes of at least the new loops latch block: (gdb) call debug_bb (new_loop->latch) ;; basic block 14, loop depth 1, count 0 ;; prev block 13, next block 4 ;; pred: 13 [98.8%] (dfs_back,true,exec) ;; succ: 13 [100.0%] (fallthru,exec) # SMT.6_40 = PHI <(13)>; # j_41 = PHI <(13)>; <L23>:; goto <bb 13> (<L24>);
Will not be fixed in 4.1.1; adjust target milestone to 4.1.2.
This happens because (vect_do_peeling_for_alignment) was designed in an assumption that latch is empty. Thus it doesn't handle PHIs in latches. (vect_analyze_loop_form) checks the latch is empty, but doesn't check that list of its PHIs is empty as too.
patch: http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00376.html
Subject: Bug number PR tree-optimizations/26969 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00376.html
Subject: Bug number PR tree-optimizations/26969 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-08/msg00006.html
Subject: Bug 26969 Author: victork Date: Mon Aug 7 11:28:31 2006 New Revision: 115995 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115995 Log: ChangeLog PR tree-optimization/26969 * tree-vect-analyze.c (vect_analyze_loop_form): Add check of latch witch an empty list of PHIs. testsuite/Changelog: PR tree-optimizations/26969 * gcc.dg/vect/vect.exp: Compile tests prefixed with "unswitch-loops" with -funswitch-loops. * gcc.dg/vect/unswitch-loops-pr26969.c: New test. Added: trunk/gcc/testsuite/gcc.dg/vect/unswitch-loops-pr26969.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/vect/vect.exp trunk/gcc/tree-vect-analyze.c
I think this can be closed? (I opened a missed-optimization PR instead - PR28643)
(In reply to comment #10) > I think this can be closed? Except we still crash on the 4.1 branch.
oops - I didn't notice it was open against 4.1. So hopefully porting Victor's patch to 4.1 would fix it.
this bug looks very similar to PR28839 which already have a fix in patch http://gcc.gnu.org/ml/gcc-patches/2006-08/msg01171.html We need to check if above patch fixes PR26969 as well.
I will look if patch http://gcc.gnu.org/ml/gcc-patches/2006-08/msg01171.html fixes this one too and will remap it to 4.1
(In reply to comment #13) > We need to check if above patch fixes PR26969 as well. Checked, it does not.
Subject: Bug 26969 Author: irar Date: Thu Oct 19 11:18:25 2006 New Revision: 117883 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117883 Log: Backport from mainline: 2006-08-07 Victor Kaplansky <victork@il.ibm.com> PR tree-optimization/26969 * tree-vect-analyze.c (vect_analyze_loop_form): Add check of latch with an empty list of PHIs. Added: branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/vect/unswitch-loops-pr26969.c Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/testsuite/ChangeLog branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/vect/vect.exp branches/gcc-4_1-branch/gcc/tree-vect-analyze.c
Fixed.