From patchwork Wed Jul 9 07:51:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wohlferd X-Patchwork-Id: 368116 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 95670140110 for ; Wed, 9 Jul 2014 17:52:03 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=N9E2LZwNX6gyejJ9NzIPoYGZty/8f6f3WpfTTN0swTh nerGjVGjMg0WfxxGWridsTFWaINMMIw7vV3N29gZjXSriy0Nes3nx3eVxHivFNsK pNzR7j5TUkaP+vbPPfbMOBw6El8UxkN9gLHCoHmU7Pe8fBlApTgmYVMGUJaBwvVg = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=Mc/LujGm8inAwPTgA2gxEC5XRZQ=; b=xYbwRVNdfipy/wlKP Nh/qPLz4tIzy3aYntnvanSXAAK4MyYz/h9Spcl09DhU2PQHUxr83Wf1rztx4Scg3 l5nrDmbPWaKsTeEECNwWZGIohGFyzQe9mm0dU8vWkKa//qRl7vPfxSmhpC2jahFb MNdLASo9ZDblk09bvZZm9vTAM4= Received: (qmail 18511 invoked by alias); 9 Jul 2014 07:51:54 -0000 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 Received: (qmail 18497 invoked by uid 89); 9 Jul 2014 07:51:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: limegreensocks.com Received: from limegreensocks.com (HELO limegreensocks.com) (207.118.20.56) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (DES-CBC3-SHA encrypted) ESMTPS; Wed, 09 Jul 2014 07:51:52 +0000 Received: from [192.168.1.44] ([192.168.1.44]) by limegreensocks.com via TCP with ESMTPSA; Wed, 09 Jul 2014 00:52:28 -0700 Message-ID: <53BCF48F.60005@LimeGreenSocks.com> Date: Wed, 09 Jul 2014 00:51:43 -0700 From: David Wohlferd User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: hjl.tools@gmail.com Subject: [Patch] PR 61662 X-IsSubscribed: yes As requested, I am posting this patch to gcc-patches. Problem description: The detailed description and examples can be found in pr61662, but in short: using "#ifdef __x86_64__" to determine the size of a 'long' does not reliably yield the correct result. This causes _lrotl and _lrotr to return incorrect results on LLP64 systems (like Windows). ChangeLog: 2014-07-09 David Wohlferd PR target/61662 * config/i386/ia32intrin.h: Use __LP64__ to determine size of long dw Index: ia32intrin.h =================================================================== --- ia32intrin.h (revision 212190) +++ ia32intrin.h (working copy) @@ -256,11 +256,7 @@ #define _bswap64(a) __bswapq(a) #define _popcnt64(a) __popcntq(a) -#define _lrotl(a,b) __rolq((a), (b)) -#define _lrotr(a,b) __rorq((a), (b)) #else -#define _lrotl(a,b) __rold((a), (b)) -#define _lrotr(a,b) __rord((a), (b)) /* Read flags register */ extern __inline unsigned int @@ -280,6 +276,15 @@ #endif +/* on LP64 systems, longs are 64bits. Use the appropriate rotate function */ +#ifdef __LP64__ +#define _lrotl(a,b) __rolq((a), (b)) +#define _lrotr(a,b) __rorq((a), (b)) +#else +#define _lrotl(a,b) __rold((a), (b)) +#define _lrotr(a,b) __rord((a), (b)) +#endif + #define _bit_scan_forward(a) __bsfd(a) #define _bit_scan_reverse(a) __bsrd(a) #define _bswap(a) __bswapd(a)