From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21910 invoked by alias); 5 Jan 2005 12:52:45 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 21372 invoked by uid 48); 5 Jan 2005 12:52:21 -0000 Date: Wed, 05 Jan 2005 12:52:00 -0000 From: "smelkov at mph1 dot phys dot spbu dot ru" To: gcc-bugs@gcc.gnu.org Message-ID: <20050105125215.19263.smelkov@mph1.phys.spbu.ru> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/19263] New: [g++-3.4.3 regression]: wrong-code: explicit inicialization of v8qi miscompiled X-Bugzilla-Reason: CC X-SW-Source: 2005-01/txt/msg00437.txt.bz2 List-Id: In the following code sample the line v8qi val8 = {v,v,v,v,v,v,v,v}; is miscompiled to smth like v8qi val8 = {0,0,0,0,0,0,0,0}; ---v8qi-init.cpp--- typedef int v8qi __attribute__ ((mode(V8QI))); static unsigned char S[8]; void do_subs(unsigned char v) { v8qi val8 = {v,v,v,v,v,v,v,v}; v8qi* s = (v8qi*)&S[0]; *s = __builtin_ia32_psubusb(*s, val8); } int main() { int i; for (i=0;i<8;++i) S[i] = 0x55; do_subs(0x54); for (i=0;i<8;++i) if (S[i] != 0x01) return 1; return 0; } --- [kirr@tugrik gcc-v8qi-bug]$ g++ -v Reading specs from /usr/local/gcc-3.4.3-nocheck-native/lib/gcc/i686-pc-linux-gnu/3.4.3/specs Configured with: ../gcc-3.4.3/configure --prefix=/usr/local/gcc-3.4.3-nocheck-native --with-gnu-as --with-gnu-ld --enable-threads=posix --with-arch=pentium3 --with-tune=pentium4 --enable-__cxa_atexit --enable-languages=c,c++,java,f77,ada --disable-checking --disable-nls Thread model: posix gcc version 3.4.3 [kirr@tugrik gcc-v8qi-bug]$ g++ -g -Wall -march=i686 -mmmx v8qi-init.cpp [kirr@tugrik gcc-v8qi-bug]$ ./a.out [kirr@tugrik gcc-v8qi-bug]$ echo $? 1 --- with g++-3.4.2 it is ok, so it is a regression. please also note, that with gcc-3.4.3 it is also ok, so it is g++ specific (???) here are assembly parts: ---g++-3.4.3--- void do_subs(unsigned char v) { 8048374: 55 push %ebp 8048375: 89 e5 mov %esp,%ebp 8048377: 83 ec 18 sub $0x18,%esp 804837a: 8b 45 08 mov 0x8(%ebp),%eax 804837d: 88 45 ff mov %al,0xffffffff(%ebp) v8qi val8 = {v,v,v,v,v,v,v,v}; 8048380: 0f ef c0 pxor %mm0,%mm0 8048383: 0f 7f 45 f0 movq %mm0,0xfffffff0(%ebp) v8qi* s = (v8qi*)&S[0]; 8048387: c7 45 ec f4 95 04 08 movl $0x80495f4,0xffffffec(%ebp) *s = __builtin_ia32_psubusb(*s, val8); 804838e: 8b 55 ec mov 0xffffffec(%ebp),%edx 8048391: 8b 45 ec mov 0xffffffec(%ebp),%eax 8048394: 0f 6f 00 movq (%eax),%mm0 8048397: 0f d8 45 f0 psubusb 0xfffffff0(%ebp),%mm0 804839b: 0f 7f 02 movq %mm0,(%edx) } 804839e: c9 leave 804839f: c3 ret --- note: pxor %mm0,%mm0 after "val8=..." ---g++-3.4.2--- void do_subs(unsigned char v) { 8048374: 55 push %ebp 8048375: 89 e5 mov %esp,%ebp 8048377: 83 ec 18 sub $0x18,%esp 804837a: 8b 45 08 mov 0x8(%ebp),%eax 804837d: 88 45 ff mov %al,0xffffffff(%ebp) v8qi val8 = {v,v,v,v,v,v,v,v}; 8048380: 0f b6 45 ff movzbl 0xffffffff(%ebp),%eax 8048384: 88 45 f0 mov %al,0xfffffff0(%ebp) 8048387: 0f b6 45 ff movzbl 0xffffffff(%ebp),%eax 804838b: 88 45 f1 mov %al,0xfffffff1(%ebp) 804838e: 0f b6 45 ff movzbl 0xffffffff(%ebp),%eax 8048392: 88 45 f2 mov %al,0xfffffff2(%ebp) 8048395: 0f b6 45 ff movzbl 0xffffffff(%ebp),%eax 8048399: 88 45 f3 mov %al,0xfffffff3(%ebp) 804839c: 0f b6 45 ff movzbl 0xffffffff(%ebp),%eax 80483a0: 88 45 f4 mov %al,0xfffffff4(%ebp) 80483a3: 0f b6 45 ff movzbl 0xffffffff(%ebp),%eax 80483a7: 88 45 f5 mov %al,0xfffffff5(%ebp) 80483aa: 0f b6 45 ff movzbl 0xffffffff(%ebp),%eax 80483ae: 88 45 f6 mov %al,0xfffffff6(%ebp) 80483b1: 0f b6 45 ff movzbl 0xffffffff(%ebp),%eax 80483b5: 88 45 f7 mov %al,0xfffffff7(%ebp) v8qi* s = (v8qi*)&S[0]; 80483b8: c7 45 ec 24 96 04 08 movl $0x8049624,0xffffffec(%ebp) *s = __builtin_ia32_psubusb(*s, val8); 80483bf: 8b 55 ec mov 0xffffffec(%ebp),%edx 80483c2: 8b 45 ec mov 0xffffffec(%ebp),%eax 80483c5: 0f 6f 00 movq (%eax),%mm0 80483c8: 0f d8 45 f0 psubusb 0xfffffff0(%ebp),%mm0 80483cc: 0f 7f 02 movq %mm0,(%edx) } 80483cf: c9 leave 80483d0: c3 ret 80483d1: 90 nop --- -- Summary: [g++-3.4.3 regression]: wrong-code: explicit inicialization of v8qi miscompiled Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: smelkov at mph1 dot phys dot spbu dot ru CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19263