User account creation filtered due to spam.

Bug 35294 - iwmmxt intrinsics, internal compiler error
Summary: iwmmxt intrinsics, internal compiler error
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 36798 36966 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-02-22 14:17 UTC by Håvard Wall
Modified: 2013-02-22 12:40 UTC (History)
11 users (show)

See Also:
Host: x86_64-linux-gnu
Target: arm-linux-gnueabi
Build: x86_64-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2009-09-17 17:04:07


Attachments
gcc 35294 possible Fix (1001 bytes, patch)
2010-12-17 16:16 UTC, serowk
Details | Diff
gcc 4.4.5 possible fix (1001 bytes, patch)
2010-12-17 16:17 UTC, serowk
Details | Diff
[PATCH] Wire-up missing ARM iwmmxt intrinsics (743 bytes, patch)
2011-10-01 15:26 UTC, Matt Turner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Håvard Wall 2008-02-22 14:17:56 UTC
Compiling this simple function:

#include <mmintrin.h>
void foo()
{
    _mm_srli_pi16(_mm_setzero_si64(), 8);
}

with the command line arm-angstrom-linux-gnueabi-gcc -c -O2 iwmmxt.cpp, results in:

/home/qt/gumstix/gumstix-oe/tmp/work/armv5te-angstrom-linux-gnueabi/gcc-cross-4.1.2-r10/image/home/qt/gumstix/gumstix-oe/tmp/cross/bin/../lib/gcc/arm-angstrom-linux-gnueabi/4.1.2/include/mmintrin.h: In function 'void foo()':
/home/qt/gumstix/gumstix-oe/tmp/work/armv5te-angstrom-linux-gnueabi/gcc-cross-4.1.2-r10/image/home/qt/gumstix/gumstix-oe/tmp/cross/bin/../lib/gcc/arm-angstrom-linux-gnueabi/4.1.2/include/mmintrin.h:529: internal compiler error: in arm_expand_binop_builtin, at config/arm/arm.c:12551
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
/home/qt/gumstix/gumstix-oe/tmp/work/armv5te-angstrom-linux-gnueabi/gcc-cross-4.1.2-r10/image/home/qt/gumstix/gumstix-oe/tmp/cross/bin/../lib/gcc/arm-angstrom-linux-gnueabi/4.1.2/include/mmintrin.h: In function 'foo':
/home/qt/gumstix/gumstix-oe/tmp/work/armv5te-angstrom-linux-gnueabi/gcc-cross-4.1.2-r10/image/home/qt/gumstix/gumstix-oe/tmp/cross/bin/../lib/gcc/arm-angstrom-linux-gnueabi/4.1.2/include/mmintrin.h:529: internal compiler error: in arm_expand_binop_builtin, at config/arm/arm.c:12551
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

$ arm-angstrom-linux-gnueabi-gcc -v
Using built-in specs.
Target: arm-angstrom-linux-gnueabi
Configured with: /home/qt/gumstix/gumstix-oe/tmp/work/armv5te-angstrom-linux-gnueabi/gcc-cross-4.1.2-r10/gcc-4.1.2/configure --build=x86_64-linux --host=x86_64-linux --target=arm-angstrom-linux-gnueabi --prefix=/home/qt/gumstix/gumstix-oe/tmp/cross --exec_prefix=/home/qt/gumstix/gumstix-oe/tmp/cross --bindir=/home/qt/gumstix/gumstix-oe/tmp/cross/bin --sbindir=/home/qt/gumstix/gumstix-oe/tmp/cross/bin --libexecdir=/home/qt/gumstix/gumstix-oe/tmp/cross/libexec --datadir=/home/qt/gumstix/gumstix-oe/tmp/cross/share --sysconfdir=/home/qt/gumstix/gumstix-oe/tmp/cross/etc --sharedstatedir=/home/qt/gumstix/gumstix-oe/tmp/cross/com --localstatedir=/home/qt/gumstix/gumstix-oe/tmp/cross/var --libdir=/home/qt/gumstix/gumstix-oe/tmp/cross/lib --includedir=/home/qt/gumstix/gumstix-oe/tmp/cross/include --oldincludedir=/home/qt/gumstix/gumstix-oe/tmp/cross/include --infodir=/home/qt/gumstix/gumstix-oe/tmp/cross/share/info --mandir=/home/qt/gumstix/gumstix-oe/tmp/cross/share/man --with-gnu-ld --enable-shared --enable-target-optspace --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-angstrom-linux-gnueabi- --with-local-prefix=/home/qt/gumstix/gumstix-oe/tmp/staging/arm-angstrom-linux-gnueabi --with-gxx-include-dir=/home/qt/gumstix/gumstix-oe/tmp/staging/arm-angstrom-linux-gnueabi/include/c++ --enable-__cxa_atexit --with-float=soft --disable-libssp --disable-libunwind-exceptions --with-mpfr=/home/qt/gumstix/gumstix-oe/tmp/staging/x86_64-linux
Thread model: posix
gcc version 4.1.2
Comment 1 Laurent GUERBY 2009-01-02 12:06:08 UTC
Fixed on 4.3.2-1 Debian gnueabi and on trunk at rev 142808 (tested native)
Comment 2 Sergey Gusarov 2009-02-19 13:44:14 UTC
Testing sample with gcc-4.3.3 (released after 2009-01-02 12:06) also fail:

