From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 50D073858D32; Tue, 26 Dec 2023 15:16:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50D073858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703603773; bh=0i+RzHyEagskFZb38yGVOHePyPCssKhAf+ht3nS9wvg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iG6oqTqJIk33qYieChTs5oUH22qVUA2Y/FDrfht/hC8NA/vChYh7z+y0LRm1MvCf1 uVNzt1wjy68EAFgYsKnR3I/uqzY4Gjm/dVkSHScn9efwvuaGnzEhvzeaxZOv3J44FD UulHgUovxbf7kGqUpa/75nGSFOD03iys9KRx0cE4= From: "fxue at os dot amperecomputing.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113091] Over-estimate SLP vector-to-scalar cost for non-live pattern statement Date: Tue, 26 Dec 2023 15:16:11 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: fxue at os dot amperecomputing.com 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: --- 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=3D113091 --- Comment #7 from Feng Xue --- > The issue here is that because the "outer" pattern consumes > patt_64 =3D (int) patt_63 it should have adjusted _2 =3D (int) _1 > stmt-to-vectorize > as being the outer pattern root stmt for all this logic to work correctly. We could not simply make this adjustment since pattern recognition does not require replaced SSA to be of single-use. If we change the above case to at= tach another scalar use to "_2" as: int foo(char *a, char *b) { unsigned array[8]; int a0 =3D a[0]; // _2 =3D (int) _1; array[0] =3D (a0 - b[0]); array[1] =3D (a[1] - b[1]); array[2] =3D (a[2] - b[2]); array[3] =3D (a[3] - b[3]); array[4] =3D (a[4] - b[4]); array[5] =3D (a[5] - b[5]); array[6] =3D (a[6] - b[6]); array[7] =3D (a[7] - b[7]); return test(array) + a0; } The pattern statement "patt_64 =3D (int) patt_63" for "_2 =3D (int) _1" sho= uld be kept. So we also need the check of "identifying whether a scalar stmt takes part in vectorization or not" to ensure the adjustment is doable.=