From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 05BE33858D28; Tue, 11 Apr 2023 12:16:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05BE33858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681215411; bh=4U8YCIrNyO2G4EeC2yQdQ3woVAJt81xWXm+Vv9jUPCE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=t3H/mTPr/+GKLqNeUi/S0Z65jK1grO4oyCIVzuOo2cFhpp9VhqwuZE8nSO0QDSlS4 3ot7UUdGuDofHru0uMgeHS51/vuWvIzQ6Fiuggia7hSSaGEch7aOqhpnYdCnrVKxPF COZXGx685KtKrPKA0OxEwon/VgSY+YLIYjV2ej/8= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/109393] Very trivial address calculation does not fold Date: Tue, 11 Apr 2023 12:16:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: component bug_status cf_reconfirmed_on everconfirmed 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=3D109393 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Component|tree-optimization |c Status|UNCONFIRMED |NEW Last reconfirmed| |2023-04-11 Ever confirmed|0 |1 --- Comment #3 from Richard Biener --- It's probably a mismatch of GENERIC/GIMPLE folding. In this case it's pointer_int_sum prematurely distributing the multiplication: /* Return a tree for the sum or difference (RESULTCODE says which) of pointer PTROP and integer INTOP. */ tree=20=20 pointer_int_sum (location_t loc, enum tree_code resultcode, tree ptrop, tree intop, bool complain) {=20=20=20=20=20 ... /* If what we are about to multiply by the size of the elements contains a constant term, apply distributive law and multiply that constant term separately. This helps produce common subexpressions. */ but this kind of stuff shouldn't be done by the frontends these days. Gating this fixes the issue. I think this piece of code should be axed (after careful evaluation of its effect)=