From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5F7B5385803B; Fri, 8 Oct 2021 09:36:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F7B5385803B From: "ubizjak at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/85730] complex code for modifying lowest byte in a 4-byte vector Date: Fri, 08 Oct 2021 09:36:46 +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: 9.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: ubizjak at gmail dot com 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, 08 Oct 2021 09:36:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D85730 --- Comment #9 from Uro=C5=A1 Bizjak --- An interesting observation with the following testcase: --cut here-- typedef char V __attribute__((vector_size(4))); struct S { char val; char pad1; char pad2; char pad3; }; V foo (V v) { v[0] <<=3D 3; return v; } struct S bar (struct S a) { a.val <<=3D 3; return a; } --cut here-- gcc -O2: foo: movsbl %dil, %edx movl %edi, %eax sall $3, %edx movb %dl, %al ret bar: movl %edi, %eax salb $3, %al ret So, the compiler is able to produce optimal code with equivalent struct description, but something (in middle-end?) prevents the same optimization = with a vector (a.k.a array).=