User account creation filtered due to spam.

Bug 16104 - [3.4 regression] ICE in reload_cse_simplify_operands, at postreload.c:378 with SSE2 code on -O2
Summary: [3.4 regression] ICE in reload_cse_simplify_operands, at postreload.c:378 wit...
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
Keywords: ice-on-valid-code, monitored, patch, ssemmx
: 18235 18238 (view as bug list)
Depends on:
Reported: 2004-06-20 18:53 UTC by Wei Dai
Modified: 2006-02-28 09:32 UTC (History)
4 users (show)

See Also:
Target: i*86-*-* sse2
Known to work:
Known to fail: 3.3.3 3.3.4 3.4.0 3.4.1 3.4.2 3.4.3 4.0.0
Last reconfirmed: 2006-01-06 15:26:18

test case (7.37 KB, text/plain)
2004-06-20 18:54 UTC, Wei Dai
un-preprocessed test case (882 bytes, text/plain)
2004-06-20 18:55 UTC, Wei Dai

Note You need to log in before you can comment on or make changes to this bug.
Description Wei Dai 2004-06-20 18:53:09 UTC
with this compiler:

$ gcc -v
Reading specs from /usr/local/lib/gcc/i686-pc-cygwin/3.4.0/specs
Configured with: ../gcc-3.4.0/configure
Thread model: single
gcc version 3.4.0

I'm getting ICE on some SSE2 code when using -O2. The same code compiles fine 
with optimizations turned off.

$ g++ -O2 -msse2 --save-temps gcctest.cpp
gcctest.cpp: In function `void P4Optimized_Multiply4(word*, const word*, const 
gcctest.cpp:119: error: insn does not satisfy its constraints:
(insn 1691 1690 1488 0 (set (reg/v:V2SI 21 xmm0 [orig:419 <anonymous> ] [419])
        (mem:V2SI (plus:SI (reg/f:SI 6 bp)
                (const_int -184 [0xffffff48])) [0 S8 A8])) 499 
{movv2si_internal} (nil)
gcctest.cpp:119: internal compiler error: in reload_cse_simplify_operands, at 

Will attach gcctest.ii.
Comment 1 Wei Dai 2004-06-20 18:54:15 UTC
Created attachment 6584 [details]
test case
Comment 2 Wei Dai 2004-06-20 18:55:14 UTC
Created attachment 6585 [details]
un-preprocessed test case
Comment 3 Andrew Pinski 2004-06-20 19:22:09 UTC
Reduced source:
typedef unsigned int word;
typedef int __m64 __attribute__ ((__mode__ (__V2SI__)));
typedef int __v2di __attribute__ ((mode (V2DI)));

void P4Optimized_Multiply41(word *C)
  __m64 s1;
  __v2di temp[7];
  word * temp819;

  temp819 = (word *)&temp[0];
  C[7] = (unsigned int)(int)(long long int)s1 + temp819[27];

Comment 4 Volker Reichelt 2004-06-25 09:30:27 UTC
Here's an even shorter testcase which crashes with the 3.4 branch
and mainline:

typedef int __m64 __attribute__ ((__mode__ (__V2SI__)));

int foo()
    return (long long)(__m64)(0ll);

PR16104B.c: In function `foo':
PR16104B.c:5: internal compiler error: in convert_move, at expr.c:585
Please submit a full bug report, [etc.]

Before 3.4 the code was rejected (errorneously IMHO):

PR16104B.c: In function `foo':
PR16104B.c:5: error: can't convert between vector values of different size
Comment 5 Steven Bosscher 2004-08-12 07:41:21 UTC
Mainline (3.5.0-to-be) claims the following: 
t.c:1: warning: specifying vector types with __attribute__ ((mode)) is 
t.c:1: warning: use __attribute__ ((vector_size)) instead 
Tweaking the test case accordingly makes the failure go away: 
typedef int __m64 __attribute__ ((vector_size (2))); 
int foo() 
    return (long long)(__m64)(0ll); 
t.c: In function `foo': 
t.c:5: error: can't convert between vector values of different size 
I don't know if the new error makes sense. 
Comment 6 Mark Mitchell 2004-08-29 18:12:06 UTC
Postponed until GCC 3.4.3.
Comment 7 Mark Mitchell 2004-08-29 18:14:45 UTC
Postponed until GCC 3.4.3.
Comment 8 Andrew Pinski 2004-10-21 12:53:33 UTC
Note the example which Steven gave is wrong, you want the vector size to 8 not 2 as 2 says only 2 
bytes not 8 bytes (64bits).
Also If we use vector_size rather than mode, we don't crash:
typedef int __m64 __attribute__ (( vector_size(8) ));
int foo()
    return (long long)(__m64)(0ll);
Comment 9 Serge Belyshev 2004-10-30 21:51:29 UTC
*** Bug 18235 has been marked as a duplicate of this bug. ***
Comment 10 Serge Belyshev 2004-10-30 22:16:07 UTC
this is small testcase for original bug (ICE in postreload.c),
it fails in 3.3 and 3.4 but not in 4.0.0, use -Os -msse2 to repeat:
void foo (int *j)
  int __attribute__ ((mode (V2SI))) k;
  long long t = (long long) k;
  j[0] = t;

Note I cannot repeat this bug on 4.0.0 neither with this nor with Volker's
testcases, so I cleared 4.0 regression flag.
Comment 11 Volker Reichelt 2004-11-05 21:12:21 UTC
Hmm. I still the the ICE with my example in comment #4.
Comment 12 Jakub Jelinek 2005-01-13 15:28:52 UTC
Patch here: <>
Comment 13 CVS Commits 2005-04-04 08:50:49 UTC
Subject: Bug 16104

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	2005-04-04 08:50:35

Modified files:
	gcc            : ChangeLog fold-const.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/execute: 20050316-1.c 

Log message:
	PR rtl-optimization/16104
	* fold-const.c (fold_unary): Fix folding of vector conversions.
	* gcc.c-torture/execute/20050316-1.c: New test.


Comment 15 Andrew Pinski 2005-04-30 16:20:56 UTC
*** Bug 18238 has been marked as a duplicate of this bug. ***
Comment 16 Gabriel Dos Reis 2006-02-28 09:32:50 UTC
Fixed in 4.0 and up.  Won't fix for 3.4.6.