From owner-freebsd-hackers@FreeBSD.ORG Fri Nov 1 12:47:25 2013 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 3D73D95C for ; Fri, 1 Nov 2013 12:47:25 +0000 (UTC) (envelope-from danfe@regency.nsu.ru) Received: from mx.nsu.ru (mx.nsu.ru [84.237.50.39]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D61CC2941 for ; Fri, 1 Nov 2013 12:47:24 +0000 (UTC) Received: from regency.nsu.ru ([193.124.210.26]) by mx.nsu.ru with esmtp (Exim 4.69) (envelope-from ) id 1VcE83-0004DC-Ri for hackers@freebsd.org; Fri, 01 Nov 2013 19:47:12 +0700 Received: from regency.nsu.ru (localhost [127.0.0.1]) by regency.nsu.ru (8.14.2/8.14.2) with ESMTP id rA1CkprX076718 for ; Fri, 1 Nov 2013 19:47:01 +0700 (NOVT) (envelope-from danfe@regency.nsu.ru) Received: (from danfe@localhost) by regency.nsu.ru (8.14.2/8.14.2/Submit) id rA1CkkE4076668 for hackers@freebsd.org; Fri, 1 Nov 2013 19:46:46 +0700 (NOVT) (envelope-from danfe) Date: Fri, 1 Nov 2013 19:46:46 +0700 From: Alexey Dokuchaev To: hackers@freebsd.org Subject: SSE2 intrinsics: gcc46 vs. clang contradiction Message-ID: <20131101124645.GA73456@regency.nsu.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-Mailman-Approved-At: Fri, 01 Nov 2013 13:05:10 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Nov 2013 12:47:25 -0000 Hi there, I've recently encountered a piece of code that uses some SSE2 intrinsics and builds with gcc46, but not clang: clang can't find _mm_movpi64_epi64(), while gcc46 defines it in its lib/gcc46/gcc/.../4.6.3/include/emmintrin.h: extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_movpi64_epi64 (__m64 __A) { return _mm_set_epi64 ((__m64)0LL, __A); } extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_set_epi64x (long long __q1, long long __q0) { return __extension__ (__m128i)(__v2di){ __q0, __q1 }; } Now, Clang in /usr/include/clang/3.3/emmintrin.h defines similar function, but without the `e', _mm_movpi64_pi64(): static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) _mm_movpi64_pi64(__m64 __a) { return (__m128i){ (long long)__a, 0 }; } So what's going on here? Who is right? What adds to confusion, in their manual [1] Intel spells them differently themselves: first, in the table, it says: _mm_movpi64_epi64 Move MOVDQ2Q ^^^^^ Then later, when they describe what it does, it says: __m128i _mm_movpi64_pi64(__m64 a) ^^^^ Moves the 64 bits of a to the lower 64 bits of the result, zeroing the upper bits. Or I'm just being stupid and confusing two different functions? ./danfe [1] http://software.intel.com/sites/products/documentation/doclib/iss/2013/compiler/cpp-lin/GUID-AFA947A7-8490-443B-9946-C7B16C8E6244.htm