From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 45162385842A; Fri, 16 Feb 2024 08:20:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45162385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708071616; bh=vpMowFsc0+L+HANh9YUhgKedGjYAMgrCoG6HB7fbqNM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=i6nCH5/KX9wT51PtgnlLcLvwMbLqkSFSS7f7k3EDNXn1i5zfFLDNvieUpvDCGM+PO r3R8R6rMGtpkS3V6VeisyZ0UzMtjsw97vM0NzZIDHNmHU6GNSsAE8Bu2nH2DlZk5hY fCC66teloR+xeICMlSLJXub3bBI4h3rkIshbXuIw= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112508] [14 Regression] Size regression when using -Os starting with r14-4089-gd45ddc2c04e Date: Fri, 16 Feb 2024 08:20:08 +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: missed-optimization X-Bugzilla-Severity: normal 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: 14.0 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=3D112508 --- Comment #4 from Richard Biener --- We are already doing /* Verify whether the candidate is hot for LOOP. Only do store motion if= the candidate's profile count is hot. Statement in cold BB shouldn't be mo= ved out of it's loop_father. */ if (!for_all_locs_in_loop (loop, ref, ref_in_loop_hot_body (loop))) return false; but /* Check the coldest loop between loop L and innermost loop. If there is o= ne cold loop between L and INNER_LOOP, store motion can be performed, other= wise no cold loop means no store motion. get_coldest_out_loop also handles c= ases when l is inner_loop. */ bool ref_in_loop_hot_body::operator () (mem_ref_loc *loc) { basic_block curr_bb =3D gimple_bb (loc->stmt); class loop *inner_loop =3D curr_bb->loop_father; return get_coldest_out_loop (l, inner_loop, curr_bb); } checks that there's a good place to move a store to but it doesn't verify whether there's a store that's likely to be executed in its contained loop. The for_all_locs_in_loop is also happy if _any_ of the stores for the var can be moved to a colder place, likely the intent was to check that for all of the stores (though it's unlikely to differ in simple cases). This all doesn't distinguish between always and not always executed refs.=