From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E9C233858415; Sun, 15 Aug 2021 22:34:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9C233858415 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/63271] Should commute arithmetic with vector load Date: Sun, 15 Aug 2021 22:34:00 +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: 4.9.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org 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 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: Sun, 15 Aug 2021 22:34:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D63271 --- Comment #3 from Andrew Pinski --- So the two functions are not the same (because __m128i is Vector of 2 long = long [at least now]). Here is a better testcase: #define vector __attribute__((vector_size(16))) typedef vector char __m128i ; static inline __m128i _mm_set_epi8(char a, char b, char c, char d, char e, = char f, char g, char h, char i, char j, char k, char l, char m, char n, char o, char p) { return (__m128i){a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p}; } __m128i foo(char C) { return _mm_set_epi8( 0, C, 2*C, 3*C, 4*C, 5*C, 6*C, 7*C, 8*C, 9*C, 10*C, 11*C, 12*C, 13*C, 14*C, 15*C); } __m128i bar(char C) { __m128i v =3D _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15); vector unsigned char d =3D (vector unsigned char)v; d *=3D C; return (__m128i)d; } -------------------------------------CUT ------------------------ So take the above, on aarch64 SLP does not do it because it does not recong= ize 0 and C as being able to SLPed. If I change them to be both to 2*C, then S= LP will do the right thing.=