From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DFBF13858D28; Fri, 4 Feb 2022 07:08:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFBF13858D28 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104356] [12 Regression] divide by zero trap incorrectly optimized away Date: Fri, 04 Feb 2022 07:08:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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, 04 Feb 2022 07:08:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104356 --- Comment #40 from rguenther at suse dot de --- On Thu, 3 Feb 2022, amacleod at redhat dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104356 >=20 > --- Comment #37 from Andrew Macleod --- > (In reply to Jakub Jelinek from comment #35) > > I meant something like: > > return Z / X; >=20 > > and there evrp does with -O2 -gnatp optimize away the division. > > Though that is likely the X / boolean_range_Y case which you've disable= d. > > In any case, I think you want to hear from Andrew/Aldy where exactly do= es > > VRP/ranger assume UB on integer division by zero. >=20 > That divide is remove by the simplifier because it determines that X has a > range of [0,1] and I believe the simplifer chooses to ignore the 0 under > various circumstances. >=20 > As for ranger, range-ops will return UNDEFINED for the range if x is know= n to > be [0,0]. This can be propagated around, and depending on how it ends up= being > used as to what happens with it.=20 I think that's OK as outgoing range (on the non-exceptional path - on the exeptional path the result isn't computed). That just may not be used to simplify the stmt producing the range itself of course.=