From patchwork Tue Nov 8 19:54:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Tomsich X-Patchwork-Id: 17190 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2916938wru; Tue, 8 Nov 2022 11:54:49 -0800 (PST) X-Google-Smtp-Source: AMsMyM7K+i80Lcl7h78g9s2OzVL/2LNWL8tT4rDJoaiFlAgJuYHbNYDhlSzZjL/PfHFmKS4P+oUq X-Received: by 2002:a50:cc07:0:b0:453:4427:a918 with SMTP id m7-20020a50cc07000000b004534427a918mr57387965edi.121.1667937289716; Tue, 08 Nov 2022 11:54:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667937289; cv=none; d=google.com; s=arc-20160816; b=KjG2RNU3HqFJFNaI9Lw69L/+6RT0Il8s6uCiLSmsrN8ahC1kQ0OBTfrdSdPwvS2B7Q dpfo7qoMJrWfWBu1zI/wNAav/ZVKrgDSEYUvSWDkVnHzM8UB4pv+j4SA+Z2t/w5N1Ljx C1rv5is4lkOepOTJnJaF2sjz7axV8+464WaqFFyiCh0a1P36/W6hPvdHN6FtxayLmt2C aNoIGf5mXgN39/4z2nwn3oaYZijxbhANAeGBFdajqbEVqAWDQjTvLi4WZHFSFhDhDbdt im5VNcDoMBkdI4dQR3XjyXvRE7l0T5bNKviZgerO9xPkc77o81l2VBMeYSKpjFvVxtlA Bkrw== 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=+DyNhtaD6PwJr7UDmcsRAMpYl3jjDHIdO8sJZomwu+k=; b=NG+G4J5O+wH6y0v9d2JanoTnhUELlr1hPBjrjdQXiQFWwBKUnVRV8+WqE6c18Qc1lK plgfFqmG4CdDs126RVlVPTMFIqPtiikKUls2ZgFBeXP0Rgkop0xTQ5bdaUp2qYVYi87R VLxZ/BtJ3l+fHidWX2Go6g+wnZCh5dFROA8GkNTgYuilfMJM9WOEdqbGSsfQ+1r1Z2pX 9tjbj9tSXld0Q3egjB+uAVQ5w/SuivSjvshlbCdP3UZ/GMnsCLsdCr2TXqdcmXLwLckl UagELfA4HdMU02gJ7p2W8igpxIn1/ahi5rDji9W2ynkZrDkODSkoI+s3ElU41VR5Sm/f BjOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=TX8FyH6n; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id rv14-20020a17090710ce00b007adf16570c3si10369067ejb.17.2022.11.08.11.54.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 11:54:49 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=TX8FyH6n; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 9A2433858C3A for ; Tue, 8 Nov 2022 19:54:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id ECE0F3858D3C for ; Tue, 8 Nov 2022 19:54:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ECE0F3858D3C 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-x230.google.com with SMTP id z24so22698956ljn.4 for ; Tue, 08 Nov 2022 11:54:22 -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=+DyNhtaD6PwJr7UDmcsRAMpYl3jjDHIdO8sJZomwu+k=; b=TX8FyH6nSfgbP4OhA16FdgmWaNnWvxT5GT0ELbuJHlaNwhr4vc2eAg3H35m6PZc1SW yLHl3mkZf7fexyUIKsskqryghIZFwgkc/X3N+PIaLSKQnVUr+gtk6QQhGCqNe1TW7WZp 7PDk1Qb4wrNhneWHH0qYorpIfR7Iq/LvwzdQFujvO7NmCiSjJ/uh/aXQb1S9XXhtYl+U N5ZmKbmGZsIeYkRPipJxcU9jgQ46q7P2yhgxDzBybwDH8Og+ENEtPz17/m4ke362dEmo ZJzuY9YKy7ZPoi+N0U2WQQkkHcLIafkYjJE+8z9xX0NkdKbIXkACNztdGnRlBKDo9h81 DJfw== 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=+DyNhtaD6PwJr7UDmcsRAMpYl3jjDHIdO8sJZomwu+k=; b=P+4MVoH4395LLBKB53vRFBvqYw4Mp14DJ6+SKF95rUp8T1cSFJXjOhiu1RuxFXfr8L BhuUgS8+i+aoLGErQ+yNVufyM9QUd8bjRoAiNuVPWle/vN/LjePiRnUOW22BBlc7em/t e4evknI+HOZCckguEI+fH164rpRM1rAHwfGgvUx3Exbn4fXZY4dWqclN2aB0ie7PDOm8 JRvj6qG4BhNkMaHvL7gzvZmNxn2b6yKuGWUfo+kK/5H18V/4v3kK8usqrvIjJ1hVp276 yFSrUcxsisDRTzQjX11RVh7pnls5Ec8sNqghVCnnKmCs6sSzBjq8sxavnYjWHFytQWnQ cDVg== X-Gm-Message-State: ACrzQf3U86/aWyB0VKtWMdrWFTSoFEx1RX4YW4v2UqiZhi+t8jXzK1Ra Ylu3Jy/yv03f6EwI61lsen6EYPPiPbqGOP98 X-Received: by 2002:a2e:88d5:0:b0:277:9bf:9411 with SMTP id a21-20020a2e88d5000000b0027709bf9411mr6920659ljk.504.1667937260795; Tue, 08 Nov 2022 11:54:20 -0800 (PST) Received: from ubuntu-focal.. ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id r14-20020ac25c0e000000b0049ae3ed42e8sm1902818lfp.180.2022.11.08.11.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 11:54:20 -0800 (PST) From: Philipp Tomsich To: gcc-patches@gcc.gnu.org Cc: Palmer Dabbelt , Kito Cheng , Christoph Muellner , Vineet Gupta , Jeff Law , Philipp Tomsich Subject: [PATCH] RISC-V: costs: handle BSWAP Date: Tue, 8 Nov 2022 20:54:15 +0100 Message-Id: <20221108195415.2701208-1-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 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?1748959011444268467?= X-GMAIL-MSGID: =?utf-8?q?1748959011444268467?= The BSWAP operation is not handled in rtx_costs. Add it. With Zbb, BSWAP for XLEN is a single instruction; for smaller modes, it will expand into two. gcc/ChangeLog: * config/riscv/riscv.c (rtx_costs): Add BSWAP. --- gcc/config/riscv/riscv.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 32f9ef9ade9..ab6c745c722 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -2562,6 +2562,16 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN *total = riscv_extend_cost (XEXP (x, 0), GET_CODE (x) == ZERO_EXTEND); return false; + case BSWAP: + if (TARGET_ZBB) + { + /* RISC-V only defines rev8 for XLEN, so we will need an extra + shift-right instruction for smaller modes. */ + *total = COSTS_N_INSNS (mode == word_mode ? 1 : 2); + return true; + } + return false; + case FLOAT: case UNSIGNED_FLOAT: case FIX: