User account creation filtered due to spam.

Bug 20415 - [4.0/4.1 Regression] Vector init builtin produces invalid instruction pshufw
Summary: [4.0/4.1 Regression] Vector init builtin produces invalid instruction pshufw
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.0.0
Assignee: Richard Henderson
URL:
Keywords: ssemmx, wrong-code
Depends on:
Blocks:
 
Reported: 2005-03-11 05:32 UTC by mschimek@users.sourceforge.net
Modified: 2005-03-11 18:58 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2005-03-11 14:59:50


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mschimek@users.sourceforge.net 2005-03-11 05:32:39 UTC
__builtin_ia32_vec_init_v4hi and __builtin_ia32_vec_init_v8qi
produce the pshufw instruction when compiled with -O2 and any of the
switches -mmmx, -m3dnow, -march=pentium-mmx, -march=pentium2,
-march=k6, -march=k6-2, i.e. targeting CPUs which do not support SSE.

Environment:
System: Linux localhost 2.4.20 #2 Tue Mar 8 16:32:57 CET 2005 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../../cvs/gcc/configure --prefix=/opt/gcc-4.1 --enable-languages=c,c++

How-To-Repeat:

typedef short __v4hi __attribute__ ((__vector_size__ (8)));
extern int i;
extern __v4hi v1;
extern __v4hi v2;
void foo (void)
{
  v1 = __builtin_ia32_vec_init_v4hi (i,i,i,i);
  v2 = __builtin_ia32_vec_init_v8qi (i,i,i,i,i,i,i,i);
}

gcc -O2 -mmmx -S example.c 

          .file   "example.c"
        .text
        .p2align 4,,15
.globl foo
        .type   foo, @function
foo:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %eax
        movl    i, %edx
        movl    %edx, -4(%ebp)
        andl    $255, %edx
        movl    %edx, %eax
        movd    -4(%ebp), %mm1
        sall    $8, %eax
        orl     %edx, %eax
        pshufw  $0, %mm1, %mm1
        movl    %eax, -4(%ebp)
        movq    %mm1, v1
        movd    -4(%ebp), %mm1
        pshufw  $0, %mm1, %mm1
        movq    %mm1, v2       
        leave
        ret
        .size   foo, .-foo
        .ident  "GCC: (GNU) 4.1.0 20050307 (experimental)"
        .section        .note.GNU-stack,"",@progbits
Comment 1 Andrew Pinski 2005-03-11 05:45:51 UTC
Confirmed, pshufw is marked wrong in mmx.md, I think it should be moved to sse.md and marked as 
SSE only.
Comment 2 Uroš Bizjak 2005-03-11 12:32:33 UTC
The problem is in "*vec_dupv4hi" pattern. However if constraint is changed to
(correct) "TARGET_SSE || TARGET_3DNOW_A", testcase ICES with unrecognizable insn.
Comment 3 CVS Commits 2005-03-11 17:50:39 UTC
Subject: Bug 20415

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2005-03-11 17:50:30

Modified files:
	gcc            : ChangeLog 
	gcc/config/i386: i386.c mmx.md 

Log message:
	PR target/20415
	* config/i386/mmx.md (vec_dupv4hi): Fix predicate.
	* config/i386/i386.c (ix86_expand_vector_init_duplicate): Update
	to match.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7788&r2=2.7789
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&r1=1.795&r2=1.796
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/mmx.md.diff?cvsroot=gcc&r1=1.6&r2=1.7

Comment 4 CVS Commits 2005-03-11 17:52:10 UTC
Subject: Bug 20415

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	rth@gcc.gnu.org	2005-03-11 17:52:00

Modified files:
	gcc            : ChangeLog 
	gcc/config/i386: i386.c mmx.md 

Log message:
	PR target/20415
	* config/i386/mmx.md (vec_dupv4hi): Fix predicate.
	* config/i386/i386.c (ix86_expand_vector_init_duplicate): Update
	to match.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.42&r2=2.7592.2.43
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.795&r2=1.795.6.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/mmx.md.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.6&r2=1.6.16.1

Comment 5 Andrew Pinski 2005-03-11 18:58:51 UTC
Fixed.