From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 496353857C5A; Thu, 6 Jul 2023 23:44:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 496353857C5A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688687077; bh=EHkoytXB7gPTbS8UD8yjFPGifDky2tSuhKsZngo9TBE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CKCiaNNDx5xN4VjoZ+q/8n8EPXcppqvvjVMgEJqi80lQomz0oUxSCsqjvDCQM9Ext ljLsYyFz/KTLqx+M34vc6ipJ7a8J71u+bCZ72PgZbJ/QAmP25fvKwyY2nSTPLoO/VU +W6SMscM/M2pIgdt26WTKnrm2I6RCgq7ixaNgA+4= From: "luke.geeson at cs dot ucl.ac.uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/110573] branch delay slots are not filled with atomic stores Date: Thu, 06 Jul 2023 23:44:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: luke.geeson at cs dot ucl.ac.uk 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110573 --- Comment #4 from Luke Geeson --- Ah so since atomics are treated as volatile (like LLVM) instructions that access them cannot inhabit a delay slot. Is it still valid to treat atomics= as volatile? Consider the following MIPS litmus test: ``` { %x0=3Dx; %y0=3Dy; %y1=3Dy; %x1=3Dx; } P0 | P1 ; lw $2,0(%x0) | lw $2,0(%y1) ; ori $3,$0,1 | ori $3,$0,1 ; sw $3,0(%y0) | sw $3,0(%x1) ; exists (0:$2=3D1 /\ 1:$2=3D1) ``` When run under the mips model we do not observe the outcome in the exists clause: ``` 0:$2=3D0; 1:$2=3D0; 0:$2=3D0; 1:$2=3D1; 0:$2=3D1; 1:$2=3D0; ``` That is, from an ordering perspective it is unlikely that unexpected behavi= ours can occur - in this case putting sw in a delay slot should be ok (the same doesn't hold for RISC-V/Arm models of course). I understand treating atomics as volatile has historical precedent but a ca= se can be made, at least on modern architectures and with improved understandi= ng of models, that atomics are not volatile and more optimisations can be appl= ied. What do you think?=