From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CAE4C3858409; Mon, 24 Jan 2022 08:13:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CAE4C3858409 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/103641] [11/12 regression] Severe compile time regression in SLP vectorize step Date: Mon, 24 Jan 2022 08:13:18 +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: 11.2.0 X-Bugzilla-Keywords: compile-time-hog X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 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: Mon, 24 Jan 2022 08:13:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103641 --- Comment #21 from rguenther at suse dot de --- On Sat, 22 Jan 2022, roger at nextmovesoftware dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103641 >=20 > --- Comment #20 from Roger Sayle --- > IMHO, the problem is in tree-vect-patterns.cc's vect_synth_mult_by_consta= nt. > The comment above line 3054 reads: > /* Use MAX_COST here as we don't want to limit the sequence on rtx cost= s. > The vectorizer's benefit analysis will decide whether it's beneficial > to do this. */ > bool possible =3D choose_mult_variant (mode, hwval, &alg, &variant, MAX= _COST); >=20 > By using MAX_COST here, synth_mult is being allowed to take an unbounded > amount of time, considering all possible permutations/implementations to > find an optimal synthetic multiply sequence. A more pragmatic bound might > be to compare the target's vector_multiply cost, or failing that use an > arbitrary, but reasonable limit, say COSTS_N_INSNS(8) machine instruction= s. > In the worst case, if it takes 100 instructions to do a vector multiply, > then the loop probably shouldn't be vectorized. Is there a way to switch synth_mult to number of insn based costs? Like using -Os metrics? And would that improve things here? I agree that an ubound search is bad but as the comment explains we want to delay costing to the vectorizer cost evaluation time ... But sure, setting an upper bound to limit compile-time sounds still reasonable.=