From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3DD1E385800C; Wed, 1 Dec 2021 09:20:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DD1E385800C From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/102356] [11/12 Regression] compile-time explosion at -O3 -g in var-tracking since r11-209-g74dc179a6da33cd0 Date: Wed, 01 Dec 2021 09:20:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: compile-time-hog X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit 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: 11.3 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Dec 2021 09:20:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102356 --- Comment #5 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:35f2c098c81118020b1d288cd739108c8747a520 commit r12-5652-g35f2c098c81118020b1d288cd739108c8747a520 Author: Jakub Jelinek Date: Wed Dec 1 10:16:57 2021 +0100 simplify-rtx: Punt on simplify_associative_operation with large operands [PR102356] Seems simplify_associate_operation is quadratic, which isn't a big deal for use during combine and other similar RTL passes, because those never try to combine expressions from more than a few instructions and because those instructions need to be recognized the machine description also bounds how many expressions can appear in there. var-tracking has depth limits only for some cases and unlimited depth for the vt_expand_loc though: /* This is the value used during expansion of locations. We want it to be unbounded, so that variables expanded deep in a recursion nest are fully evaluated, so that their values are cached correctly. We avoid recursion cycles through other means, and we don't unshare RTL, so excess complexity is not a problem. */ #define EXPR_DEPTH (INT_MAX) /* We use this to keep too-complex expressions from being emitted as location notes, and then to debug information. Users can trade compile time for ridiculously complex expressions, although they're seldom useful, and they may often have to be discarded as not representable anyway. */ #define EXPR_USE_DEPTH (param_max_vartrack_expr_depth) IMO for very large expressions it isn't worth trying to reassociate tho= ugh, in fact e.g. for the new testcase below keeping it as is has bigger cha= nce of generating smaller debug info which the dwarf2out.c part of the chan= ge tries to achieve - if a binary operation has the same operands, we can use DW_OP_dup and not bother computing the possibly large operand again. The patch fixes it by adding a counter to simplify_context and counting how many times simplify_associative_operation has been called during a single outermost simplify_* call, and once it reaches some maximum (currently 64), it stops reassociating. Another possibility to deal with the power expressions in debug info would be to introduce some new RTL operation for the pow{,i} (x, n) case, allow that solely in debug insns and expand those into DWARF using a loop. But that seems like quite a lot of work for something ra= rely used (especially when powi for larger n is only useful for 0 and 1 inpu= ts because anything else overflows). 2021-12-01 Jakub Jelinek PR rtl-optimization/102356 * rtl.h (simplify_context): Add assoc_count member and max_assoc_count static member. * simplify-rtx.c (simplify_associative_operation): Don't reassociate more than max_assoc_count times within one outermost simplify_* call. * dwarf2out.c (mem_loc_descriptor): Optimize binary operation with both operands the same using DW_OP_dup. * gcc.dg/pr102356.c: New test.=