From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0AD063851C21; Fri, 26 Jun 2020 08:56:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AD063851C21 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593161806; bh=65Ap2qYeKtus0GVCR2EldoawWgxA9dvDwxv4UjW3npA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Jpb1irg2H6puZcHiHJSjQNj6+Og24gf2aBFSxMGP/ObyDqltquYRnpfqYIpQIz6ES TDZAkvaPKFMKwHer9ybAc01gsW4RKtz9JPweHOolhzwTq4gx4znT329iZdRVfu5uwM GUxotxaxsMN57XuSwh48BLEyb8Ke0Yf0FOWOTk+4= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/95903] gcc 10: wrong code with -fwrapv Date: Fri, 26 Jun 2020 08:56:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Jun 2020 08:56:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95903 --- Comment #5 from Jakub Jelinek --- Created attachment 48788 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D48788&action=3Dedit gcc11-pr95903.patch Untested fix. I don't really care what clang generates or what you find expected on ilp32 targets, what matters is if what GCC generates is fast, a= nd unless somebody finds a wrong-code issue with that, it doesn't need to be changed. For the lp64 case, I can imagine a testcase, though it will be pretty rare = in practice and we need to slow down -fwrapv generated code because of that (i= sn't e.g. Linux kernel built with -fwrapv?), just don't want to add it into the testsuite as that would require allocating at least 4GB of memory. On the other side, on: extern char arr[]; char baz (int off) { off +=3D 1; return arr[off]; } char qux (int off) { return arr[off + 1]; } we do generate the addition and then sign extension, and we should not, bec= ause we would get better code otherwise. arr[INT_MIN] is in this case certainly invalid. But that is about different code.=