From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1E8ED3858409; Mon, 27 Sep 2021 05:08:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E8ED3858409 From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102494] Failure to optimize vector reduction properly especially when using OpenMP Date: Mon, 27 Sep 2021 05:08:08 +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: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: crazylht at gmail dot com 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: --- 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, 27 Sep 2021 05:08:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102494 --- Comment #3 from Hongtao.liu --- (In reply to Hongtao.liu from comment #2) > It seems x86 doesn't supports optab reduc_plus_scal_v8hi yet. vectorizer does the work for backend.=20 typedef short v8hi __attribute__((vector_size(16))); short foo1 (v8hi p, int n) { short sum =3D 0; for (int i =3D 0; i !=3D 8; i++) sum +=3D p[i]; return sum; } # sum_21 =3D PHI # vect_sum_9.26_5 =3D PHI _22 =3D (vector(8) unsigned short) vect_sum_9.26_5; _23 =3D VEC_PERM_EXPR <_22, { 0, 0, 0, 0, 0, 0, 0, 0 }, { 4, 5, 6, 7, 8, = 9, 10, 11 }>; _24 =3D _23 + _22; _25 =3D VEC_PERM_EXPR <_24, { 0, 0, 0, 0, 0, 0, 0, 0 }, { 2, 3, 4, 5, 6, = 7, 8, 9 }>; _26 =3D _25 + _24; _27 =3D VEC_PERM_EXPR <_26, { 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 2, 3, 4, 5, = 6, 7, 8 }>; _28 =3D _27 + _26; stmp_sum_9.27_29 =3D BIT_FIELD_REF <_28, 16, 0>; But for the case in PR, it's v8qi -> 2 v4hi, and no vector reduction for v4= hi.=