From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1CDDE3858431; Fri, 11 Nov 2022 07:47:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1CDDE3858431 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668152858; bh=JYf92u0Xghh9C7O7P+Av6WMbTKxsWV7qdzTuQF8PZ3Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=yF1LnVOUvHV4HB1SZfeDjYzyVYralfQSFhjkBe869ZYZR1usMe4/ldKWhVNnOvfAT JW3lZ5kwnLY/P8uvOmdMJnOSdKNqi9l8ZKLf084k6y3037ZfXyen/L7tytOy5tYjPF r2neeMQCd37T0YQsbA+XAcW35J64YlWL6ptc+BJE= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107618] Incorrect diagnostics when using -Og, builtin_expect(), and function attribute "warning" or "error" Date: Fri, 11 Nov 2022 07:47:37 +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: 13.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status version assigned_to cf_reconfirmed_on keywords component everconfirmed 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=3D107618 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Version|unknown |13.0 Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot = gnu.org Last reconfirmed| |2022-11-11 Keywords| |diagnostic Component|middle-end |tree-optimization Ever confirmed|0 |1 --- Comment #3 from Richard Biener --- We diagnose because we see int main () { long int _2; [local count: 1073741824]: _2 =3D 0; if (_2 !=3D 0) goto ; [10.00%] else goto ; [90.00%] [local count: 107374184]: a (); [local count: 1073741824]: return 0; } and the reason is that for some reason /* Copy propagation also copy-propagates constants, this is necessary to forward object-size and builtin folding results properly. */ NEXT_PASS (pass_copy_prop); doesn't work: --- a-t2.c.224t.strlen2 2022-11-11 08:44:14.044322291 +0100 +++ a-t2.c.225t.copyprop5 2022-11-11 08:44:14.044322291 +0100 ... [local count: 1073741824]: b_5 =3D __builtin_object_size (0B, 0); - _1 =3D 0; - _2 =3D (long int) _1; + _2 =3D 0; if (_2 !=3D 0) goto ; [10.00%] else I will have a look.=