From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ujaHJtm3jWHjSwAAWB0awg (envelope-from ) for ; Thu, 11 Nov 2021 19:39:53 -0500 Received: by simark.ca (Postfix, from userid 112) id 8D4F01F0BD; Thu, 11 Nov 2021 19:39:53 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2757B1E813 for ; Thu, 11 Nov 2021 19:39:53 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 33AFD385843D for ; Fri, 12 Nov 2021 00:39:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 33AFD385843D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1636677592; bh=4584KWxm4bqfU8/PbqfLss4trz77gMFutdkI70AZ+9Q=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WkmZ+9ZH0fPRAl8OeztL8K4UvT3OxxuMdqAcoabtF8LQ5ZyM5EeGT2audlNjVcJDU pODtecwc7I2XQEHRAC1qF+etL6vSj+dFuQmk6Mxh2CVosFvPaKRC5iN+py2z7neNPT mq3f/IY8CZuhBqFWuCN978Gv6Y+0F/osrkqVFYxM= Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 1BD7C3858D28 for ; Fri, 12 Nov 2021 00:39:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1BD7C3858D28 Received: by smtp.gentoo.org (Postfix, from userid 559) id 3DEDF3430B3; Fri, 12 Nov 2021 00:39:31 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH 1/2] sim: sh: rework carry checks to not rely on integer overflows Date: Thu, 11 Nov 2021 19:39:32 -0500 Message-Id: <20211112003933.3612-1-vapier@gentoo.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <68a4c7ee-700a-22f5-62ad-9257de03e9f9@linaro.org> References: <68a4c7ee-700a-22f5-62ad-9257de03e9f9@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mike Frysinger via Gdb-patches Reply-To: Mike Frysinger Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" In <=gcc-7 versions, -fstrict-overflow is enabled by default, and that triggers warnings in this code that relies on integer overflows to test for carries. Change the logic to test against the limit directly. --- sim/sh/gencode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c index 80eecfdf1d36..5eb7caf25893 100644 --- a/sim/sh/gencode.c +++ b/sim/sh/gencode.c @@ -2266,7 +2266,7 @@ op ppi_tab[] = "int Sx_grd = GET_DSP_GRD (x);", "", "res = Sx - 0x10000;", - "carry = res > Sx;", + "carry = Sx < (INT_MIN + 0x10000);", "res_grd = Sx_grd - carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", @@ -2277,7 +2277,7 @@ op ppi_tab[] = "int Sx_grd = GET_DSP_GRD (x);", "", "res = Sx + 0x10000;", - "carry = res < Sx;", + "carry = Sx > (INT_MAX - 0x10000);", "res_grd = Sx_grd + carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", @@ -2288,7 +2288,7 @@ op ppi_tab[] = "int Sy_grd = SIGN32 (Sy);", "", "res = Sy - 0x10000;", - "carry = res > Sy;", + "carry = Sy < (INT_MIN + 0x10000);", "res_grd = Sy_grd - carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", @@ -2299,7 +2299,7 @@ op ppi_tab[] = "int Sy_grd = SIGN32 (Sy);", "", "res = Sy + 0x10000;", - "carry = res < Sy;", + "carry = Sy > (INT_MAX - 0x10000);", "res_grd = Sy_grd + carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", -- 2.33.0