From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 126C03858CD1; Fri, 10 Nov 2023 13:42:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 126C03858CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699623742; bh=hfOqqK6KX8aBQq910HJTVY8O2f4JYV4dM+rPV4gQZi4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pgWT9xRh5MTbMIHlF93sJRqoNifIerA4JD2QMlDZeRMzBDMiNWsqDzuktkd+EJRYV 0838GVBBO7jtNQnufSKH0ZhTKdlBEmiPOHifmwMxAua7cChGINnU4kDfgXR/4VOOS/ EW3xcnCGLXaCS8JNxXydEUqQbzKbXS80v8UACyRQ= From: "juzhe.zhong at rivai dot ai" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109088] GCC does not always vectorize conditional reduction Date: Fri, 10 Nov 2023 13:42:21 +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: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: juzhe.zhong at rivai dot ai 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=3D109088 --- Comment #17 from JuzheZhong --- Sorry for confusing and not enough information. I am trying to transform: + reduc_1 =3D PHI <..., reduc_2> + ... + if (...) + tmp1 =3D reduc_1 + rhs1; + tmp2 =3D tmp1 + rhs2; + tmp3 =3D tmp2 + rhs3; + ... + reduc_3 =3D tmpN-1 + rhsN-1; + + reduc_2 =3D PHI First transform the first statement: tmp1 =3D reduc_1 + rhs1; into tmp1 =3D rhs1 + 0; Then it will become bogus data move assignment: tmp1 =3D rhs1. The later PASS will eliminate it. Then, transform the reduction PHI:=20 reduc_1 =3D PHI <..., reduc_2> into if-convert statement: reduc_1 =3D PHI <_ifc__35(8), 0(18)> Thid, transform=20 + reduc_3 =3D tmpN-1 + rhsN-1; + + reduc_2 =3D PHI into : reduc_3 =3D tmpN-1 + rhsN-1; _ifc__35 =3D .COND_ADD (condition, reduc_1, reduc_3, reduc_1); So finally: result_1 =3D PHI <_ifc__35(8), 0(18)> ... tmp1 =3D rhs1; tmp2 =3D tmp1 + rhs2; tmp3 =3D tmp2 + rhs3; ... reduc_3 =3D tmpN-1 + rhsN-1; _ifc__35 =3D .COND_ADD (condition, reduc_1, reduc_3, reduc_1);=