From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B2C2A3858D37; Sat, 22 Jan 2022 14:30:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2C2A3858D37 From: "roger at nextmovesoftware dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/103641] [11/12 regression] Severe compile time regression in SLP vectorize step Date: Sat, 22 Jan 2022 14:30:40 +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: roger at nextmovesoftware dot com 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: Sat, 22 Jan 2022 14:30:40 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103641 --- Comment #20 from Roger Sayle --- IMHO, the problem is in tree-vect-patterns.cc's vect_synth_mult_by_constant. The comment above line 3054 reads: /* Use MAX_COST here as we don't want to limit the sequence on rtx costs. 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_C= OST); 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 instructions. In the worst case, if it takes 100 instructions to do a vector multiply, then the loop probably shouldn't be vectorized.=