From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BC56D385AC3A; Wed, 1 Sep 2021 20:14:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC56D385AC3A From: "arnd at linaro dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102162] Byte-wise access optimized away at -O1 and above Date: Wed, 01 Sep 2021 20:14:34 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: arnd at linaro dot org 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: cc 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: Wed, 01 Sep 2021 20:14:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102162 Arnd Bergmann changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |arnd at linaro dot org --- Comment #2 from Arnd Bergmann --- I tried reproducing the issue with my original kernel code, using this inpu= t: typedef unsigned u32; #define __packed __attribute__((packed)) #define __get_unaligned_t(type, ptr) ({=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 \ const struct { type x; } __packed *__pptr =3D (typeof(__pptr))(ptr)= ;=20=20=20=20=20 \ __pptr->x;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 \ })=20 #define get_unaligned(ptr) __get_unaligned_t(typeof(*(ptr)), (ptr)) int f_unaligned(u32 *p) {=20 return get_unaligned(p);=20 } int g(u32 *p)=20 {=20 return *(p);=20 } and it looks like I get correct output: hppa64-linux-gcc -S kernel/test_unaligned.c -o - -O2 .LEVEL 2.0w .text .align 8 .globl f_unaligned .type f_unaligned, @function f_unaligned: .PROC .CALLINFO FRAME=3D0,NO_CALLS .ENTRY ldb 0(%r26),%r20 ldb 1(%r26),%r19 depd,z %r20,39,40,%r20 depd,z %r19,47,48,%r19 ldb 2(%r26),%r31 ldb 3(%r26),%r28 or %r19,%r20,%r19 depd,z %r31,55,56,%r31 or %r31,%r19,%r31 or %r28,%r31,%r28 bve (%r2) extrd,s %r28,63,32,%r28 .EXIT .PROCEND .size f_unaligned, .-f_unaligned .align 8 .globl g .type g, @function g: .PROC .CALLINFO FRAME=3D0,NO_CALLS .ENTRY ldw 0(%r26),%r28 bve (%r2) extrd,s %r28,63,32,%r28 .EXIT .PROCEND .size g, .-g .ident "GCC: (GNU) 11.1.0" Any idea what the difference is between the working version and your broken one?=