From patchwork Wed Sep 7 11:09:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?556/5LuZ5re8?= X-Patchwork-Id: 57463 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DBBF9385021C for ; Wed, 7 Sep 2022 11:10:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBBF9385021C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662549013; bh=p9hJfuG1KBy4bW3auzevVWT+acxKk5DjOuTtJsCDHxA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fRhpa881Msgni1TM5QXbVMGb8FABoyEV5GeVVVlPDdu01FyjwO8RKGq4JvCUEQkJ2 VRdxtstHuvFwFNzEoLFNsAWC9uYVmbp3D7o88x76uowUhib76gwrwAXysOlqenBu7Y dBOBK17fWkFN5WSwBQPCsxGqTP0cf4KRRZdAlVWo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by sourceware.org (Postfix) with ESMTPS id 1A03B385841A for ; Wed, 7 Sep 2022 11:09:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1A03B385841A X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R651e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045168; MF=cooper.qu@linux.alibaba.com; NM=1; PH=DS; RN=3; SR=0; TI=SMTPD_---0VOy5Uc7_1662548975; Received: from L-PF1ZESZG-1136.hz.ali.com(mailfrom:cooper.qu@linux.alibaba.com fp:SMTPD_---0VOy5Uc7_1662548975) by smtp.aliyun-inc.com; Wed, 07 Sep 2022 19:09:39 +0800 To: gcc-patches@gcc.gnu.org Subject: [COMMITTED] C-SKY: Fix expanding of float LE comparing with zero for fpuv3. Date: Wed, 7 Sep 2022 19:09:33 +0800 Message-Id: <20220907110933.2630-1-cooper.qu@linux.alibaba.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 X-Spam-Status: No, score=-20.5 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xianmiao Qu via Gcc-patches From: =?utf-8?b?556/5LuZ5re8?= Reply-To: Xianmiao Qu Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The original code will cause the warning: /usr/lib/gcc-snapshot/bin/g++ -fno-PIE -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o csky.o -MT csky.o -MMD -MP -MF ./.deps/csky.TPo ../../gcc/gcc/config/csky/csky.cc In file included from ../../gcc/gcc/config/csky/csky.h:183, from ./tm.h:20, from ../../gcc/gcc/backend.h:28, from ../../gcc/gcc/config/csky/csky.cc:27: ../../gcc/gcc/config/csky/csky.cc: In function 'bool csky_emit_compare_float(rtx_code, rtx, rtx)': ../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context] 29 | #define CSKY_ISA_FEATURE_DEFINE(x) isa_bit_ ## x | ^~~~~~~~ ../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE' 30 | #define CSKY_ISA_FEATURE_GET(x) CSKY_ISA_FEATURE_DEFINE (x) | ^~~~~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/config/csky/csky.cc:6346:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET' 6346 | || CSKY_ISA_FEATURE_GET(fpv2_df) | ^~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context] 29 | #define CSKY_ISA_FEATURE_DEFINE(x) isa_bit_ ## x | ^~~~~~~~ ../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE' 30 | #define CSKY_ISA_FEATURE_GET(x) CSKY_ISA_FEATURE_DEFINE (x) | ^~~~~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/config/csky/csky.cc:6346:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET' 6346 | || CSKY_ISA_FEATURE_GET(fpv2_df) | ^~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context] 29 | #define CSKY_ISA_FEATURE_DEFINE(x) isa_bit_ ## x | ^~~~~~~~ ../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE' 30 | #define CSKY_ISA_FEATURE_GET(x) CSKY_ISA_FEATURE_DEFINE (x) | ^~~~~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/config/csky/csky.cc:6347:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET' 6347 | || CSKY_ISA_FEATURE_GET(fpv2_divd))) | ^~~~~~~~~~~~~~~~~~~~ The 'CSKY_ISA_FEATURE_DEFINE (x)' is an enum contant, it will cause the condition always being true. In addition to warning, it will let FPUV3 to generate a move instruction, which is unnecessary. In a simple test case, the move instruction can be combined, so it was not found in the testsuite. But in some complex scenarios, this may generate some redundant instructions. The correct way is to use 'CSKY_ISA_FEATURE' instead of 'CSKY_ISA_FEATURE_DEFINE'. gcc/ * config/csky/csky.cc (csky_emit_compare_float): Fix the expanding of float LE comparing with zero for fpuv3. * config/csky/csky.h (TARGET_SUPPORT_FPV2): New, true if any fpuv2 features are enabled. --- gcc/config/csky/csky.cc | 4 +--- gcc/config/csky/csky.h | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/config/csky/csky.cc b/gcc/config/csky/csky.cc index a7dc6cefead..4dc74d8924f 100644 --- a/gcc/config/csky/csky.cc +++ b/gcc/config/csky/csky.cc @@ -6342,9 +6342,7 @@ csky_emit_compare_float (enum rtx_code code, rtx op0, rtx op1) case GT: case LT: case LE: - if (op1 == CONST0_RTX (mode) && (CSKY_ISA_FEATURE_GET(fpv2_sf) - || CSKY_ISA_FEATURE_GET(fpv2_df) - || CSKY_ISA_FEATURE_GET(fpv2_divd))) + if (op1 == CONST0_RTX (mode) && TARGET_SUPPORT_FPV2) op1 = force_reg (mode, op1); break; case ORDERED: diff --git a/gcc/config/csky/csky.h b/gcc/config/csky/csky.h index 37410f0cda4..f786ad55d43 100644 --- a/gcc/config/csky/csky.h +++ b/gcc/config/csky/csky.h @@ -165,6 +165,10 @@ || CSKY_ISA_FEATURE (fpv3_sf) \ || CSKY_ISA_FEATURE (fpv3_df)) +#define TARGET_SUPPORT_FPV2 (CSKY_ISA_FEATURE(fpv2_sf) \ + || CSKY_ISA_FEATURE(fpv2_df) \ + || CSKY_ISA_FEATURE(fpv2_divd)) + /* Number of loads/stores handled by ldm/stm. */ #define CSKY_MIN_MULTIPLE_STLD 3 #define CSKY_MAX_MULTIPLE_STLD 12