From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 51E0B3858CDA; Sat, 2 Sep 2023 20:02:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51E0B3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693684973; bh=Dx8yoYIW3SLWIDPg4C1me8GUHSXm4cH/XMhp50BeGDw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fTW8yCiX2Gcb67S1da/1DuQZhNSOcObTo1lVlFs1S7qB0smNDvhijvUqNV3/+XARI bDtWr2yoAM9mZTv5Zi0ZIXVp7TrnnuL9nCwwZnHMEsI9g9cJAMFL7oKQQpjrhiO3Jp vHyWmqPHRuQwSSUdcAna9KKp02/QBCmxW4UL3v+4= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/104986] [12/13/14 Regression] bogus writing 1 byte into a region of size 0 with -fwrapv and -O2 -fpeel-loops since r12-4698-gf6d012338bf87f42 Date: Sat, 02 Sep 2023 20:02:51 +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: 12.0 X-Bugzilla-Keywords: diagnostic, missed-optimization, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords cf_known_to_work 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104986 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |needs-bisection Known to work| |13.1.0 --- Comment #13 from Andrew Pinski --- Looks like SCEV can figure out the bounds more correctly in GCC 13+ which f= ixes the warning and the missed optimization. GCC 12.3.0: ``` Estimating # of iterations of loop 1 Matching expression match.pd:2119, generic-match.cc:693 Matching expression match.pd:2122, generic-match.cc:753 Matching expression match.pd:2129, generic-match.cc:776 Analyzing # of iterations of loop 1 exit condition [prephitmp_30, + , -1] !=3D 0 bounds on difference of bases: -5 ... 1 Applying pattern match.pd:182, generic-match.cc:30997 Applying pattern match.pd:5698, generic-match.cc:11425 Matching expression match.pd:2119, generic-match.cc:693 Matching expression match.pd:2122, generic-match.cc:753 Matching expression match.pd:2129, generic-match.cc:776 Applying pattern match.pd:354, generic-match.cc:5780 result: # of iterations (unsigned int) prephitmp_30, bounded by 4294967295 Statement (exit)if (nb_24 !=3D 0) is executed at most (unsigned int) prephitmp_30 (bounded by 4294967295) + 1 times in loop 1. ``` While GCC 13+: ``` Estimating # of iterations of loop 1 Matching expression match.pd:2404, generic-match.cc:727 Matching expression match.pd:2407, generic-match.cc:787 Matching expression match.pd:2414, generic-match.cc:810 Analyzing # of iterations of loop 1 exit condition [prephitmp_30, + , -1] !=3D 0 bounds on difference of bases: -5 ... 0 Applying pattern match.pd:182, generic-match.cc:33250 Applying pattern match.pd:6155, generic-match.cc:21253 Matching expression match.pd:2404, generic-match.cc:727 Matching expression match.pd:2407, generic-match.cc:787 Matching expression match.pd:2414, generic-match.cc:810 Applying pattern match.pd:365, generic-match.cc:21998 result: # of iterations (unsigned int) prephitmp_30, bounded by 5 Statement (exit)if (nb_24 !=3D 0) is executed at most (unsigned int) prephitmp_30 (bounded by 5) + 1 times in loop 1. ```=