From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2EA8A3858439; Sun, 8 Oct 2023 04:00:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2EA8A3858439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696737608; bh=Pp7ChsFwi1wSkwYCz6AjzGGECfKtSbKL8KMhZvJPc6w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iKAdWHFwRxjJzdBgGR+URipxznzfMV5kec3dAeARMblX0qhvdN3uL+IsA44vjnRzQ yxtY+rAGlIgwNjihKz0rJ9vEI+ecvahtT7QcFhRBWs3hYgQlS+FloIrHTcHFtTXWAx PIrH20fuBJWTwZRaPYRhDlrS7HBZeKD/mHjT1ueE= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111718] Missed optimization of '(a+a)/a' Date: Sun, 08 Oct 2023 04:00:07 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia 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: bug_severity everconfirmed bug_status keywords cf_reconfirmed_on 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=3D111718 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Keywords| |missed-optimization Last reconfirmed| |2023-10-08 --- Comment #4 from Andrew Pinski --- (In reply to Andrew Pinski from comment #3) > For comment #2 from EVRP: > Folding statement: _3 =3D _2 / a_5(D); > Applying pattern match.pd:934, gimple-match-4.cc:2021 > gimple_simplified to _3 =3D 2; >=20 > Which corresponds to the match pattern: > /* Simplify (t * 2) / 2) -> t. */ > (for div (trunc_div ceil_div floor_div round_div exact_div) > (simplify > (div (mult:c @0 @1) @1) > (if (ANY_INTEGRAL_TYPE_P (type)) > (if (TYPE_OVERFLOW_UNDEFINED (type)) > @0 > #if GIMPLE > (with {value_range vr0, vr1;} > (if (INTEGRAL_TYPE_P (type) > && get_range_query (cfun)->range_of_expr (vr0, @0) > && get_range_query (cfun)->range_of_expr (vr1, @1) > && range_op_handler (MULT_EXPR).overflow_free_p (vr0, vr1)) > @0)) > #endif > )))) Which was improved on the trunk by r14-4082-g55b22a6f630e (and then by r14-4191-gd946fc1c71bd). I don't know why the original testcase is not caus= ing the above pattern to match though, maybe because a*2 is used twice ...=