Bug 50622 - [4.7 Regression] ICE: verify_gimple failed for std::complex<double>
Summary: [4.7 Regression] ICE: verify_gimple failed for std::complex<double>
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.7.0
: P1 blocker
Target Milestone: 4.7.0
Assignee: Martin Jambor
URL:
Keywords: ice-on-valid-code
: 50623 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-05 15:47 UTC by vincenzo Innocente
Modified: 2011-12-06 17:16 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-10-05 00:00:00


Attachments
Untested fix (314 bytes, patch)
2011-11-30 19:40 UTC, Martin Jambor
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description vincenzo Innocente 2011-10-05 15:47:23 UTC
NOTE; ok with -std=gnu++0x
cat ice47.cc
#include <complex>

template <typename Value> struct LorentzVector
{
template <typename ValueB>
LorentzVector<Value> & operator+=(const LorentzVector<ValueB> & a) {
theX += a.theX;
theY += a.theY;
theZ += a.theZ;
theT += a.theT;
return *this;
}

Value theX;
Value theY;
Value theZ;
Value theT;
};

template <typename ValueA, typename ValueB>
inline LorentzVector<ValueA>
operator+(LorentzVector<ValueA> a, const LorentzVector<ValueB> & b) {
return a += b;
}

std::complex<double> evaluate() {
LorentzVector<std::complex<double> > v1;
LorentzVector<std::complex<double> > veca = v1 + v1;
return veca.theT;
}
Macintosh-203:ctest innocent$ c++ -O2 -c ice47.cc 
ice47.cc: In function ‘std::complex<double> evaluate()’:
ice47.cc:26:22: error: invalid rhs for gimple memory store
a$_M_value

v1$_M_value

# .MEM_14 = VDEF <.MEM_12>
a$_M_value = v1$_M_value;

ice47.cc:26:22: error: invalid rhs for gimple memory store
a$16$_M_value

v1$theY$_M_value

# .MEM_15 = VDEF <.MEM_14>
a$16$_M_value = v1$theY$_M_value;

ice47.cc:26:22: error: invalid rhs for gimple memory store
a$32$_M_value

v1$32$_M_value

# .MEM_16 = VDEF <.MEM_15>
a$32$_M_value = v1$32$_M_value;

ice47.cc:26:22: error: invalid rhs for gimple memory store
a$48$_M_value

v1$theT$_M_value

# .MEM_17 = VDEF <.MEM_16>
a$48$_M_value = v1$theT$_M_value;

ice47.cc:26:22: internal compiler error: verify_gimple failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Macintosh-203:ctest innocent$ c++ -O2 -c ice47.cc  -std=gnu++0x
Macintosh-203:ctest innocent$
Comment 1 Paolo Carlini 2011-10-05 15:55:03 UTC
*** Bug 50623 has been marked as a duplicate of this bug. ***
Comment 2 Paolo Carlini 2011-10-05 15:56:53 UTC
Confirmed.
Comment 3 Richard Biener 2011-10-06 08:33:11 UTC
Offending pass is late SRA.
Comment 4 vincenzo Innocente 2011-10-09 08:40:07 UTC
reduced to this (no std)

typedef __complex__ double Value;
struct LorentzVector
{
  LorentzVector & operator+=(const LorentzVector & a) {
    theX += a.theX;
    theY += a.theY;
    theZ += a.theZ;
    theT += a.theT;
    return *this;
  }
  
  Value theX;
  Value theY;
  Value theZ;
  Value theT;
};

inline LorentzVector
operator+(LorentzVector a, const LorentzVector & b) {
  return a += b;
}

Value ex, et;
LorentzVector sum() {
  LorentzVector v1; v1.theX =ex; v1.theY =ex+et; v1.theZ =ex-et;   v1.theT =et;
  return v1+v1;
}

c++ -O2 -c ice47c.cc
ice47c.cc: In function ‘LorentzVector sum()’:
ice47c.cc:24:15: error: invalid rhs for gimple memory store
a$theX

v1$theX

# .MEM_53 = VDEF <.MEM_13>
a$theX = v1$theX;

ice47c.cc:24:15: error: invalid rhs for gimple memory store
a$theY

v1$theY

# .MEM_54 = VDEF <.MEM_53>
a$theY = v1$theY;

ice47c.cc:24:15: error: invalid rhs for gimple memory store
a$theZ

v1$theZ

# .MEM_55 = VDEF <.MEM_54>
a$theZ = v1$theZ;

ice47c.cc:24:15: error: invalid rhs for gimple memory store
a$theT

v1$theT

# .MEM_56 = VDEF <.MEM_55>
a$theT = v1$theT;

ice47c.cc:24:15: internal compiler error: verify_gimple failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 5 Paolo Carlini 2011-10-09 12:42:38 UTC
Thanks Vincenzo. Doesn't happen for __complex__ float, doesn't happen for < 4 components, thus seems related to the size of the struct.
Comment 6 vincenzo Innocente 2011-11-29 09:42:31 UTC
This ICE is still present with revision 181800.
It does block our tests and validation of 4.7
Comment 7 Martin Jambor 2011-11-30 19:20:23 UTC
Mine.  At the first glance it seems that load_assign_lhs_subreplacements cannot create assignment statements with grp_partial_lhs replacements on both sides.
Comment 8 Martin Jambor 2011-11-30 19:40:27 UTC
Created attachment 25959 [details]
Untested fix

An untested fix.  I will run it through bootstrap tomorrow and proceed to submit it if it passes. Sorry for the delay, I'm a bit busy lately.
Comment 9 Martin Jambor 2011-12-01 16:20:02 UTC
Patch posted to mailing list:

http://gcc.gnu.org/ml/gcc-patches/2011-12/msg00080.html
Comment 10 Martin Jambor 2011-12-02 12:53:06 UTC
Author: jamborm
Date: Fri Dec  2 12:53:03 2011
New Revision: 181908

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181908
Log:
2011-12-02  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/50622
	* tree-sra.c (load_assign_lhs_subreplacements): Force gimple operand
	if both lacc and racc are grp_partial_lhs.

	* testsuite/g++.dg/tree-ssa/pr50622.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/tree-ssa/pr50622.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-sra.c
Comment 11 Richard Biener 2011-12-06 11:55:52 UTC
Fixed.
Comment 12 Martin Jambor 2011-12-06 17:16:28 UTC
Author: jamborm
Date: Tue Dec  6 17:16:19 2011
New Revision: 182057

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182057
Log:
2011-12-06  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/50622
	* tree-sra.c (load_assign_lhs_subreplacements): Force gimple operand
	if both lacc and racc are grp_partial_lhs.

	* testsuite/g++.dg/tree-ssa/pr50622.C: New test.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/tree-ssa/pr50622.C
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-sra.c