From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DA581385141D; Fri, 20 Aug 2021 08:45:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA581385141D From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101991] bit_and or bit_ior with an invariant inside loop is not pulled out of the loop Date: Fri, 20 Aug 2021 08:45:48 +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: missed-optimization X-Bugzilla-Severity: enhancement 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: bug_status everconfirmed 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 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, 20 Aug 2021 08:45:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101991 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2021-08-20 --- Comment #1 from Richard Biener --- [local count: 955630225]: # r_11 =3D PHI r_8 =3D e_7(D) & r_11; I wonder if this is sth for phiopt to pattern match. In principle VN would need to figure (for PRE) that the PHI translated d_3(D) & e_7(D) is equal to r_8. So the "trick" (aka pattern-matching) could be done during phi_translation. But then both look like a hack. Curiously when we do int f(int t, int d, int e) { int r =3D d & e; for(int i =3D 0; i < t; i++) r &=3D e; return r; } aka "peel" one iteration, then CCP is what eliminates the in-loop AND. Ah, that's because we simplify d & e & e since we optimistically start with just the entry edge value. And that remains so. With PRE we're not fully re-doing VN of PHIs but phi-translation seeks to re-use existing value-numbers where possible, so a programmatic approach doesn't work here.=