From patchwork Tue Nov 8 19:55:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Tomsich X-Patchwork-Id: 17193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2917493wru; Tue, 8 Nov 2022 11:56:15 -0800 (PST) X-Google-Smtp-Source: AMsMyM7A8QJyJ55gbEEs6hFxJD4JpPBXQWe1oizrGTgCzre32sDO+eTQU4967YC4alobVqXuAVWW X-Received: by 2002:a05:6402:5159:b0:462:3e9f:a0a4 with SMTP id n25-20020a056402515900b004623e9fa0a4mr55902649edd.313.1667937375770; Tue, 08 Nov 2022 11:56:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667937375; cv=none; d=google.com; s=arc-20160816; b=EoIYTJchofMIn5DIe4WrGOGOXiBkgzGZf7OPkyjdAHksbZ3sWdFrqEzfIC0HLNLI8q 2vk0/06AmB43qKOqFWUwJdxAGQj/04OUaNeCr1BTi7iaXr/SEi9OrqilXbn8nY9ABUhu XPIJixSY/h4ytvXNbRmDCOPSbJ4PTbF0lLeOtpaxOz2tRZcATBPX40LmkXt+ocaH8Kjl wndwbfJ4hpsTKQBl3WzuxsO3NXqLWS2UVFzGNIAO5koP9PK1nkm//p6bONmAR0D2Pbp6 7xDgY61NQx2rgY73FtM7rBzWsLfaawNYosktooEX/1Jxh+8i3iSejFcfzuU4qX62OnCd 5c1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=HpWFTKpR8RTITEEcJM7g/Smup+i4QN4fi/YyUSK0Xog=; b=pwDsiyxWD+XvlKcGlLTCqyrHnRJ99zDPUqBPwtU1npszK20h1Tb4gDgJtXU69xppNv DVZMaXqj2Udxs2Y1SWI7rhKxIHV/QP44MijpdhR939IatO32Gcfao02ocPq+AtL98Brb G8ry+0YlaQivaC1LqbMEnUjdnUAvb3kj1qve/q01/XZEbW8ZvC5cyj0Wh718GoQ2pg6n eHhZGTpXD2SDyKnxIAkM9c0gGU0zu/5rNnTwYJtv98dMjZQtjVAT/2oBkmsDu0QfDnQo Kj/HIlb/C6S1sBkfhKJOMP/GuRVmXHvyepcgtgDprO8aOCWsxxQHvqm5znl+Vz0fVEfK P2jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=hsO8yqqX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d21-20020a056402517500b004614db9789asi10695196ede.127.2022.11.08.11.56.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 11:56:15 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=hsO8yqqX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D42FA3857BAB for ; Tue, 8 Nov 2022 19:55:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id B3C9D3858003 for ; Tue, 8 Nov 2022 19:55:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B3C9D3858003 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-lj1-x232.google.com with SMTP id b9so22698500ljr.5 for ; Tue, 08 Nov 2022 11:55:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HpWFTKpR8RTITEEcJM7g/Smup+i4QN4fi/YyUSK0Xog=; b=hsO8yqqX8jOgr7zCgELNVFwA21cyCGXIoMyA2KgeqN1F3VlDlTjzXwVBn9+fkk6Plv gVsshmvWKRRSOIq3H95+GmxT0PbqGFQ0NSRQOz+nAnf+Nia+pSq3ETjqjsBYMPslzeXE ltkq8qUXaLm6Km4+vGtdX1iWBgxyMvK+1hedsEKIsSS/HX3AhGM7TWWsyfo512shk1m6 hGBKH3vDjnHBayvGSTcSC1iRnVFvs86Zj66sP+CZB6ycMhJwOvFk42sMpY0TJ0YHwxV9 WRV6PRyBSl4CM6nvPxcuJJpeI6kHiYlBI24VAhILqpNiXtOHb8A2xLKUnEGGL+fHUnWY ickA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HpWFTKpR8RTITEEcJM7g/Smup+i4QN4fi/YyUSK0Xog=; b=1Krh+EGyfyvLkgKbMVikbHaDW180ILprLyiKLa9w877Y82KSYAPJEjzdO0POZVTKxp tuPbVK49kkvedYfqgN3szkuKpNbFsfBQZiMI3kr+Uk5/0vkfscyV4wb+acs+smHw7fpj A07ufTu10mf601SAYoe81xddYSNG4+nQyb2ia7HrbHN7vsIB21sKKfu4Wbunaj/TN3iw Bp8/ceGNYdggcG02/C8X3Vmq20RD3Yn7465H9Zer01XS3jL2z7UUAn0xf1y4lZAXLZPR v7OwA0mZCq1Sxk5OGXsMVgdnV7mc6ddg/HgBEcuRWoHedprrHA8RH6nH1QsfiIo2FtRi /4ig== X-Gm-Message-State: ACrzQf3hqq3v19NxFBp1/pxFAgAhUowPrfS+/+0aTqpmBhSLJ9LaROdu NaT3oDUL3Y/0/iSVTGunXy9cjxdXCjgpo2M3 X-Received: by 2002:a2e:918a:0:b0:277:46da:16a6 with SMTP id f10-20020a2e918a000000b0027746da16a6mr17914946ljg.200.1667937312037; Tue, 08 Nov 2022 11:55:12 -0800 (PST) Received: from ubuntu-focal.. ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id f6-20020ac25326000000b0049487818dd9sm1918404lfh.60.2022.11.08.11.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 11:55:11 -0800 (PST) From: Philipp Tomsich To: gcc-patches@gcc.gnu.org Cc: Vineet Gupta , Kito Cheng , Jeff Law , Palmer Dabbelt , Christoph Muellner , Philipp Tomsich Subject: [PATCH] RISC-V: branch-(not)equals-zero compares against $zero Date: Tue, 8 Nov 2022 20:55:09 +0100 Message-Id: <20221108195509.2701313-1-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748959101868164527?= X-GMAIL-MSGID: =?utf-8?q?1748959101868164527?= If we are testing a register or a paradoxical subreg (i.e. anything that is not a partial subreg) for equality/non-equality with zero, we can generate a branch that compares against $zero. This will work for QI, HI, SI and DImode, so we enable this for ANYI. 2020-08-30 gcc/ChangeLog: * config/riscv/riscv.md (*branch_equals_zero): Added pattern. --- gcc/config/riscv/riscv.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index 798f7370a08..97f6ca37891 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -2205,6 +2205,19 @@ ;; Conditional branches +(define_insn "*branch_equals_zero" + [(set (pc) + (if_then_else + (match_operator 1 "equality_operator" + [(match_operand:ANYI 2 "register_operand" "r") + (const_int 0)]) + (label_ref (match_operand 0 "" "")) + (pc)))] + "!partial_subreg_p (operands[2])" + "b%C1\t%2,zero,%0" + [(set_attr "type" "branch") + (set_attr "mode" "none")]) + (define_insn "*branch" [(set (pc) (if_then_else