From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 26A20385E037; Fri, 21 Jul 2023 21:40:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26A20385E037 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689975611; bh=2TNI9sFDuACDyqxY8wSiorU5u5m3NgdhsWES3sU+tVo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nlgiuU71FNCT/YmRdcnYqD9x+6YLMDNwjLt6RS4oRZ+J1gy5ORrg9vJxTMH4SitnB i/f0vzFG+yijc1SKMIZ3KPXTgy1D+R3kUrdvsVT6x6mGeRpasE3qM8H+5yWjuduOq9 PSisW7tbkwmumyXNTp3gEZY9bpeOinKqAgrQmEcA= From: "vineetg at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/110748] RISC-V: optimize store of DF 0.0 Date: Fri, 21 Jul 2023 21:40:10 +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: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: vineetg at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: vineetg 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=3D110748 --- Comment #11 from Vineet Gupta --- There's a variation which can be optimized as well and seems non trivial to implement Now it is the negative constant -0.0 to be stored to mem. In bit notation t= his has a single sign bit set thus can be optimized using a bseti if rv64gc_zbs. void znd(double *d) { *d =3D -0.0; } void znf(float *f) { *f =3D -0.0; } llvm optim these to znd(double*): bseti a1, zero, 63 sd a1, 0(a0) ret znf(float*): lui a1, 0x80000 sw a1, 0(a0) ret While gcc resorts to constant pool for both lui a5,%hi(.LANCHOR0) fld fa5,%lo(.LANCHOR0)(a5) fsd fa5,0(a0) ret .set .LANCHOR0,. + 0 .LC0: .word 0 .word -2147483648=