From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8ABC43858D39; Tue, 10 Oct 2023 08:26:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8ABC43858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696926378; bh=J6wEDA68abVaYtUzDuPO3iN5CovQzeanpmzig5s+Zdc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cWpZ/Vi+64X32ArME41WSxFmwA1AnO8+7gulFYTrAlDRNAUqYIgR5Ivds6l7fXM7A 0l45U88gAtoYiPYhBFaKCvmD/RMCxvCkdso+we5f4P1RLgIkmP2Xbk57DYtbqgPWNk PHy7S9WIjNQGYE5sBSLIGGD2c5+1tdKinMSPn8hk= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111519] [13/14 Regression] Wrong code at -O3 on x86_64-linux-gnu since r13-455-g1fe04c497d Date: Tue, 10 Oct 2023 08:26:17 +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: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.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=3D111519 --- Comment #5 from Richard Biener --- Reverting @@ -5089,8 +5123,9 @@ strlen_pass::handle_store (bool *zero_write) return false; } - if (storing_all_zeros_p - || storing_nonzero_p + if (storing_nonzero_p + || storing_all_zeros_p + || (full_string_p && lenrange[1] =3D=3D 0) || (offset !=3D 0 && store_before_nul[1] > 0)) { /* When STORING_NONZERO_P, we know that the string will start fixes the issue. We somehow compute a lenrange of { 0, 0, 1 } for d =3D _8 but also set storing_all_zeros_p to false. It seems that strlen_pass::count_nonzero_bytes happily skips intermediate stores when it handles SSA names here: gimple *stmt =3D SSA_NAME_DEF_STMT (exp); if (gimple_assign_single_p (stmt)) { exp =3D gimple_assign_rhs1 (stmt); if (!DECL_P (exp) && TREE_CODE (exp) !=3D CONSTRUCTOR && TREE_CODE (exp) !=3D MEM_REF) return false; /* Handle DECLs, CONSTRUCTOR and MEM_REF below. */ we have _8 =3D *_7; ... *_7 =3D prephitmp_89; d =3D _8; when we recursively process a memory reference we need to verify there are no intermediate aliases, the simplest thing would be to pass down a virtual use. Trying some prototype.=