Bug 22228 - [4.1 regression] ICE with -ftree-vectorize in verify_ssa
Summary: [4.1 regression] ICE with -ftree-vectorize in verify_ssa
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, monitored
: 22543 23352 (view as bug list)
Depends on:
Blocks: 21859 23352
  Show dependency treegraph
 
Reported: 2005-06-28 23:21 UTC by Wolfgang Bangerth
Modified: 2005-08-19 14:47 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-08-06 06:58:46


Attachments
Preprocessed source (152.14 KB, application/x-gzip)
2005-06-28 23:22 UTC, Wolfgang Bangerth
Details
New testcase (702 bytes, text/x-c++src)
2005-06-29 03:41 UTC, Wolfgang Bangerth
Details
Shorter testcase (368 bytes, text/plain)
2005-06-29 13:33 UTC, Volker Reichelt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bangerth 2005-06-28 23:21:26 UTC
Attached code fails like so: 
 
spec/src> /home/bangerth/bin/gcc-4.1-pre/bin/c++ -O3 -march=pentium4 
-ftree-vectorize -c mapping_cartesian.ii 
mapping_cartesian.cc: In constructor 
&#8216;MappingCartesian<dim>::InternalData::InternalData(const Quadrature<dim>&) 
[with int dim = 3]&#8217;: 
mapping_cartesian.cc:36: error: Definition in block 1 does not dominate use in 
block 6 
for SSA_NAME: TMT.2405_3(ab) in statement: 
TMT.2405_317 = PHI <TMT.2405_3(ab)(6), TMT.2405_3(ab)(5)>; 
PHI argument 
TMT.2405_3(ab) 
for PHI node 
TMT.2405_317 = PHI <TMT.2405_3(ab)(6), TMT.2405_3(ab)(5)>; 
mapping_cartesian.cc:36: internal compiler error: verify_ssa failed. 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
W.
Comment 1 Wolfgang Bangerth 2005-06-28 23:22:49 UTC
Created attachment 9168 [details]
Preprocessed source
Comment 2 Andrew Pinski 2005-06-28 23:24:29 UTC
Most likely the same bug which is causing a bootstrap regression:
http://gcc.gnu.org/ml/gcc-regression/2005-06/msg00090.html

