From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 37F423858439; Fri, 27 Aug 2021 06:48:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37F423858439 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/98167] [x86] Failure to optimize operation on indentically shuffled operands into a shuffle of the result of the operation Date: Fri, 27 Aug 2021 06:48:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal 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: Fri, 27 Aug 2021 06:48:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98167 --- Comment #17 from Andrew Pinski --- (In reply to Hongtao.liu from comment #16) > typedef int v4si __attribute__ ((vector_size(16))); >=20 > v4si f(v4si a, v4si b) { > v4si a1 =3D __builtin_shufflevector (a, a, 2, 3 ,1 ,0); > v4si b1 =3D __builtin_shufflevector (b, a, 2, 3 ,1 ,0); > return a1 * b1; > } >=20 > gcc generate=20 >=20 > f: > vpshufd xmm1, xmm1, 30 > vpshufd xmm0, xmm0, 30 > vpmulld xmm0, xmm0, xmm1 > ret >=20 > llvm generate >=20 > f: # @f > vpmulld xmm0, xmm1, xmm0 > vpshufd xmm0, xmm0, 30 # xmm0 =3D xmm0[2,3,1,0] > ret For the above, this is safe for -ftrapping-math as all elements are still u= sed. It is when elements that are not used it might not be safe ...=