From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 510BF3858C50; Mon, 4 Mar 2024 09:36:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 510BF3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709545001; bh=uhq+E5cEKWS+lALbBcqR93O/XcxFybynPCuwZ0MOQGs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ys4RG2/xgVykiitYgFP+KwVbhoLNY7l4ioOC+M52OJ7KPDrbWAlaJsALB8DT9Xq0i 1XquG2CE3V3DmRqI3I4C3K/CIA4Iaty5I2yO6xtDazxBGqzkDIayQXhQFKWfWoetJt zG3mX5ZHMZ2cFM99tb3x8veo9BVqiOmrcOtsZkLM= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114203] [13/14 Regression] Miscompilation: A possible miscompilation in GCC 13 and 14 with option -Os Date: Mon, 04 Mar 2024 09:36:40 +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: needs-bisection, wrong-code 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: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to bug_status 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=3D114203 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot = gnu.org Status|NEW |ASSIGNED --- Comment #2 from Richard Biener --- (set_nb_iterations_in_loop =3D b_3(D) !=3D 0 ? (unsigned int) (32 - __bui= ltin_clz ((unsigned int) b_3(D))) : 24)) The issue is for prec <=3D i_prec we do call =3D build_call_expr (fn, 1, src); if (define_at_zero) { tree is_zero =3D fold_build2 (NE_EXPR, boolean_type_node, src, build_zero_cst (TREE_TYPE (src))); call =3D fold_build3 (COND_EXPR, integer_type_node, is_zero, call, build_int_cst (integer_type_node, prec)); } if (leading && prec < i_prec) call =3D fold_build2 (MINUS_EXPR, integer_type_node, call, build_int_cst (integer_type_node, i_prec - prec= )); but that's the wrong way around, 'define_at_zero' should happen after the adjustment for leading.=