And Also PR 22037
Comment 3 Wolfgang Bangerth 2005-06-28 23:31:40 UTC
I don't think its the same as PR 22037 -- they have different error messages! 
W. 
Comment 4 Andrew Pinski 2005-06-28 23:41:01 UTC
(In reply to comment #3)
> I don't think its the same as PR 22037 -- they have different error messages! 

Actually you are right, this is vectorizer bug and the other one is a differnt one.
Comment 5 Wolfgang Bangerth 2005-06-29 03:41:44 UTC
Created attachment 9169 [details]
New testcase

New testcase, much smaller: 100 lines + #include<vector>
Comment 6 Volker Reichelt 2005-06-29 13:33:10 UTC
Created attachment 9171 [details]
Shorter testcase

Shorter testcase (below 50 lines).

Crashes with "g++ -march=pentium4 -ftree-vectorize -O2"
Comment 7 Volker Reichelt 2005-06-29 13:34:04 UTC
Confirmed.
Comment 8 Wolfgang Bangerth 2005-06-29 17:58:38 UTC
May be the same as PR 22234... 
 
Comment 9 Volker Reichelt 2005-06-30 11:17:51 UTC
Not fixed by the patch for PR22234 :-(
Comment 10 Andrew Pinski 2005-08-06 06:59:29 UTC
*** Bug 22543 has been marked as a duplicate of this bug. ***
Comment 11 Dorit Naishlos 2005-08-09 15:38:59 UTC
I was able to reproduce the error on powerpc-drawin using the first testcase 
from comment 3 for PR22543.

I was also able to pin down the patch that triggered/exposed this problem:

2005-07-09  Diego Novillo  <dnovillo@redhat.com>

        * Makefile.in (tree-ssa-alias.o): Depend on tree-ssa-structalias.h
        * tree-cfg.c (CHECK_OP): Only test for is_gimple_val.
        * tree-dfa.c (dump_subvars_for): New.
        (debug_subvars_for): New.
        (dump_variable): Show subvariables if VAR has them.
	  ........

Here is what I think is going on:
The updating of phi-nodes during loop-peeling (in the vectorizer) does not 
create all the required phis for the variable SFT.3. This happens because the 
vectorizer can only update the ssa-form for variables that are in proper loop-
closed-ssa-form. SFT.3 is not in loop-closed-form, and in fact virtual 
variables in general are no longer guaranteed to be in loop-closed-form (or 
maybe never have been?). More specifically, the function 
slpeel_update_phi_nodes_for_guard2 was supposed to create the missing phis, but 
it only works for variables that have a loop-closed phi at the loop exit. 

The reason we don't fail in the presence of virtual-phis all the time, is, I 
think, that usually the virtual variables that need to be updated (due to 
peeling) are also used or defined inside the loop (in a load or store 
operation), and are therefore marked by the vectorizer for renaming when that 
load/store is handled (and update_ssa is consequently called). This was also 
what used to happen in this testcase, until the patch by Diego was committed - 
SFT.3 was used in the loop, and was therefore marked for renaming. This is how 
the loop looked like before the patch:

  # ivtmp.20D.2696_34 = PHI <ivtmp.20D.2696_2(2), 4(0)>;
  # SFT.4D.2672_41 = PHI <SFT.4D.2672_33(2), SFT.4D.2672_22(0)>;
  # SFT.3D.2671_39 = PHI <SFT.3D.2671_32(2), SFT.3D.2671_23(0)>;
  # iD.2620_37 = PHI <iD.2620_17(2), 0(0)>;
<L0>:;
  #   SFT.3D.2671_32 = V_MAY_DEF <SFT.3D.2671_39>;
  #   SFT.4D.2672_33 = V_MAY_DEF <SFT.4D.2672_41>;
  thisD.2584_16->zD.2580[iD.2620_37] = 0;
  iD.2620_17 = iD.2620_37 + 1;
  ivtmp.20D.2696_2 = ivtmp.20D.2696_34 - 1;
  if (ivtmp.20D.2696_2 != 0) goto <L14>; else goto <L15>;

And this is how the loop looks like now, after the patch: 

  # ivtmp.37D.2713_4 = PHI <ivtmp.37D.2713_1(2), 4(0)>;
  # TMT.10D.2678_10 = PHI <TMT.10D.2678_11(2), TMT.10D.2678_9(0)>;
  # SFT.4D.2672_41 = PHI <SFT.4D.2672_41(2), SFT.4D.2672_22(0)>;
  # SFT.3D.2671_39 = PHI <SFT.3D.2671_39(2), SFT.3D.2671_23(0)>;
  # iD.2620_37 = PHI <iD.2620_17(2), 0(0)>;
<L0>:;
  #   TMT.10D.2678_11 = V_MAY_DEF <TMT.10D.2678_10>;
  thisD.2584_16->zD.2580[iD.2620_37] = 0;
  iD.2620_17 = iD.2620_37 + 1;
  ivtmp.37D.2713_1 = ivtmp.37D.2713_4 - 1;
  if (ivtmp.37D.2713_1 != 0) goto <L14>; else goto <L15>;

SFT.3 no longer gets used inside the loop, so it doesn't get marked for 
renaming, and the proper phis do not get created.

I tried to mark for renaming virtual variables that have phis in the loop, like 
this SFT.3, as follows:

Index: tree-vectorizer.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-vectorizer.c,v
retrieving revision 2.107
diff -c -3 -p -r2.107 tree-vectorizer.c
*** tree-vectorizer.c   28 Jul 2005 16:29:57 -0000      2.107
--- tree-vectorizer.c   9 Aug 2005 12:20:00 -0000
*************** slpeel_update_phi_nodes_for_guard1 (edge
*** 522,527 ****
--- 522,532 ----
         orig_phi && update_phi;
         orig_phi = PHI_CHAIN (orig_phi), update_phi = PHI_CHAIN (update_phi))
      {
+       /* Virtual phi; Mark it for renaming.  */
+       /* CHECKME: skip? */
+       if (!is_gimple_reg (SSA_NAME_VAR (PHI_RESULT (orig_phi))))
+         mark_sym_for_renaming (SSA_NAME_VAR (PHI_RESULT (orig_phi)));
+
        /** 1. Handle new-merge-point phis  **/

        /* 1.1. Generate new phi node in NEW_MERGE_BB:  */


This patch didn't help although SFT.3 was marked for renaming. Diego, any 
ideas??

The other thing we could try to do is put virtual variables in loop-closed-
form, at least just before the vectorizer, and at least just for some loops. 
(By the way, why don't we keep virtual variables in loop-closed-form?)
Comment 12 Wolfgang Bangerth 2005-08-09 17:01:26 UTC
(In reply to comment #11) 
> I was also able to pin down the patch that triggered/exposed this problem: 
>  
> 2005-07-09  Diego Novillo  <dnovillo@redhat.com> 
 
I'm not sure what relationship this patch has wrt this PR -- I filed the PR 
on 2005-06-28, so before Diego's patch. It may well have exposed a separate 
problem, though. 
 
W. 
Comment 13 Dorit Naishlos 2005-08-09 17:14:25 UTC
> I'm not sure what relationship this patch has wrt this PR -- I filed the PR 
> on 2005-06-28, so before Diego's patch. It may well have exposed a separate 
> problem, though. 
>

I tried a snaphost from 20050710, just before Diego's patch, and it passed 
successfully. The next snapshot I tried, from the next day, with Diesgo's patch 
and a few other bits, produced this error:

error: definition in block 1 does not dominate use in block 3
for SSA_NAME: SFT.3_39 in statement:
#   VUSE <SFT.3_39>;
lsm_tmp.35_36 = D.2625.j;
pr22543.cc:26: internal compiler error: verify_ssa failed

Maybe there are multiple unrelated problems grouped under this one PR. Or maybe 
PR22543 is not a duplicate of this one. This error one is the only one I can 
currently reproduce. 
Comment 14 Wolfgang Bangerth 2005-08-09 17:19:56 UTC
Subject: Re:  [4.1 regression] ICE with
 -ftree-vectorize in verify_ssa


> Maybe there are multiple unrelated problems grouped under this one PR. Or maybe
> PR22543 is not a duplicate of this one. This error one is the only one I can
> currently reproduce.

It certainly can't hurt if you fix whatever you find is wrong at present. 
If this works and a second problem is uncovered, we can always look at 
that at a later time. Please go ahead with what you did, irrespective of 
this question.

Thanks
  Wolfgang

-------------------------------------------------------------------------
Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                                www: http://www.ices.utexas.edu/~bangerth/

Comment 15 Andrew Pinski 2005-08-12 17:36:00 UTC
*** Bug 23352 has been marked as a duplicate of this bug. ***
Comment 16 Dorit Naishlos 2005-08-14 14:00:23 UTC
patch: http://gcc.gnu.org/ml/gcc-patches/2005-08/msg00826.html
Comment 17 Michael Cieslinski 2005-08-16 08:10:01 UTC
I tried the patch with the actual snapshot (20050813) and it fails to bootstrap.
Without this patch bootstrap works.

Michael Cieslinski


export   CFLAGS="-O3 -g -pipe -march=opteron -fmessage-length=0 -ffast-math -
funroll-all-loops -funit-at-a-time -fpeel-loops -funswitch-loops --param max-
gcse-passes=9 -fverbose-asm -msse2"
export CXXFLAGS=$CFLAGS
../gcc-4.1-20050813/configure --prefix=/usr/local/gcc41k --program-suffix=41k --
with-arch=opteron --enable-languages=c,c++ --enable-checking
make -j12 bootstrap

<....>

Bootstrapping the compiler
make[1]: Entering directory `/home/cie019/gcc41k/obj/gcc'
make CC=" stage1/xgcc -Bstage1/ -B/usr/local/gcc41k/x86_64-unknown-linux-
gnu/bin/" CC_FOR_BUILD=" stage1/xgcc -Bstage1/ -B/usr/local/gcc41k/x86_64-
unknown-linux-gnu/bin/" \
         STAGE_PREFIX=stage1/ \
         ADAFLAGS="" CFLAGS="-g -O2" LDFLAGS="" 
WARN_CFLAGS="\$(GCC_WARN_CFLAGS)" STRICT_WARN="-pedantic -Wno-long-long -Wno-
variadic-macros -Wold-style-definition -Wmissing-format-attribute -Werror" 
libdir=/usr/local/gcc41k/lib LANGUAGES="c gcov gcov-dump c++" 
MAKEINFO="makeinfo --split-size=5000000" MAKEINFOFLAGS="--no-split" 
MAKEOVERRIDES= OUTPUT_OPTION="-o \$@" \
         CFLAGS="-g -O2" WERROR="-Werror"
make[2]: Entering directory `/home/cie019/gcc41k/obj/gcc'
stage1/xgcc -Bstage1/ -B/usr/local/gcc41k/x86_64-unknown-linux-gnu/bin/ -c   -
g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-
prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-
definition -Wmissing-format-attribute -Werror -fno-common   -DHAVE_CONFIG_H    -
I. -I. -I../../gcc-4.1-20050813/gcc -I../../gcc-4.1-20050813/gcc/. -I../../gcc-
4.1-20050813/gcc/../include -I../../gcc-4.1-
20050813/gcc/../libcpp/include  ../../gcc-4.1-20050813/gcc/tree-vect-
transform.c -o tree-vect-transform.o
cc1: warnings being treated as errors
../../gcc-4.1-20050813/gcc/tree-vect-transform.c: In 
function 'vect_transform_loop':
../../gcc-4.1-20050813/gcc/tree-vect-transform.c:2832: warning: pointer targets 
in passing argument 4 of 'bmp_iter_set_init' differ in signedness
../../gcc-4.1-20050813/gcc/tree-vect-transform.c:2832: warning: pointer targets 
in passing argument 2 of 'bmp_iter_set' differ in signedness
../../gcc-4.1-20050813/gcc/tree-vect-transform.c:2832: warning: pointer targets 
in passing argument 2 of 'bmp_iter_next' differ in signedness
make[2]: *** [tree-vect-transform.o] Error 1
make[2]: Leaving directory `/home/cie019/gcc41k/obj/gcc'
make[1]: *** [stage2_build] Error 2
make[1]: Leaving directory `/home/cie019/gcc41k/obj/gcc'
make: *** [bootstrap] Error 2
Comment 18 Dorit Naishlos 2005-08-16 08:48:36 UTC
oops, I sent the worng patch (I also got this bootstrap error, and fixed it, 
but sent the older patch by mistake) - will resend
Comment 19 Dorit Naishlos 2005-08-16 16:41:32 UTC
patch: http://gcc.gnu.org/ml/gcc-patches/2005-08/msg00979.html
Comment 20 Michael Cieslinski 2005-08-17 07:24:44 UTC
The new patch bootstraps on x86_64 but it does not fix the ICEs from pr23352
Comment 21 GCC Commits 2005-08-18 16:08:37 UTC
Subject: Bug 22228

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dorit@gcc.gnu.org	2005-08-18 16:07:55

Modified files:
	gcc            : ChangeLog tree-ssa-loop.c tree-vect-transform.c 
	                 tree-vectorizer.c tree-vectorizer.h 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/vect: pr22543.cc 

Log message:
	PR tree-optimization/22228
	* tree-ssa-loop (pass_vectorize): Add TODO_verify_loops to todo_flags_start.
	* tree-vect-transform.c (vect_transform_loop): Mark the variables that
	are recorded in vect_vnames_to_rename for renaming.
	* tree-vectorizer.c (vect_vnames_to_rename): New global bitmap.
	(slpeel_update_phi_nodes_for_guard1): Record virtual vars for renaming
	in vect_vnames_to_rename.
	(vectorize_loops): Allocate and free the vect_vnames_to_rename bitmap.
	* tree-vectorizer.h (vect_vnames_to_rename): New extern variable.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9772&r2=2.9773
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-loop.c.diff?cvsroot=gcc&r1=2.33&r2=2.34
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-vect-transform.c.diff?cvsroot=gcc&r1=2.40&r2=2.41
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-vectorizer.c.diff?cvsroot=gcc&r1=2.107&r2=2.108
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-vectorizer.h.diff?cvsroot=gcc&r1=2.27&r2=2.28
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5935&r2=1.5936
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/vect/pr22543.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 22 Volker Reichelt 2005-08-19 14:47:43 UTC
Fixed on mainline.
Btw, this fixes also the ICE from PR 23352 for me.