From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A0378385828E; Wed, 8 Feb 2023 12:15:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0378385828E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675858532; bh=mtrDqy1N2+z8VfTXTlkAOcfzgZdQ5F2I1+ueNPDYhwA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=e2Yl6dlERhizdLGc+oKFCPYlbYL0Iu312BL6Wk8xcW1zSekg1V6ZinzbKzw8P+oIk 2R5jjidvn/AyQ3vkCMvHRypZShwUEAgFIlfw6OVCmjEPa+gU5V12tqhRMTg6oTSMzn zOcVSQedLykD4b+TNfBwXonb4KB8dv5VSPb4fuAw= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyB0cmVlLW9wdGltaXphdGlvbi8xMDg2ODhdIFsxMyBSZWdy?= =?UTF-8?B?ZXNzaW9uXSBlcnJvcjog4oCYYml0X2ZpZWxkX3JlZuKAmSBvZiBub24tbW9k?= =?UTF-8?B?ZS1wcmVjaXNpb24gb3BlcmFuZA==?= Date: Wed, 08 Feb 2023 12:15:32 +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: 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: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.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=3D108688 --- Comment #4 from Jakub Jelinek --- I think the bug is in the match.pd /* Simplify a bit extraction from a bit insertion for the cases with the inserted element fully covering the extraction or the insertion not touching the extraction. */ (simplify (BIT_FIELD_REF (bit_insert @0 @1 @ipos) @rsize @rpos) (with { unsigned HOST_WIDE_INT isize; if (INTEGRAL_TYPE_P (TREE_TYPE (@1))) isize =3D TYPE_PRECISION (TREE_TYPE (@1)); else isize =3D tree_to_uhwi (TYPE_SIZE (TREE_TYPE (@1))); } (switch (if (wi::leu_p (wi::to_wide (@ipos), wi::to_wide (@rpos)) && wi::leu_p (wi::to_wide (@rpos) + wi::to_wide (@rsize), wi::to_wide (@ipos) + isize)) (BIT_FIELD_REF @1 @rsize { wide_int_to_tree (bitsizetype, wi::to_wide (@rpos) - wi::to_wide (@ipos)); })) (if (wi::geu_p (wi::to_wide (@ipos), wi::to_wide (@rpos) + wi::to_wide (@rsize)) || wi::geu_p (wi::to_wide (@rpos), wi::to_wide (@ipos) + isize)) (BIT_FIELD_REF @0 @rsize @rpos))))) which folds _ifc__35 =3D BIT_INSERT_EXPR <_ifc__34, _2, 0 (7 bits)>; _ifc__31 =3D BIT_FIELD_REF <_ifc__35, 2, 0>; where 34/35 have unsigned char type, 31 signed:2 and 2 signed:7. So, in this case it wants to extract low 2 bits out of the 7 bits _2 which = is invalid because _2 doesn't have mode precision. If it tried to extract 7 bits out = of it, we have: (simplify (BIT_FIELD_REF @0 @1 integer_zerop) (if (tree_int_cst_equal (@1, TYPE_SIZE (TREE_TYPE (@0)))) (view_convert @0))) simplification but that one wouldn't trigger, because those signed:2 types = have TYPE_SIZE 8 rather than 7, only TYPE_PRECISION of 7.=