sergeyhost:/tmp$ cat ./main.c 
#include <mmintrin.h>
void foo()
{
    _mm_srli_pi16(_mm_setzero_si64(), 8);
}
sergeyhost:/tmp$

sergeyhost:/tmp$ arm-iwmmx-linux-gnueabi-gcc -flax-vector-conversions -c -O2 ./main.c
/opt/toolchain/arm-iwmmx-linux-gnueabi/gcc-4.3.3-glibc-2.8-binutils-2.18-kernel-2.6.22-sanitized/lib/gcc/arm-iwmmx-linux-gnueabi/4.3.3/include/mmintrin.h: In function 'foo':
/opt/toolchain/arm-iwmmx-linux-gnueabi/gcc-4.3.3-glibc-2.8-binutils-2.18-kernel-2.6.22-sanitized/lib/gcc/arm-iwmmx-linux-gnueabi/4.3.3/include/mmintrin.h:529: internal compiler error: in arm_expand_binop_builtin, at config/arm/arm.c:15380
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
sergeyhost:/tmp$ 

I am use OSELAS.Toolchan-1.99.3 arm-iwmmx-linux-gnueabi_gcc-4.3.2_glibc-2.8_binutils-2.18_kernel-2.6.27-sanitized with small changes for me (update compiler because in contains "regression fixes and docs only" and downgrade kernel headers). I think this changes unimportant for bug.
Comment 3 Sergey Gusarov 2009-02-24 14:37:23 UTC
Can anybody reopen bug?
Comment 4 Denis V. Lunev 2009-09-13 17:07:20 UTC
same problem with gcc-4.3.4, sources comes from gentoo package

iris ~ $ arm-iwmmxt-linux-gnueabi-g++ -flax-vector-conversions -c -O2  1.cpp
/vol/marvel-4.3.2/bin/../lib/gcc/arm-iwmmxt-linux-gnueabi/4.3.4/include/mmintrin.h: In function 'void foo()':
/vol/marvel-4.3.2/bin/../lib/gcc/arm-iwmmxt-linux-gnueabi/4.3.4/include/mmintrin.h:529: internal compiler error: in arm_expand_binop_builtin, at config/arm/arm.c:15429
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
iris ~ $ arm-iwmmxt-linux-gnueabi-g++ -v
Using built-in specs.
Target: arm-iwmmxt-linux-gnueabi
Configured with: /vol/build/gcc-4.3.4/configure --target=arm-iwmmxt-linux-gnueabi --with-cpu=iwmmxt --with-float=soft --enable-cxx-flags=-msoft-float --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long --with-sysroot=/opt/marvel/sysroot --prefix=/opt/marvel/
Thread model: posix
gcc version 4.3.4 (GCC) 
Comment 5 Sergey Gusarov 2009-09-16 15:58:44 UTC
Denis, nobody wants to open this thread. First, we must do it.

PS You say in Russian?
Comment 6 Denis V. Lunev 2009-09-16 17:22:17 UTC
for russian - yes.

