From patchwork Tue Jul 18 08:53:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 121880 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1607317vqt; Tue, 18 Jul 2023 02:12:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlE/6uBIqLGpht9tAdFiwMN5b82Z3S59nINpK5KplFlXI8+vhsdGJdDql3NTf5wT0PKeE6+f X-Received: by 2002:a05:6512:33c8:b0:4f8:6560:6436 with SMTP id d8-20020a05651233c800b004f865606436mr11380901lfg.9.1689671556837; Tue, 18 Jul 2023 02:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689671556; cv=none; d=google.com; s=arc-20160816; b=hmXmXDwXI8No+DPmlg9gjrKootv5goWkyZxH7wEEzTHQVJ6iA5cQHfWHSsFUGrxKTB FRdRYhYgE5yV0Cf74+hkCQea5YYx2UCBBIGJUHaPoV4cFLJL6ShsqXJYrV6Xt1YKt4FS h7+5E0fPUf0VizsYDkKUbyGo/dlVjAIWn4wdhOEzPgNYp8QqKG0X6zZVFrk6yD2akvH0 jEG50IoeRt6Pm6cEuZr1pLFm+U/MRlqemjJd/her/xf9baOJTvup17nh7G7lEWqN68iH 3ULOYoSd26zdGFDwnibNahPJHW/9DjpjbeTmXuuwMH8ccRflD+Xi5BiAiE4y5IZ0B0G3 Us3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=o1Ifl5VDQlWe8uIWHthknhql5RNqKTJjwSWEy4g++GQ=; fh=6Fn44rT+es5LorQkefd/dMi3+2cZsvZW1j/f1fgpeig=; b=jgGsb5LGe8Vdp2Cx8dXNG/W6A9YZFphPF6Y3aFHs2mC/TNO/BLtdPW67kZc18YEb7H IzTtxB8BvBM+NEqNsclgFOYCg4WHBkGdGxPHr9N4yoxnfq4Tr54n9IpQMREOfhU+TaOr uziySJbIBzwFvOoCBgtmtjnisxHaPn9HNuiXj2MMVbaNQElGyCtS0DSqJWnx1oH8+RtV QwOLLUGhhRY97dBlw5soNlCWc49O1LE2XHm/CZQGsWeXmuhu03PMvDxEo+61yDh9PS03 XibWWyi84t9sb6PczC+vaQwdFjniea8zKpL1pndYNZi8DFtMUJ+xoi/tYe1GBiLPf5XK r/6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay25-20020a056402203900b0051e0eca4c16si918593edb.529.2023.07.18.02.12.12; Tue, 18 Jul 2023 02:12:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231342AbjGRIyN (ORCPT + 99 others); Tue, 18 Jul 2023 04:54:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232058AbjGRIyD (ORCPT ); Tue, 18 Jul 2023 04:54:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E279EE55; Tue, 18 Jul 2023 01:53:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7861B614CA; Tue, 18 Jul 2023 08:53:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C995C433C7; Tue, 18 Jul 2023 08:53:51 +0000 (UTC) From: Huacai Chen To: Huacai Chen Cc: loongarch@lists.linux.dev, linux-arch@vger.kernel.org, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Huacai Chen , WANG Xuerui Subject: [PATCH V2] LoongArch: Cleanup __builtin_constant_p() checking for cpu_has_* Date: Tue, 18 Jul 2023 16:53:27 +0800 Message-Id: <20230718085327.2691237-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771749042184605782 X-GMAIL-MSGID: 1771749042184605782 In the current configuration, cpu_has_lsx and cpu_has_lasx cannot be constants. So cleanup the __builtin_constant_p() checking to reduce the complexity. Reviewed-by: WANG Xuerui Signed-off-by: Huacai Chen --- V2: Update commit message. arch/loongarch/include/asm/fpu.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/arch/loongarch/include/asm/fpu.h b/arch/loongarch/include/asm/fpu.h index e4193d637f66..b541f6248837 100644 --- a/arch/loongarch/include/asm/fpu.h +++ b/arch/loongarch/include/asm/fpu.h @@ -218,15 +218,8 @@ static inline void restore_lsx(struct task_struct *t) static inline void init_lsx_upper(void) { - /* - * Check cpu_has_lsx only if it's a constant. This will allow the - * compiler to optimise out code for CPUs without LSX without adding - * an extra redundant check for CPUs with LSX. - */ - if (__builtin_constant_p(cpu_has_lsx) && !cpu_has_lsx) - return; - - _init_lsx_upper(); + if (cpu_has_lsx) + _init_lsx_upper(); } static inline void restore_lsx_upper(struct task_struct *t) @@ -294,7 +287,7 @@ static inline void restore_lasx_upper(struct task_struct *t) {} static inline int thread_lsx_context_live(void) { - if (__builtin_constant_p(cpu_has_lsx) && !cpu_has_lsx) + if (!cpu_has_lsx) return 0; return test_thread_flag(TIF_LSX_CTX_LIVE); @@ -302,7 +295,7 @@ static inline int thread_lsx_context_live(void) static inline int thread_lasx_context_live(void) { - if (__builtin_constant_p(cpu_has_lasx) && !cpu_has_lasx) + if (!cpu_has_lasx) return 0; return test_thread_flag(TIF_LASX_CTX_LIVE);