Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6498282rwp; Tue, 18 Jul 2023 00:59:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBvLXuV2VV3X4B8yd7PL1xW56WwL2R3XR1xQxS/WdEsrG1R6jR5LZlgESDcE9/wn1l+jxG X-Received: by 2002:a05:6402:886:b0:51e:2e39:9003 with SMTP id e6-20020a056402088600b0051e2e399003mr12861890edy.40.1689667139743; Tue, 18 Jul 2023 00:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689667139; cv=none; d=google.com; s=arc-20160816; b=hCy6Tru7iskQt2TqOadQnqs36O36QeB6WDtfZPFywNWserbim0KoZ5ocLvhyqX2Vi3 uY7cVrq/WeDDcS1gceumOihKjUIxVxiSJrCFxiRNVuFS6gyttUPgzxaJeUDinObLXwJu NMUlWMOpX32mwyOgOYIhwd1hxDNmudUVh2oiZ+VJiYfFkN5SgKjNgYOIqwmnz1sfFp1p 2zvcr+IAOOeW8CUO8+I9Hi1QxLcsZVm9b5+s8JRdLHnaMsDeaWZNIqcwVsFfuZnHTwmd to10WcCNp1oMi/PdN4J3kgz5Z8jHd9Sz3MQ9O2Z8qc0R1QnyluWoRt7/FApgGIFz5iLT f1MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Z0tvEakfDEb1noOXzOkCjjzTk2vxcdxID2+08VCzRN0=; fh=sDLpgug4GPK2y+1mgRXJ/Fbmu2Q6Zx3JO1N2qHO0/tA=; b=HitXLssbCx3QAe/KoiyuNbd5t4nUOnd7yfV2DvdABsVc+Ix8rxnkGFRvdrAVowwJ/F XckOaZ00C3m7aSbh6gPpWz4tPMPzRTCidvz2jLukWMKI3T36J3kxhhTv0ZA7ttT1/f2H Vlgnq6+Iqp87FysD64TXeZSUD0L0rh5dsKxEtZ5/MgBkJWYeSloP1xnhmYMQcihHtZr1 Ry/fvaL52qdDzSnOEppj3DUpsq3Y1djC+moYcmn0ME6TUtxsEbw0wKcwjjS9BCGKItGt HeHVaQH/yB00/UJj1Z4T4oxAhAf45kKCOuNyMw/LmwYt69uZ/JUnH5F1MVKzTFvdHV+R SMsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=TEd8Dgh3; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020aa7d048000000b0051e029af08esi807314edo.371.2023.07.18.00.58.36; Tue, 18 Jul 2023 00:58:59 -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; dkim=pass header.i=@xen0n.name header.s=mail header.b=TEd8Dgh3; 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 S230168AbjGRHe6 (ORCPT + 99 others); Tue, 18 Jul 2023 03:34:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229708AbjGRHe5 (ORCPT ); Tue, 18 Jul 2023 03:34:57 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66DAD10D; Tue, 18 Jul 2023 00:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1689665689; bh=0dhKwcbWoqGkIlVJQTKrRCgM9NPlqkRBuK4pvbdfpdE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=TEd8Dgh31dm+LAQsOm/hBPLYZsO+NlDOWZUI25/DPaHR9aIAed47qGtepHcsjKi+M vgInZvSHjoSM5UiWm4RE7KYC9jVWdvuA/1y4OJPZoZSH6JPZWGMVkagPkVqWpF1OAk 65ZAdT86vz5CSYChOTPqlEX8OfJFISbNFTkzoOSs= Received: from [100.100.34.13] (unknown [220.248.53.61]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 96C1C60103; Tue, 18 Jul 2023 15:34:48 +0800 (CST) Message-ID: Date: Tue, 18 Jul 2023 15:34:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] LoongArch: Cleanup __builtin_constant_p() checking for cpu_has_* Content-Language: en-US To: Huacai Chen , Huacai Chen Cc: loongarch@lists.linux.dev, linux-arch@vger.kernel.org, Xuefeng Li , Guo Ren , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn References: <20230718064819.2549052-1-chenhuacai@loongson.cn> From: WANG Xuerui In-Reply-To: <20230718064819.2549052-1-chenhuacai@loongson.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On 2023/7/18 14:48, Huacai Chen wrote: > In current configuration, cpu_has_lsx and cpu_has_lasx are impossible > constants. So cleanup the __builtin_constant_p() checking to reduce the "cannot be constants"? "impossible constants" sounds like a compile-time error to me. > complexity. > > Signed-off-by: Huacai Chen > --- > arch/loongarch/include/asm/fpu.h | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/arch/loongarch/include/asm/fpu.h b/arch/loongarch/include/asm/fpu.h > index e4193d637f66..f02f4a0d0d64 100644 > --- a/arch/loongarch/include/asm/fpu.h > +++ b/arch/loongarch/include/asm/fpu.h > @@ -218,12 +218,7 @@ 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) > + if (!cpu_has_lsx) > return; > > _init_lsx_upper(); > @@ -294,7 +289,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 +297,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); For the foreseeable future, the changes seem appropriate to me. FWIW the LoongArch kernel would stay as generic as possible so I expect the various predicates to almost never exist as constants. Reviewed-by: WANG Xuerui -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/