From patchwork Thu Aug 22 19:46:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick O'Neill X-Patchwork-Id: 1975737 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=UHliuGGO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqYh14Cmrz1yf6 for ; Fri, 23 Aug 2024 05:49:53 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D2737387547A for ; Thu, 22 Aug 2024 19:49:51 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id CFD2B3860C32 for ; Thu, 22 Aug 2024 19:48:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CFD2B3860C32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CFD2B3860C32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724356099; cv=none; b=gOzGKTRorBEXv4gHFFD7QkptMbYt+R5EUD9/e17fpaKPFia1sIWK0uQjG3GN/yp4xGGXRrXNES/yIToNgnM4sVc7EkDM5qwd36IHhuKxrqh5XvCfj24ytn9a33nISd9spMwMlr0AFI9N5pLMKV0VNWbT97MeafAM3bStCfjiMQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724356099; c=relaxed/simple; bh=BbjYCPD+PWDH4b4svq8Y14Wdqcl28fcUhb2aUBKP8qo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=G84at+4ulmrSfEbw15Y1tr7Nf8pfpi7XHmiblpEXGI0+Zed9EWVgt7VZwrq1jEu1djTO70hFq/8cUvLzBWYoIL9mglLaZls1+hGuqMTRvyag1RpX/RgaB5w3tyVqKZe3Mw2QtI5GIMQ0hpn/HLuvb3G/8K3l4mXYOXGAiFYLhwI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-202146e9538so11561425ad.3 for ; Thu, 22 Aug 2024 12:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724356094; x=1724960894; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J7KebF7/5q4EtExDCAe8Hfeu92CajyP+TNv82bpurGs=; b=UHliuGGOWK7g/uiDfr30yjZl6Yzx1JsB/AmgSaFcVSrjMi94nPkpqJ8KAR6xwKVKCn N7ttH5HGKIHXFQc6w+Yhu2efK+NepVJLmBTweyNLbb6HHxdMKwLB9zlXxrf3Y53T6oSj nmlcIbR7Bt11+iMFrP2fCVVdTs5VZNgjKJgVZXSYQWld1RucRCY3gPKine291nrPos+G 0BSnuIJntvNdv1v6UJbQN7zSAXW/DBXeMArTNEc1NaZz09k0TOr74ginz3BdEgjeXACZ xJl82wy/vqTatgPNuJBoF9PIQQDeelfEOQV6QO3XpGvmzEaUDJF7zz8nL84pEhU/phrE 98SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724356094; x=1724960894; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J7KebF7/5q4EtExDCAe8Hfeu92CajyP+TNv82bpurGs=; b=CgOpAVu7gNTYXX+IYD+XBf0RVgBHWTGmqqpf9wTCUDIIfyHSwolvVDqbYyYbfyeHRD jr/1baiUx5evDqEUJZID4NhIBTBo6p8gd7yIElAv3jo7nE6RgJrVbsNs3/YkjRA+jWil 8dPajfiGyC78vlbv9IymTlIzjmOY5wteD2XS+yNbTDKzc9xHxQH/dpW2dunXqnIMBpKk w9pIy2FaSQSpC1Cdxc2vZlCeFgfVZcbyj73UNtszTdgQwj0P0XfOud1J+HER79zbHVdJ lUzHqyr0WlbJ7CZ6GyLF4Rgryap6RcRbx6b3ecRzKv6J4CCqR0GdMXynqe2H/wTAQx8c eyvw== X-Gm-Message-State: AOJu0Yy7yghnm+rl9kW0OZ7ZiKSfhsAgfLSz+ztimYrdBbER7xt1yAut V631Eib9nSbXtWuW4MpsBCGedilOyTdzaSl5405R/An61UBxuaGzJ4HZy+RnzXFn+/275AUVnKq f X-Google-Smtp-Source: AGHT+IFUrWuah1UyKUQecrTWU1E5zOQhXjeOhf9pePn3pcH2dyPh5k/OshIOFaGtaJDUSQuxUs3NBg== X-Received: by 2002:a17:902:ecd1:b0:1f9:d0da:5b2f with SMTP id d9443c01a7336-20388b47f8cmr37412775ad.39.1724356093611; Thu, 22 Aug 2024 12:48:13 -0700 (PDT) Received: from patrick-ThinkPad-X1-Carbon-Gen-8.hq.rivosinc.com ([50.145.13.30]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855e1609sm16250925ad.160.2024.08.22.12.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 12:48:13 -0700 (PDT) From: Patrick O'Neill To: gcc-patches@gcc.gnu.org Cc: rdapp.gcc@gmail.com, juzhe.zhong@rivai.ai, kito.cheng@gmail.com, jeffreyalaw@gmail.com, gnu-toolchain@rivosinc.com, Patrick O'Neill Subject: [PATCH 4/9] RISC-V: Reorder insn cost match order to match corresponding expander match order Date: Thu, 22 Aug 2024 12:46:27 -0700 Message-ID: <20240822194705.2789364-5-patrick@rivosinc.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240822194705.2789364-1-patrick@rivosinc.com> References: <20240822194705.2789364-1-patrick@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org The corresponding expander (riscv-v.cc:expand_const_vector) matches const_vec_duplicate_p before const_vec_series_p. Reorder to match this behavior when calculating costs. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_const_insns): Relocate. Signed-off-by: Patrick O'Neill --- gcc/config/riscv/riscv.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index dc9e9280c8c..eb1c172d1ce 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -2142,15 +2142,6 @@ riscv_const_insns (rtx x, bool allow_new_pseudos) ...etc. */ if (riscv_v_ext_mode_p (GET_MODE (x))) { - /* const series vector. */ - rtx base, step; - if (const_vec_series_p (x, &base, &step)) - { - /* This is not accurate, we will need to adapt the COST - * accurately according to BASE && STEP. */ - return 1; - } - rtx elt; if (const_vec_duplicate_p (x, &elt)) { @@ -2184,6 +2175,15 @@ riscv_const_insns (rtx x, bool allow_new_pseudos) return 1 + 4; /*vmv.v.x + memory access. */ } } + + /* const series vector. */ + rtx base, step; + if (const_vec_series_p (x, &base, &step)) + { + /* This cost is not accurate, we will need to adapt the COST + accurately according to BASE && STEP. */ + return 1; + } } /* TODO: We may support more const vector in the future. */