From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 30F6D3858D37; Sun, 15 Oct 2023 12:26:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30F6D3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697372760; bh=UxLF++KyY4fQFpK8UASkkiOUconK1rUjSlACOI+QlcA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AO4kTuYWTY+u91KTRr0KfiZJ04U+VMtfdjB5Vo+ZP2a58iGLP6dWOEBue/AeEayJW DrH693xo7yPpli0LYcJc2Jq+bAZvWiM5pnQFsZG/Q9C3p8yKrAICkOgJGM/qLsYiz8 /ITh8LAhLOLOBV2yMB5i16tlzdXVe3L2Zyqi7zIE= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111800] [14 Regression] ICE with -fdump-tree-ccp1-details Date: Sun, 15 Oct 2023 12:25:59 +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: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub 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=3D111800 --- Comment #9 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:3bcc10b98e9ffc1296d3d1aae16e85c6bdb09d1a commit r14-4645-g3bcc10b98e9ffc1296d3d1aae16e85c6bdb09d1a Author: Jakub Jelinek Date: Sun Oct 15 14:23:14 2023 +0200 wide-int: Fix estimation of buffer sizes for wide_int printing [PR11180= 0] As mentioned in the PR, my estimations on needed buffer size for wide_i= nt and especially widest_int printing were incorrect, I've used get_len () in the estimations, but that is true only for !wi::neg_p (x) values. Under the hood, we have 3 ways to print numbers. print_decs which if if ((wi.get_precision () <=3D HOST_BITS_PER_WIDE_INT) || (wi.get_len () =3D=3D 1)) uses sprintf which always fits into WIDE_INT_PRINT_BUFFER_SIZE (positiv= e or negative) and otherwise uses print_hex, print_decu which if if ((wi.get_precision () <=3D HOST_BITS_PER_WIDE_INT) || (wi.get_len () =3D=3D 1 && !wi::neg_p (wi))) uses sprintf which always fits into WIDE_INT_PRINT_BUFFER_SIZE (positive only) and print_hex, which doesn't print most significant limbs which a= re zero and the first limb which is non-zero prints such that redundant 0 hex digits aren't printed, while all limbs below that are printed with "%016" PRIx64. For wi::neg_p (x) values, the first limb of the precisi= on is always non-zero, so we print all the limbs for the precision. So, the current estimations are accurate if !wi::neg_p (x), or when print_decs will be used and x.get_len () =3D=3D 1, otherwise we need to= use estimation based on get_precision () rather than get_len (). I've introduced new inlines print_{dec{,s,u},hex}_buf_size which compute the needed buffer length in bytes and return true if WIDE_INT_PRINT_BUFFER_= SIZE isn't sufficient and caller should XALLOCAVEC the buffer. 2023-10-15 Jakub Jelinek PR tree-optimization/111800 gcc/ * wide-int-print.h (print_dec_buf_size, print_decs_buf_size, print_decu_buf_size, print_hex_buf_size): New inline functions. * wide-int.cc (assert_deceq): Use print_dec_buf_size. (assert_hexeq): Use print_hex_buf_size. * wide-int-print.cc (print_decs): Use print_decs_buf_size. (print_decu): Use print_decu_buf_size. (print_hex): Use print_hex_buf_size. (pp_wide_int_large): Use print_dec_buf_size. * value-range.cc (irange_bitmask::dump): Use print_hex_buf_size. * value-range-pretty-print.cc (vrange_printer::print_irange_bitmasks): Likewise. * tree-ssa-loop-niter.cc (do_warn_aggressive_loop_optimizations= ): Use print_dec_buf_size. Use TYPE_SIGN macro in print_dec call argument. gcc/c-family/ * c-warn.cc (match_case_to_enum_1): Assert w.get_precision () is smaller or equal to WIDE_INT_MAX_INL_PRECISION rather than w.get_len () is smaller or equal to WIDE_INT_MAX_INL_ELTS.=