From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6A84C385AFB3; Thu, 20 Jul 2023 17:24:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A84C385AFB3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689873880; bh=l6omKCLPWlXLTcvRO+/Fz9gHiAOVbOMyhGrTu1nj4u4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ce4OA/eEPjqfJWs9CN9Z28BzMhkos9y92Y9y9veXoTggKjHIU6OPPS9s24JnRaGFH XFdmTCrwHSwR1eTVY1xK44ykV3i4nAx2ZrYJ6wHU45qQacRNuLp/ddzhQH8RhSbFC8 ntz1yF42JeN7vvbYIxg/lfRp6IkF1IDbneNpFPOE= 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: Thu, 20 Jul 2023 17:24:39 +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 #8 from Vineet Gupta --- (In reply to Jeffrey A. Law from comment #5) > I'd bet it's const_0_operand not allowing CONST_DOUBLE. Correct. > The question is what unintended side effects we'd have if we allowed > CONST_DOUBLE 0.0 in const_0_operand. Exactly. I had the same concern.=20 I do have a hack which creates a new predicate and that seems to do the tri= ck. +(define_predicate "const_0hf_operand" + (and (match_code "const_double") + (match_test "op =3D=3D CONST0_RTX (GET_MODE (op))"))) + +(define_predicate "reg_or_0_operand_inc_hf" + (ior (match_operand 0 "reg_or_0_operand") + (match_operand 0 "const_0hf_operand"))) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc - if (!register_operand (dest, mode) && !reg_or_0_operand (src, mode)) + if (!register_operand (dest, mode) && !reg_or_0_operand_inc_hf (src, mod= e)) { And it seems to be generating the desired int 0 for double 0.0. However to Kito's point, this indeed works in gcc 12 so I first need to bis= ect what regressed it in 13.=