Should we open new issue? :)
Comment 7 Sergey Gusarov 2009-09-16 18:26:06 UTC
ß êîãäà-òî ïî ïîâîäó ýòîé îøèáêè îáèëüíî ãóãëèë è íàõîäèë íåñêîëüêî òðåäîâ â ýòîé áàãçèëëå. Èõ çàêðûâàëè ïîä ïðåäëîãîì "duplicate". ß äóìàþ, åñëè òû çàõî÷åøü, òû èõ òîæå íàéä¸øü. Òàê ÷òî - ýòî ãëàâíûé òðåä.
À òàê íàâåðíîå íàäî îòêðûâàòü íîâûé áàã è ñêîïèïàñòèòü òóäà ÷òî åñòü. :)
Comment 8 Richard Earnshaw 2009-09-17 17:03:54 UTC
The assertion in the source is clearly broken if a constant can legally be passed to it.  If a constant can't legally be passed, then the caller needs to be fixed to diagnose it before we reach this point.
Comment 9 serowk 2010-11-22 11:49:32 UTC
Appears with gcc 4.4.5 (builded with crosstool-ng 1.9.0)

$ /opt/arm-iwmmx-linux-uclibcgnueabi/bin/arm-iwmmx-linux-uclibcgnueabi-gcc iwmmx_test.c -flax-vector-conversions -O1
In file included from iwmmx_test.c:1:
/opt/arm-iwmmx-linux-uclibcgnueabi/lib/gcc/arm-iwmmx-linux-uclibcgnueabi/4.4.5/include/mmintrin.h: In function 'main':
/opt/arm-iwmmx-linux-uclibcgnueabi/lib/gcc/arm-iwmmx-linux-uclibcgnueabi/4.4.5/include/mmintrin.h:526: internal compiler error: in arm_expand_binop_builtin, at config/arm/arm.c:16168
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

iwmmx_test.c:

#include <mmintrin.h>
int main()
{
    _mm_srli_pi16(_mm_setzero_si64(), 8);
	return 0;
}

Compiler fail only when there is optimization(-O1).
Comment 10 serowk 2010-12-16 11:19:50 UTC
It seems that this bug affects the whole iwmmxt shift intrinsics group(_mm_slli_pi16, _mm_slli_pi32, _mm_slli_si64, _mm_srai_pi16, _mm_srai_pi32, _mm_srai_si64, _mm_srli_pi16, _mm_srli_pi32, _mm_srli_si64, _mm_rori_pi16, _mm_rori_pi32, _mm_rori_si64). I tested it.

These functions have the same prototype:
static __inline __m64 func_name (__m64 __m, int __count)

But it is very strange that abort did not work in gcc 3.4.5(This version looks like is not affected by this bug and it contains abort instead gcc_assert).

My suggestion:

