From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A84BC385840F; Tue, 20 Sep 2022 23:46:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A84BC385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663717598; bh=z7rSV6PcUcDt5MZ3TBLcTb7ABXd10s30aC51L1rh1P4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lGjOgnCGOVFA+BoWo1v87WF7jtbjpLOkLa+leXtWhwCEQ9o6qSp+qyhpeeJIZ9VvG nntqis5y0leJjyBQ7s3Bno6bXmQZNb8kTcagBg9SV2JTqDYzBWWEOCoHklo6xrdLOB 7JVvLDH9CwG8UDx41E4xQForF7QXLZn5HoRSNGwo= From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106989] GCC fail to vectorize and clang succeed Date: Tue, 20 Sep 2022 23:46:32 +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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106989 --- Comment #1 from Hongtao.liu --- > real_t* __restrict__ xx; > real_t* yy; > real_t s243(void) > { > for (int nl =3D 0; nl < iterations; nl++) { > for (int i =3D 0; i < LEN_1D-1; i++) { > a[i] =3D b[i] + c[i ] * d[i]; > b[i] =3D a[i] + d[i ] * e[i]; > a[i] =3D b[i] + a[i+1] * d[i]; > } > } > } Manually change the code to below, gcc can vectorize the loop. real_t s243(void) { for (int nl =3D 0; nl < iterations; nl++) { for (int i =3D 0; i < LEN_1D-1; i++) { // a[i] =3D b[i] + c[i ] * d[i]; propagate it into next line. b[i] =3D b[i] + c[i ] * d[i] + d[i ] * e[i]; a[i] =3D b[i] + a[i+1] * d[i]; } } }=