From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0A5BC3858C5E; Wed, 26 Apr 2023 06:36:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A5BC3858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682491006; bh=uJoJsnFjRLJ06g06VLj5+5LqTmF278knxJsDuk9FzOY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=knUWvtbucS0VS+FxMFwCVfAAIjDmKQzGD8y3hH8rHUiKdiXzIdrLEQo67JrWEdiiE oP9uoMjN07K2jhQjjQp0NCNRpExBlu/F0IJce/hV+OGyrwP4PIwQMnEMPSTPNAyYH5 xxkGXBZFeHIClBsEK+p8cCV+xXYKHGzXjGcCwzbU= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109626] forwprop introduces new signed multiplication UB Date: Wed, 26 Apr 2023 06:36:45 +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: 13.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords 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=3D109626 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code --- Comment #1 from Richard Biener --- We apply from match.pd (-A) * (-B) -> A * B and -(A - B) -> B - A where there are no constraints on overflow present for these patterns. We go (int) (v2_6(D) - _2) * (int) - v1_5(D) -> (int) (- (v2_6(D) - _2)) * (int) v1_5(D) -> (int) (_2 - v2_6(D)) * (int) v1_5(D) I think the issue must be in (-A) * (-B) -> A * B, but I can't quite nail i= t. To result in -1 * INT_MIN we'd have to come from 1 * INT_MIN but then the negation of INT_MIN would already be problematic.=