From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B442D3857C48; Tue, 28 Nov 2023 14:48:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B442D3857C48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701182936; bh=WAoBJTfOON0D+j1HhmavD8L0pgvIxpdP+qQ993VDKIU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qXOSJbNjgcU7+av4T74v9XH9gKEtBl+FhsvrRD4jomeiCYlL1HBJ6qWIVEKnTSQdm yRMwJldmy0usBBhZGxmFMwhdYz/koQu76DMuDrjNfddd7nlbs/NFRvqhAqY6vXS4yg Es+pz5TmyGU/ZBr77+lfsrgDJBsTo0we/gV5BfS4= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/112733] [14 Regression] ICE: Segmentation fault in wide-int.cc during GIMPLE pass: sccp Date: Tue, 28 Nov 2023 14:48:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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: cc 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=3D112733 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rsandifo at gcc dot gnu.org --- Comment #7 from Jakub Jelinek --- On the fold-const.cc side, we IMHO should either do: --- gcc/fold-const.cc.jj 2023-11-28 08:46:28.345803059 +0100 +++ gcc/fold-const.cc 2023-11-28 15:37:28.252327265 +0100 @@ -14563,7 +14563,7 @@ multiple_of_p (tree type, const_tree top && TREE_CODE (op2) =3D=3D INTEGER_CST && integer_pow2p (bottom) && wi::multiple_of_p (wi::to_widest (op2), - wi::to_widest (bottom), UNSIGNED)) + wi::to_widest (bottom), SIGNED)) return true; op1 =3D gimple_assign_rhs1 (stmt); because widest_ints are always signed by definition, or --- gcc/fold-const.cc.jj 2023-11-28 08:46:28.345803059 +0100 +++ gcc/fold-const.cc 2023-11-28 15:43:46.730985893 +0100 @@ -14562,8 +14562,11 @@ multiple_of_p (tree type, const_tree top && (op2 =3D gimple_assign_rhs2 (stmt)) !=3D NULL_TREE && TREE_CODE (op2) =3D=3D INTEGER_CST && integer_pow2p (bottom) - && wi::multiple_of_p (wi::to_widest (op2), - wi::to_widest (bottom), UNSIGNED)) + && wi::multiple_of_p (widest_int::from (wi::to_wide (op2), + UNSIGNED), + widest_int::from (wi::to_wide (bottom), + UNSIGNED), + UNSIGNED)) return true; op1 =3D gimple_assign_rhs1 (stmt); to use widest_int but zero extend there everything, or --- gcc/fold-const.cc.jj 2023-11-28 08:46:28.345803059 +0100 +++ gcc/fold-const.cc 2023-11-28 15:45:35.867445679 +0100 @@ -14562,8 +14562,8 @@ multiple_of_p (tree type, const_tree top && (op2 =3D gimple_assign_rhs2 (stmt)) !=3D NULL_TREE && TREE_CODE (op2) =3D=3D INTEGER_CST && integer_pow2p (bottom) - && wi::multiple_of_p (wi::to_widest (op2), - wi::to_widest (bottom), UNSIGNED)) + && wi::multiple_of_p (wi::to_wide (op2), wi::to_wide (bottom), + TYPE_SIGN (TREE_TYPE (bottom)))) return true; op1 =3D gimple_assign_rhs1 (stmt); The last one has the disadvantage that it would ICE if op2 and bottom don't have same precision (but I'd think it would be caller's screw up if that was the case). Given return wi::multiple_of_p (wi::to_widest (top), wi::to_widest (bottom), SIGNED); a few lines earlier in the same patch, I think my preference is the first patch. Thoughts on this?=