From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5BF283858D39; Tue, 26 Oct 2021 15:24:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5BF283858D39 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102951] New: failure to optimize MIN_EXPR of subobject addresses of the same object Date: Tue, 26 Oct 2021 15:24:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Tue, 26 Oct 2021 15:24:15 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102951 Bug ID: 102951 Summary: failure to optimize MIN_EXPR of subobject addresses of the same object Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- GCC fails to fold the MIN_EXPR below to the lower address. The test case affects C because the C front end emits a MIN_EXPR but not C++ because the = C++ front end emits an if statement. $ cat z.c && gcc -O2 -S -Wall -fdump-tree-optimized=3D/dev/stdout z.c extern int a[]; void f (void) { int *p1 =3D &a[1]; int *p2 =3D &a[2]; int *d =3D p1 < p2 ? p1 : p2; *d =3D 0; } ;; Function f (f, funcdef_no=3D0, decl_uid=3D1979, cgraph_uid=3D1, symbol_o= rder=3D0) void f () { int * d; [local count: 1073741824]: d_1 =3D MIN_EXPR <&a[2], &a[1]>; // the two statements can be folded in= to *d_1 =3D 0; // MEM[(int *)&a + 4B] =3D 0 return; }=