From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21252 invoked by alias); 4 May 2003 17:36:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 21222 invoked by uid 71); 4 May 2003 17:36:00 -0000 Resent-Date: 4 May 2003 17:36:00 -0000 Resent-Message-ID: <20030504173600.21221.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, yourst@yourst.com Resent-Reply-To: gcc-gnats@gcc.gnu.org, yourst@yourst.com Received: (qmail 19539 invoked by uid 48); 4 May 2003 17:29:03 -0000 Message-Id: <20030504172903.19538.qmail@sources.redhat.com> Date: Sun, 04 May 2003 17:36:00 -0000 From: yourst@yourst.com Reply-To: yourst@yourst.com To: gcc-gnats@gcc.gnu.org Cc: yourst@yourst.com X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify: yourst@yourst.com Subject: optimization/10623: Incorrect generation of IA-32 SSE movups via __builtin_ia32_loadups X-SW-Source: 2003-05/txt/msg00244.txt.bz2 List-Id: >Number: 10623 >Category: optimization >Synopsis: Incorrect generation of IA-32 SSE movups via __builtin_ia32_loadups >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Sun May 04 17:36:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Matt Yourst >Release: gcc 3.2.2 >Organization: >Environment: gcc from Mandrake Linux (release gcc-3.2.2-3mdk) >Description: When using the __builtin_ia32_loadups function, gcc generates incorrect code at all optimization levels including -O1. In some circumstances, gcc generates a "movaps" load instruction instead of the specified "movups"; the code will cause an unaligned SSE load exception when run. Furthermore, if the (incorrectly) loaded vector is subsequently stored to another correctly aligned address, gcc places the "movups" there in place of the correct instruction, "movaps". See below for code and commented disassembly. >How-To-Repeat: // Compile with gcc -O2 -msse -fomit-frame-pointer: typedef float vec4f_t __attribute__ ((mode(V4SF))); void test(vec4f_t* dest, float* src, int count) { for (int i = 0; i < count; i++) { vec4f_t v = __builtin_ia32_loadups(src + i); dest[i] = v; } } int main() { vec4f_t dest[64]; float src[64]; test(dest, src, 64-4); } /* Dump of assembler code for function _Z4testPU8__vectorfPfi: mov 0xc(%esp,1),%eax test %eax,%eax jle 0x80483ef <_Z4testPU8__vectorfPfi+31> mov 0x4(%esp,1),%ecx mov 0x8(%esp,1),%edx movaps (%edx),%xmm0 << INCORRECT: this should be movups (%edx),%xmm0 movups %xmm0,(%ecx) << INCORRECT: this should be movaps %xmm0,(%ecx) add $0x4,%edx add $0x10,%ecx dec %eax jne 0x80483e0 <_Z4testPU8__vectorfPfi+16> ret */ >Fix: Unknown; only workaround is to compile at -O0 or use inline assembly instead of __builtin_ia32_loadups intrinsic. >Release-Note: >Audit-Trail: >Unformatted: