From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 368FE3858D32; Mon, 22 Jan 2024 22:16:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 368FE3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705961816; bh=FVSIJGhZeqx92uvY+0H4TWZqoN9fgF7NcPHDqueS1mk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wXva5t6WyatjpW6YtZzUoC40wiU4nDVIT2YAPTaU+/C9AMyCLaPrITLfUxtgzFuLG OB6y2TR2njpsv7p3TwbQi++g0e6IIhmongFNObFLrV/9Sy6/YZO2coxI7PIdQr57p+ 0bK+R//81T56uiTSOuZalWWRFHMAiDQySSKPnD+U= From: "juzhe.zhong at rivai dot ai" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113441] [14 Regression] Fail to fold the last element with multiple loop Date: Mon, 22 Jan 2024 22:16:55 +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: missed-optimization, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: juzhe.zhong at rivai dot ai X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned 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=3D113441 --- Comment #10 from JuzheZhong --- (In reply to Tamar Christina from comment #9) > So on SVE the change is cost modelling. >=20 > Bisect landed on g:33c2b70dbabc02788caabcbc66b7baeafeb95bcf which changed > the compiler's defaults to using the new throughput matched cost modelling > used be newer cores. >=20 > It looks like this changes which mode the compiler picks for when using a > fixed register size. >=20 > This is because the new cost model (correctly) models the costs for FMAs = and > promotions. >=20 > Before: >=20 > array1[0][_1] 1 times scalar_load costs 1 in prologue > int) _2 1 times scalar_stmt costs 1 in prologue >=20 > after: >=20 > array1[0][_1] 1 times scalar_load costs 1 in prologue=20 > (int) _2 1 times scalar_stmt costs 0 in prologue=20 >=20 > and the cost goes from: >=20 > Vector inside of loop cost: 125 >=20 > to >=20 > Vector inside of loop cost: 83=20 >=20 > so far, nothing sticks out, and in fact the profitability for VNx4QI drops > from >=20 > Calculated minimum iters for profitability: 5 >=20 > to >=20 > Calculated minimum iters for profitability: 3 >=20 > This causes a clash, as this is now exactly the same cost as VNx2QI which > used to be what it preferred before. >=20 > Which then leads it to pick the higher VF. >=20 > In the end smaller VF shows: >=20 > ;; Guessed iterations of loop 4 is 0.500488. New upper bound 1. >=20 > and now we get: >=20 > Vectorization factor 16 seems too large for profile prevoiusly believed to > be consistent; reducing.=20=20 > ;; Guessed iterations of loop 4 is 0.500488. New upper bound 0. > ;; Scaling loop 4 with scale 66.6% (guessed) to reach upper bound 0 >=20 > which I guess is the big difference. >=20 > There is a weird costing going on in the PHI nodes though: >=20 > m_108 =3D PHI 1 times vector_stmt costs 0 in body=20 > m_108 =3D PHI 2 times scalar_to_vec costs 0 in prolo= gue >=20 > they have collapsed to 0. which can't be right.. I don't think this change makes the regression since the regression not only happens on ARM SVE but also on RVV. It should be middle-end. I believe you'd better use -fno-vect-cost-model.=