From patchwork Sun Dec 4 11:49:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 129144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 3240DB6F65 for ; Sun, 4 Dec 2011 22:49:19 +1100 (EST) Received: (qmail 24056 invoked by alias); 4 Dec 2011 11:49:17 -0000 Received: (qmail 24048 invoked by uid 22791); 4 Dec 2011 11:49:16 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_AV, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-gy0-f175.google.com (HELO mail-gy0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 04 Dec 2011 11:49:03 +0000 Received: by ghrr13 with SMTP id r13so4177323ghr.20 for ; Sun, 04 Dec 2011 03:49:03 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.181.225 with SMTP id l61mr6136273yhm.131.1322999341561; Sun, 04 Dec 2011 03:49:01 -0800 (PST) Received: by 10.146.137.4 with HTTP; Sun, 4 Dec 2011 03:49:01 -0800 (PST) Date: Sun, 4 Dec 2011 12:49:01 +0100 Message-ID: Subject: Re: Wrong parameter type for _mm256_insert_epi64 in avxintrin.h From: Uros Bizjak To: gcc-patches@gcc.gnu.org Cc: =?ISO-8859-1?Q?J=E9r=E9mie_Detrey?= Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello! > Attached is a patch which fixes bug target/51393: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51393 > > Also attached, avx_bug.c is a minimal example to reproduce the bug > (requires an AVX-capable CPU): > > $ gcc -O3 -mavx avx_bug.c > $ ./a.out 0x80000000 > in = 0x0000000080000000 > out = 0xffffffff80000000 > > The correct output should be: > > $ ./a.out 0x80000000 > in = 0x0000000080000000 > out = 0x0000000080000000 > > As explained in the bug report, it's just a matter of the second > parameter of _mm256_insert_epi64 being declared as int where it should > be long long (avxintrin.h:762). A simple typo, trivially fixed by the > attached patch. OK. Attached patch (with a testcase) was committed to mainline SVN with following ChangeLog entry: 2011-12-04 Jérémie Detrey PR target/51393 * config/i386/avxintrin.h (_mm256_insert_epi64): Declare second parameter as long long. testsuite/ChangeLog: 2011-12-04 Uros Bizjak Jérémie Detrey PR target/51393 * gcc.target/i386/pr51393.c: New test. Patch was tested on x86_64-pc-linux-gnu {,-m32}. Patch was committed to mainline, will be committed to release branches. Thanks, Uros. Index: config/i386/avxintrin.h =================================================================== --- config/i386/avxintrin.h (revision 181984) +++ config/i386/avxintrin.h (working copy) @@ -759,7 +759,7 @@ #ifdef __x86_64__ extern __inline __m256i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) -_mm256_insert_epi64 (__m256i __X, int __D, int const __N) +_mm256_insert_epi64 (__m256i __X, long long __D, int const __N) { __m128i __Y = _mm256_extractf128_si256 (__X, __N >> 1); __Y = _mm_insert_epi64 (__Y, __D, __N % 2); Index: testsuite/gcc.target/i386/pr51393.c =================================================================== --- testsuite/gcc.target/i386/pr51393.c (revision 0) +++ testsuite/gcc.target/i386/pr51393.c (revision 0) @@ -0,0 +1,21 @@ +/* { dg-do run { target { ! { ia32 } } } } */ +/* { dg-require-effective-target avx } */ +/* { dg-options "-O -mavx" } */ + +#include "avx-check.h" +#include + +static void +__attribute__((noinline)) +avx_test (void) +{ + long long in = 0x800000000ll; + long long out; + + __m256i zero = _mm256_setzero_si256(); + __m256i tmp = _mm256_insert_epi64 (zero, in, 0); + out = _mm256_extract_epi64(tmp, 0); + + if (in != out) + abort (); +}