From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 13AA4385DC14; Wed, 15 Apr 2020 06:46:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 13AA4385DC14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586933177; bh=V0bW8ty+HbtNzdR4niLURIekI2jeCYGPVsJBL7CTsrI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PKsmvlDExE8CyY0Fp2kKPGWZU1Czm9U/sPMvhwHn4cvYgNJwDjdWTni5onqQQrw4E 1L11xK/jp+eeXLhjACwIW67m6nMGOVlI3fuJEJXtODzR0DjD2Ui2VYmtuAAG6k7JIL ziw9LOndIg45vrBCvGdGq7EKseIZm3T+ktGSl0Og= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/94600] Ignored volatile specifier on loop unrolling and bitfield misoptimization Date: Wed, 15 Apr 2020 06:46:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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: Wed, 15 Apr 2020 06:46:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94600 --- Comment #3 from Richard Biener --- Confirmed on arm. The odd thing is that the optimized GIMPLE for foo() is much nicer: foo () { [local count: 153437707]: MEM[(volatile struct t0 *)655404B] =3D{v} a0[0]; MEM[(volatile struct t0 *)655408B] =3D{v} a0[1]; MEM[(volatile struct t0 *)655412B] =3D{v} a0[2]; MEM[(volatile struct t0 *)655416B] =3D{v} a0[3]; MEM[(volatile struct t0 *)655420B] =3D{v} a0[4]; MEM[(volatile struct t0 *)655424B] =3D{v} a0[5]; return; while for bar() we have additional stmts to construct the stack objects though the actual stores are the same: [local count: 1073741824]: a01 =3D {}; a02 =3D {}; a03 =3D {}; a04 =3D {}; a05 =3D {}; MEM[(struct *)&a00] =3D 33556023; MEM[(volatile struct t0 *)655404B] =3D{v} a00; _38 =3D MEM[(struct *)&a01]; _39 =3D _38 & 33521664; _40 =3D _39 | 33558455; MEM[(struct *)&a01] =3D _40; MEM[(volatile struct t0 *)655408B] =3D{v} a01; _41 =3D MEM[(struct *)&a02]; _42 =3D _41 & 33521664; _43 =3D _42 | 167774200; MEM[(struct *)&a02] =3D _43; MEM[(volatile struct t0 *)655412B] =3D{v} a02; _44 =3D MEM[(struct *)&a03]; _45 =3D _44 & 33521664; _46 =3D _45 | 33554453; MEM[(struct *)&a03] =3D _46; MEM[(volatile struct t0 *)655416B] =3D{v} a03; _47 =3D MEM[(struct *)&a04]; _48 =3D _47 & 33521664; _49 =3D _48 | 33554453; MEM[(struct *)&a04] =3D _49; MEM[(volatile struct t0 *)655420B] =3D{v} a04; _50 =3D MEM[(struct *)&a05]; _51 =3D _50 & 33521664; _52 =3D _51 | 33554453; MEM[(struct *)&a05] =3D _52; MEM[(volatile struct t0 *)655424B] =3D{v} a05; a00 =3D{v} {CLOBBER}; a01 =3D{v} {CLOBBER}; a02 =3D{v} {CLOBBER}; a03 =3D{v} {CLOBBER}; a04 =3D{v} {CLOBBER}; a05 =3D{v} {CLOBBER}; return; I suspect that the RTL expansion for foo() applies "premature" optimization via constant folding the aggregate initializer and thus compiling this into partly initializing the destination which isn't valid for volatile qualified LHSs. For bar() there's nothing to optimize for it.=