From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 56CF43858414; Fri, 12 May 2023 07:47:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 56CF43858414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683877620; bh=azuSqGqdzvP5VvCtq7F3NKmGjtzLQLHhqj51Xk/MAFE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=deH5UXku7fx2WCqdMAYjS2KsJLEC6/4Urc8mdH0Et7vBdOPL5+Ti6yh+JEPiNsDXs HnMJCu+kIPN5U2c1BhpEtT7FmzlCHpnIAXPYcKeddDDadK4kDi9CTJ+5+6GYGzZG2k YSYik5YJhV/MmpdWYmpITRoPfcegnD8j4ri9RFF0= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/102989] Implement C2x's n2763 (_BitInt) Date: Fri, 12 May 2023 07:46:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement 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: --- 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=3D102989 --- Comment #38 from Jakub Jelinek --- I guess there are other options. If we could make wide_int/widest_int non-POD, one option would be to turn t= heir storage into a union of the normal small case we use now everywhere (i.e. f= ixed one) and one where the val array is not stored directly in the storage but pointed to by some pointer. E.g. class GTY(()) wide_int_storage { private: HOST_WIDE_INT val[WIDE_INT_MAX_ELTS]; unsigned int len; unsigned int precision; could be private: union { HOST_WIDE_INT val[WIDE_INT_MAX_ELTS]; HOST_WIDE_INT *valp; }; unsigned int len; unsigned int precision; and decide which one is which based on len > WIDE_INT_MAX_ELTS or something similar. Or, if we can't affort to make it non-POD, perhaps valp would refer to obst= ack destroyed at the end of each pass or something similar. Another problem is with INTEGER_CST (note, if we lower this stuff before expansion hopefully we wouldn't need something similar for rtxes). Currently INTEGER_CST has: /* The number of HOST_WIDE_INTs in an INTEGER_CST. */ struct { /* The number of HOST_WIDE_INTs if the INTEGER_CST is accessed in its native precision. */ unsigned char unextended; /* The number of HOST_WIDE_INTs if the INTEGER_CST is extended to wider precisions based on its TYPE_SIGN. */ unsigned char extended; /* The number of HOST_WIDE_INTs if the INTEGER_CST is accessed in offset_int precision, with smaller integers being extended according to their TYPE_SIGN. This is equal to one of the two fields above but is cached for speed. */=20=20=20=20=20=20=20=20= =20=20=20=20 unsigned char offset;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 } int_length; Now, this obviously limits the largest representable constants to 0xFF HOST_WIDE_INTs, i.e. at most 16320 bits. We have 8 spare bits there, so one possibility wo= uld be to add a flag there and if that flag is true, ignore int_length.{unextended,extended,offset} fields and instead stick that info somewhere into the val array. Or kill TREE_INT_CST_OFFSET_NUNITS (replace it with TREE_INT_CST_EXT_NUNITS (t) <=3D OFFSET_INT_ELTS ? TREE_INT_CST_EXT_NUNITS = (t) : TREE_INT_CST_NUNITS (t)) and turn unextended/extended into unsigned short. Then we can handle at most _BitInt(4194240), slightly more than 2 times low= er than what LLVM chose, I guess that would be still acceptable.=