From patchwork Sat Feb 8 08:01:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 3609511 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A718E9F2D6 for ; Sat, 8 Feb 2014 08:03:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DDB32201E9 for ; Sat, 8 Feb 2014 08:03:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A3A2201E4 for ; Sat, 8 Feb 2014 08:03:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751826AbaBHICO (ORCPT ); Sat, 8 Feb 2014 03:02:14 -0500 Received: from mga14.intel.com ([143.182.124.37]:2453 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751803AbaBHICN (ORCPT ); Sat, 8 Feb 2014 03:02:13 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by azsmga102.ch.intel.com with ESMTP; 08 Feb 2014 00:02:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,805,1384329600"; d="scan'208";a="471776735" Received: from laut.jf.intel.com (HELO localhost) ([10.23.232.94]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2014 00:02:04 -0800 Received: by localhost (Postfix, from userid 1000) id 6AC8B124AC1; Sat, 8 Feb 2014 09:01:26 +0100 (CET) From: Andi Kleen To: linux-kernel@vger.kernel.org Cc: linux-kbuild@vger.kernel.org, x86@kernel.org, Andi Kleen Subject: [PATCH 02/17] x86, lto: Disable fancy hweight optimizations for LTO v2 Date: Sat, 8 Feb 2014 09:01:06 +0100 Message-Id: <1391846481-31491-2-git-send-email-ak@linux.intel.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1391846481-31491-1-git-send-email-ak@linux.intel.com> References: <1391846481-31491-1-git-send-email-ak@linux.intel.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The fancy x86 hweight uses different compiler options for the hweight file. This does not work with LTO. Just disable the optimization with LTO v2: Simplify Kconfig checks (Jan Beulich) Cc: x86@kernel.org Signed-off-by: Andi Kleen --- arch/x86/Kconfig | 1 + arch/x86/include/asm/arch_hweight.h | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 940e50e..f125c5f 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -255,6 +255,7 @@ config X86_32_LAZY_GS config ARCH_HWEIGHT_CFLAGS string + default "" if LTO default "-fcall-saved-ecx -fcall-saved-edx" if X86_32 default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11" if X86_64 diff --git a/arch/x86/include/asm/arch_hweight.h b/arch/x86/include/asm/arch_hweight.h index 9686c3d..ca80549 100644 --- a/arch/x86/include/asm/arch_hweight.h +++ b/arch/x86/include/asm/arch_hweight.h @@ -25,9 +25,14 @@ static inline unsigned int __arch_hweight32(unsigned int w) { unsigned int res = 0; +#ifdef CONFIG_LTO + res = __sw_hweight32(w); +#else + asm (ALTERNATIVE("call __sw_hweight32", POPCNT32, X86_FEATURE_POPCNT) : "="REG_OUT (res) : REG_IN (w)); +#endif return res; } @@ -46,6 +51,9 @@ static inline unsigned long __arch_hweight64(__u64 w) { unsigned long res = 0; +#ifdef CONFIG_LTO + res = __sw_hweight64(w); +#else #ifdef CONFIG_X86_32 return __arch_hweight32((u32)w) + __arch_hweight32((u32)(w >> 32)); @@ -54,6 +62,7 @@ static inline unsigned long __arch_hweight64(__u64 w) : "="REG_OUT (res) : REG_IN (w)); #endif /* CONFIG_X86_32 */ +#endif return res; }