Fix 'gcc.dg/tree-ssa/return-value-range-1.c' for 'char' defaulting to 'unsigned' (was: Propagate value ranges of return values)
Message ID | 87r0kiu7f3.fsf@euler.schwinge.homeip.net |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp923519vqb; Tue, 21 Nov 2023 13:24:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFD+TElXE4kSYUiCHktLXtSQw+nc1Zxb/TtR/cw5q2CLktTXtR1OGyN0RVhJtQMtgWOlati X-Received: by 2002:ac8:5d05:0:b0:41c:b9b6:ec11 with SMTP id f5-20020ac85d05000000b0041cb9b6ec11mr489533qtx.3.1700601873513; Tue, 21 Nov 2023 13:24:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700601873; cv=pass; d=google.com; s=arc-20160816; b=yIfcuOdVUu1M4Kj2GTXpwPox2GnyL/nUIiAL/U0pIGoJ+hff82jiyyw6Ol4wefFPW0 qd2EGXTu0/Zq7+XI28tIHewtTN/RUMIyFhWdTY4NIfCMld9XAlNQqIVKMnScyw8UopO7 xZzdkMYC0SXAE0m88JzcsGpM7307xkr+qBZkAxMgM9jqt7j25U3kpka+yPtXiPwR9+hu OHSI4tFbr+iUx+VtTvMwkKJ6yryxDdz7/HwzKPM/C2/VhLjpOyKHNWxggfgBBEblYgE0 5ooKo6eXbiMUVx7ZLR2nUeuSBsXnr0gTyPwERSeGkZjRlkwTZ/IzsJsTt9iKccVHyEzA 0RdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date :user-agent:references:in-reply-to:subject:to:from:ironport-sdr :arc-filter:dmarc-filter:delivered-to; bh=+kRCgHnAazp7SnAlqmNdzZiWma+bzsPNVTXKMO1UqJ4=; fh=eFkiSZLWwt6NUk89P52s4KbBpZ86lKHrs6ztijECvfM=; b=cgc7qwX485G9qAStcswgvMlrO5ZOLSF9HZIYnSchFu21EtcBVCyZOehWyO5nO3rHfj Guyx1OYCSykIJG/cBPOGiactuFFry5rZs83+lRxP4qA04l0S6aSSWkwixpyCwPhUH5dU kUSUYXF3MdWezKDBe/x+PGc/nWTDg26O0xBHY2FEoa44iDOVPxU0LRKxA2i2ow7+34Rr 4p7wE7xAanq/1ZNsBDB4MOY9XoWDFILvtovIo68LZ6u8VwdTamkBDCrrvZkySSwSdL2p EFWBRDNnkmf6lYx/JSVXb3zqltrpwH1wZ117RBH2Bw2Ga5ppo8puEtGz1WzcwaaBOTKw MONQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n10-20020a05622a040a00b00421f6bb9818si9483637qtx.194.2023.11.21.13.24.33 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 13:24:33 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2D1713858C30 for <ouuuleilei@gmail.com>; Tue, 21 Nov 2023 21:24:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id E1D9D3858D33 for <gcc-patches@gcc.gnu.org>; Tue, 21 Nov 2023 21:24:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E1D9D3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E1D9D3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.129.153 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700601850; cv=none; b=YWov6SrxkhKuRF/dkx+JjUuQvnYMj8T8vGkLppy+n+2vFS5hMBeb9Jz499BaXR2Pgpkq9ZmwYHvbJ9qkDcOawhdbIz0XzISTIJDqOUtLRMSbG5MmvB23LqiQ6CuNC7JAF8Ck6hDeU2+zJ8/+ZdHRyotA7naFwIBvqv9Keuz1YBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700601850; c=relaxed/simple; bh=evgsei/Faf9lgx+JTg1QXtigTnRzZZZGroFnQbv86xk=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=fRgziFt2wy3p8kpUFwP6llwIb9AjGdzYEQ887HI0V9X2x8Qc/GaKcKmWk4Ki9AbnjNh0+An7ptSNQ3Gj+vRTMzzAsYvcxAoLLvRG585K2rcHKk7AVTc1m5hrdErxHIF70bxKJ9m5YDAYtlLCmhaXgl6F8Pcckh+mRoKOgUddkaM= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: zS/EH7dbTgmtlhUq2KqdEQ== X-CSE-MsgGUID: TUKwjcMuRwuYjn8v6abePA== X-IronPort-AV: E=Sophos;i="6.04,216,1695715200"; d="scan'208,223";a="26425730" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 21 Nov 2023 13:24:07 -0800 IronPort-SDR: +YU0Oy+xX/ObKAG0klbppx9aBPm1eHyyqBB1ZkpSyqRM4sEmL7MLM7+N9WeJIy86wJDXtV0viQ mZf1YtwKle+5q8Mhysqx26ZIs4UdYKXeXIi5zIKMRRMBLczcz2aWrZxQZ11SKhStJ+tVN38/pK lAAo0jItOLGr0DKEpJVBT1+SFAETzOBtg/PWnY9ChIosRvzQMBkcCVAJGq4E9CztRfa+pttL3c ttkRqAKkK2JHYdLJx7aVIV5NHqtpkWrbji+syez/rnqNrejEZrB40cz5Dr5A0GThPspMRimkKg uQw= From: Thomas Schwinge <thomas@codesourcery.com> To: Jan Hubicka <hubicka@ucw.cz>, <gcc-patches@gcc.gnu.org> Subject: Fix 'gcc.dg/tree-ssa/return-value-range-1.c' for 'char' defaulting to 'unsigned' (was: Propagate value ranges of return values) In-Reply-To: <ZVokRs1zL7NY5cVe@kam.mff.cuni.cz> References: <ZVljEevbGcssSuh8@kam.mff.cuni.cz> <871qcmkmgd.fsf@gentoo.org> <ZVocLAJnye+K0oh4@kam.mff.cuni.cz> <ZVokRs1zL7NY5cVe@kam.mff.cuni.cz> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Tue, 21 Nov 2023 22:24:00 +0100 Message-ID: <87r0kiu7f3.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, 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 server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783210310104850291 X-GMAIL-MSGID: 1783210310104850291 |
Series |
Fix 'gcc.dg/tree-ssa/return-value-range-1.c' for 'char' defaulting to 'unsigned' (was: Propagate value ranges of return values)
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Thomas Schwinge
Nov. 21, 2023, 9:24 p.m. UTC
Hi! On 2023-11-19T16:05:42+0100, Jan Hubicka <hubicka@ucw.cz> wrote: > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/return-value-range-1.c Pushed to master branch commit a0240662b22312ffb3e3fefb85f258ab0e7010f4 "Fix 'gcc.dg/tree-ssa/return-value-range-1.c' for 'char' defaulting to 'unsigned'", see attached. On powerpc64le-linux-gnu ('char' defaulting to 'unsigned') I still saw: /tmp/ccd1xwD7.o: In function `test': return-value-range-1.c:(.text+0x50): undefined reference to `link_error' Grüße Thomas > @@ -0,0 +1,22 @@ > +/* { dg-do ling } */ > +/* { dg-options "-O1 -dump-tree-evrp-details" } */ > +__attribute__ ((__noinline__)) > +int a(char c) > +{ > + return c; > +} > +void link_error (); > + > +void > +test(int d) > +{ > + if (a(d) > 200) > + link_error (); > +} > +int > +main(int argc, char **argv) > +{ > + test(argc); > + return 0; > +} > +/* { dg-final { scan-tree-dump-times "Recording return range" 2 "evrp"} } */ ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
Comments
Hi! On Tue, 21 Nov 2023 at 22:24, Thomas Schwinge <thomas@codesourcery.com> wrote: > > Hi! > > On 2023-11-19T16:05:42+0100, Jan Hubicka <hubicka@ucw.cz> wrote: > > --- /dev/null > > +++ b/gcc/testsuite/gcc.dg/tree-ssa/return-value-range-1.c > > Pushed to master branch commit a0240662b22312ffb3e3fefb85f258ab0e7010f4 > "Fix 'gcc.dg/tree-ssa/return-value-range-1.c' for 'char' defaulting to > 'unsigned'", see attached. On powerpc64le-linux-gnu ('char' defaulting > to 'unsigned') I still saw: > > /tmp/ccd1xwD7.o: In function `test': > return-value-range-1.c:(.text+0x50): undefined reference to `link_error' > We do see the same error in our CI (Thomas, normally you have received a notification because your patch turned ERROR in FAIL) Thomas, you said in another email that adding -O2 avoids the linker error with missing link_error(), but I don't see how that would be possible? (and hence I expect the error you quoted above to happen) So should we use dg-compile instead of dg-link? Not sure what the original intention was? Thanks, Christophe > > Grüße > Thomas > > > > @@ -0,0 +1,22 @@ > > +/* { dg-do ling } */ > > +/* { dg-options "-O1 -dump-tree-evrp-details" } */ > > +__attribute__ ((__noinline__)) > > +int a(char c) > > +{ > > + return c; > > +} > > +void link_error (); > > + > > +void > > +test(int d) > > +{ > > + if (a(d) > 200) > > + link_error (); > > +} > > +int > > +main(int argc, char **argv) > > +{ > > + test(argc); > > + return 0; > > +} > > +/* { dg-final { scan-tree-dump-times "Recording return range" 2 "evrp"} } */ > > > ----------------- > Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
Hi! On 2023-11-22T11:51:02+0100, Christophe Lyon <christophe.lyon@linaro.org> wrote: > On Tue, 21 Nov 2023 at 22:24, Thomas Schwinge <thomas@codesourcery.com> wrote: >> On 2023-11-19T16:05:42+0100, Jan Hubicka <hubicka@ucw.cz> wrote: >> > --- /dev/null >> > +++ b/gcc/testsuite/gcc.dg/tree-ssa/return-value-range-1.c >> >> Pushed to master branch commit a0240662b22312ffb3e3fefb85f258ab0e7010f4 >> "Fix 'gcc.dg/tree-ssa/return-value-range-1.c' for 'char' defaulting to >> 'unsigned'", see attached. On powerpc64le-linux-gnu ('char' defaulting >> to 'unsigned') I still saw: >> >> /tmp/ccd1xwD7.o: In function `test': >> return-value-range-1.c:(.text+0x50): undefined reference to `link_error' >> > We do see the same error in our CI (Thomas, normally you have received > a notification because your patch turned ERROR in FAIL) Yes, I have; and I even tried to log in there, to point to my commit mentioned above, which is meant to address this issue -- please let me know if you're still seeing the FAIL after that commit. > Thomas, you said in another email that adding -O2 avoids the linker > error with missing link_error(), but I don't see how that would be > possible? That's the gist of Honza's "Propagate value ranges of return values" optimization, per my understanding: from 'int a(signed char c)' doing 'return c;' figure out that 'a(d) > 200)' is always false (due to '-128 <= c <= 127)'. > (and hence I expect the error you quoted above to happen) > > So should we use dg-compile instead of dg-link? Not sure what the > original intention was? No, the idea really is to prove that the 'link_error ()' call is unreachable. Grüße Thomas >> > @@ -0,0 +1,22 @@ >> > +/* { dg-do ling } */ >> > +/* { dg-options "-O1 -dump-tree-evrp-details" } */ >> > +__attribute__ ((__noinline__)) >> > +int a(char c) >> > +{ >> > + return c; >> > +} >> > +void link_error (); >> > + >> > +void >> > +test(int d) >> > +{ >> > + if (a(d) > 200) >> > + link_error (); >> > +} >> > +int >> > +main(int argc, char **argv) >> > +{ >> > + test(argc); >> > + return 0; >> > +} >> > +/* { dg-final { scan-tree-dump-times "Recording return range" 2 "evrp"} } */ ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
From a0240662b22312ffb3e3fefb85f258ab0e7010f4 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <thomas@codesourcery.com> Date: Tue, 21 Nov 2023 22:07:13 +0100 Subject: [PATCH] Fix 'gcc.dg/tree-ssa/return-value-range-1.c' for 'char' defaulting to 'unsigned' ... added in recent commit 53ba8d669550d3a1f809048428b97ca607f95cf5 "inter-procedural value range propagation", fixed in commit 878a860cae78146d98d7a21612f0bcec0930a9c2 "Fix 'gcc.dg/tree-ssa/return-value-range-1.c'". gcc/testsuite/ * gcc.dg/tree-ssa/return-value-range-1.c: Fix. --- gcc/testsuite/gcc.dg/tree-ssa/return-value-range-1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/return-value-range-1.c b/gcc/testsuite/gcc.dg/tree-ssa/return-value-range-1.c index 74f1a5080bb..97294482c05 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/return-value-range-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/return-value-range-1.c @@ -1,7 +1,7 @@ /* { dg-do link } */ /* { dg-options "-O2 -fdump-tree-evrp-details" } */ __attribute__ ((__noinline__)) -int a(char c) +int a(signed char c) { return c; } -- 2.34.1