From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8E94A3959C85; Tue, 6 Dec 2022 07:51:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E94A3959C85 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670313071; bh=kZy/BvntC89qKH6DTtltLD2i9ln237HfPe9aZ8f6S5I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fNm6L81D+NGMH9wnKRMQqVOXABE7Wugrrbbit+UAlna+SasF9r9/QxRZxyS1DjgBD Mawnwmwg6bEXEZsacbSCHTtxUX7tOy17t4mHTjhKGUFsYNUE5Oge42WfxQPCVKO/HY U7NgdZCQSJLOFwEEN8QNaDtdKyBg78mgoFsgRjg8= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107986] [12/13 Regression] Bogus -Warray-bounds diagnostic with std::sort Date: Tue, 06 Dec 2022 07:51:11 +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.2.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal 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: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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=3D107986 --- Comment #2 from Andrew Pinski --- (In reply to Richard Biener from comment #1) >=20 > void bar (); > void foo (int *a) > { > int qa =3D 0; > for (int i =3D 0; i < 3; i++) > if (a[i]) > a[qa++] =3D 0; > if (qa > 3) > bar (); > } >=20 > where we should be able to eliminate the call to bar (). What is interesting is we can optimize away the call to bar in this slightly modified case during vrp2: void bar (); bool cond; void foo (int *a) { int qa =3D 0; for (int i =3D 0; i < 3; i++) if (cond) a[qa++] =3D 0; if (qa > 3) bar (); } But I don't see why having the load inside the loop would make a difference ....=