static rtx
arm_expand_binop_builtin_iwmmx_shift (enum insn_code icode,
			  tree exp, rtx target)
{
  rtx pat;
  tree arg0 = CALL_EXPR_ARG (exp, 0);
  tree arg1 = CALL_EXPR_ARG (exp, 1);
  rtx op0 = expand_normal (arg0);
  rtx op1 = expand_normal (arg1);
  enum machine_mode tmode = insn_data[icode].operand[0].mode;
  enum machine_mode mode0 = insn_data[icode].operand[1].mode;
  enum machine_mode mode1 = insn_data[icode].operand[2].mode;

  gcc_assert (VECTOR_MODE_P (mode0))
  op0 = safe_vector_operand (op0, mode0);

  gcc_assert (!VECTOR_MODE_P (mode1))

  if (! target
      || GET_MODE (target) != tmode
      || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
    target = gen_reg_rtx (tmode);

  if (! (*insn_data[icode].operand[1].predicate) (op0, mode0))
    op0 = copy_to_mode_reg (mode0, op0);
  if (! (*insn_data[icode].operand[2].predicate) (op1, mode1))
    op1 = copy_to_mode_reg (mode1, op1);

  pat = GEN_FCN (icode) (target, op0, op1);
  if (! pat)
    return 0;
  emit_insn (pat);
  return target;
}

And in
arm_expand_builtin
...
  switch (fcode)
    {
...
	case ARM_BUILTIN_WSLLHI:
	case ARM_BUILTIN_WSLLWI:
	case ARM_BUILTIN_WSLLDI:

	case ARM_BUILTIN_WSRAHI:
	case ARM_BUILTIN_WSRAWI:
	case ARM_BUILTIN_WSRADI:

	case ARM_BUILTIN_WSRLHI:
	case ARM_BUILTIN_WSRLWI:
	case ARM_BUILTIN_WSRLDI:

	case ARM_BUILTIN_WRORHI:
	case ARM_BUILTIN_WRORWI:
	case ARM_BUILTIN_WRORDI:
		arm_expand_binop_builtin_iwmmx_shift(fcode, exp, target);
...
Comment 11 serowk 2010-12-17 16:16:28 UTC
Created attachment 22799 [details]
gcc 35294 possible Fix
Comment 12 serowk 2010-12-17 16:17:07 UTC
Created attachment 22800 [details]
gcc 4.4.5 possible fix
Comment 13 serowk 2010-12-17 16:22:36 UTC
I have attached two versions of the patch (gcc 4.2.4 and gcc 4.4.5). Patched gcc 4.2.4 seems to work. With the patched gcc 4.4.5, I ran into bug 44332, and can not check. For arm platform newer versions of gcc seems more completely ubusabled.
Comment 14 Matt Turner 2011-10-01 15:26:10 UTC
Created attachment 25391 [details]
[PATCH] Wire-up missing ARM iwmmxt intrinsics

Fixes it for me for gcc-4.6.1. Allows me to build an iwmmxt-optimized pixman using the standard _mm_* intrinsics.
Comment 15 junkmailnotread 2012-05-06 12:28:25 UTC
The previous attachment 25391 [details] fixes it for me for gcc-4.5.3.

It allowed me to build pixman-0.24.0 with the --enable-arm-iwmmxt configure option.
Comment 16 Nick Clifton 2012-06-26 14:59:54 UTC
Author: nickc
Date: Tue Jun 26 14:59:45 2012
New Revision: 188988

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188988
Log:
	* doc/extend.texi (__builtin_arm_tinsrb): Add missing second
	parameter.
	(__builtin_arm_tinsrh): Likewise.
	(__builtin_arm_tinsrw): Likewise.
	(__builtin_arm_wsadb): Add missing v2si parameter.
	(__builtin_arm_wsadh): Likewise.
	(__builtin_arm_getwcx): Delete.
	(__builtin_arm_setwcx): Delete.
	(__builtin_arm_getwcgr0): Add.
	(__builtin_arm_getwcgr1): Add.
	(__builtin_arm_getwcgr2): Add.
	(__builtin_arm_getwcgr3): Add.
	(__builtin_arm_setwcgr0): Add.
	(__builtin_arm_setwcgr1): Add.
	(__builtin_arm_setwcgr2): Add.
	(__builtin_arm_setwcgr3): Add.

	PR target/35294
	* gcc.target/arm/mmx-2.c: New.

Added:
    trunk/gcc/testsuite/gcc.target/arm/mmx-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/doc/extend.texi
    trunk/gcc/testsuite/ChangeLog
Comment 17 Nick Clifton 2013-01-28 15:07:48 UTC
Author: nickc
Date: Mon Jan 28 15:07:41 2013
New Revision: 195510

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195510
Log:
	PR target/35294
	* config/arm/arm.c (arm_expand_binop_builtin): Add new parameter.
	Fix mode checks to allow for the passing of constants in the
	second parameter.
	(arm_expand_builtin): Adjust calls to arm_expand_binop_builtin.
	Add entries in the switch statement for builtin iwmmxt vector
	shift and rotate builtins.

Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/config/arm/arm.c
Comment 18 Nick Clifton 2013-01-28 15:09:52 UTC
I have checked in a modified version of serowk's patch to the 4.7 branch.  The modification was to produce an error message in the cases where the modes do not match, and to allow for the automatic forcing of constants into registers for those builtins that do not accept immediates as their third operand.

Cheers
  Nick
Comment 19 Nick Clifton 2013-02-22 12:38:36 UTC
*** Bug 36798 has been marked as a duplicate of this bug. ***
Comment 20 Nick Clifton 2013-02-22 12:40:42 UTC
*** Bug 36966 has been marked as a duplicate of this bug. ***