Menu

#461 Internal compiler error pentium4/sse2 and optimization

component_package
closed-fixed
gcc (462)
2004-07-27
2003-12-01
Bob Brand
No

Hello,

Platform: windows NT4 sp6a
> gcc --version
gcc.exe (GCC) 3.3.1 (mingw special 20030804-1)
> grep __MINGW32_VERSION \lang\mingw331
\include\_mingw.h
#define __MINGW32_VERSION 3.2

Compilation of sse2 instructions using -msse2,
-mcpu=pentium4 or -march=pentium4 together
with optimization -O, -O1 or higher generates an
internal compiler error.

Example code:

#include <xmmintrin.h>

void test(void)
{
short *p;
int *q;
__m128i v, u, w, _xf, _yf, _yf1;

for(;;)
{
int a = _mm_extract_epi16(v, 0);
w = _mm_insert_epi16(w, p[a+1], 7);

v = _mm_mulhi_epu16(_yf1, _xf);
u = _mm_madd_epi16(u, v);

v = _mm_mulhi_epu16(_yf, _xf);
w = _mm_madd_epi16(w, v);
u = _mm_add_epi32(u, w);

u = _mm_srai_epi32(u, 15);
*(__m128i *)(q) = _mm_add_epi32(*(__m128i *)
(q), u);
}
}

Compile with e.g.:
gcc -c -O2 -msse2 prob3.c
or (rename snippet to prob3.cpp):
g++ -c -O -march=pentium4 prob3.cpp

Compiler output:
prob3.c: In function `test':
prob3.c:24: internal compiler error: in push_reload, at
reload.c:1261
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.mingw.org/bugs.shtml> for
instructions.

The code snipped is very much reduced. Removing
any further lines or removal of the loop removes the
internal compiler error.

Manually substituting the _mm_... functions with the
__builtin_ia32_... functions as defined in xmmintrinsic.h
changes the internal compiler error from one in
push_reload to:
internal compiler error: in ix86_expand_binop_builtin,
at config/i386/i386.c:13113

Possibly a red herring: a slightly larger snipped did
compile when for(;;) was changed into while(1),
in the above snippet this does not matter.

I suspect that this is a generic GCC problem, but I do
not have access to other GCC systems here to test this.

Thanks for looking into this.

Regards,

Bob Brand

Discussion

  • Danny Smith

    Danny Smith - 2003-12-01

    Logged In: YES
    user_id=11494

    Thanks for providing a reproducible testcase.

    This appears to be the same bug as the one reported on GCC
    bugzilla at:

    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11627

    Perhaps you should add your testcase to the audit trail for
    that bug. Your testcase is smaller than the existing testcase
    for that bug.

    Danny

     
  • Bob Brand

    Bob Brand - 2003-12-02

    Logged In: YES
    user_id=921329

    Thanks for your attention.
    I have added this to GCC's bug 11627.

    Regards,

    Bob Brand.

     
  • Danny Smith

    Danny Smith - 2004-07-27
    • status: open --> closed-fixed
     
  • Danny Smith

    Danny Smith - 2004-07-27

    Logged In: YES
    user_id=11494

    Fixed in 3.4.1