From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 02FAE3858D32; Sun, 14 Aug 2022 16:28:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02FAE3858D32 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106615] redundant load and store introduced in if-true-branch Date: Sun, 14 Aug 2022 16:28:00 +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.1.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: everconfirmed keywords cf_reconfirmed_on bug_status bug_severity 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: Sun, 14 Aug 2022 16:28:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106615 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Keywords| |missed-optimization Last reconfirmed| |2022-08-14 Status|UNCONFIRMED |NEW Severity|normal |enhancement --- Comment #1 from Andrew Pinski --- Reduced testcase: int g_44; void func_16(int *a, unsigned long int b) { *a =3D 5; if ((g_44 =3D 1) <=3D b) ; else *a =3D 0; } ---- CUT ---- So CSElim on the gimple level goes from: *a_3(D) =3D 5; g_44 =3D 1; if (b_6(D) !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 536870913]: *a_3(D) =3D 0; [local count: 1073741824]: return; to: *a_3(D) =3D 5; g_44 =3D 1; if (b_6(D) !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 536870912]: cstore_8 =3D MEM [(void *)a_3(D)]; [local count: 1073741824]: # cstore_9 =3D PHI MEM [(void *)a_3(D)] =3D cstore_9; Thinking it might be able to remove the load inside the if branch (for an example at -O2 with 1 instead of 5, GCC can remove the load). And then nothing afterwards will undo that transformation.=