From patchwork Tue Aug 27 00:36:56 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: 1977062 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=guJtjC19; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4Wt7wq4vH9z1yh3 for ; Tue, 27 Aug 2024 10:39:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7C64F385DDFF for ; Tue, 27 Aug 2024 00:39:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id DD2753858C56 for ; Tue, 27 Aug 2024 00:37:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DD2753858C56 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 DD2753858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::32f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724719064; cv=none; b=rlW5cN4jNEO8+peEfa4OfqEC/Sjz4U6qpRXNnZUawrLf7WF0jXKZHurgXIOzWWjCwJMLx6o6guoXFet05DWTTk4GQ68yeoXRSxlImC7j2OO3hjnJVSMu3jb+wWKoc3WU18II5YRPSN0X6SOWidZyYYompRVnidMj64G60lUTFZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724719064; c=relaxed/simple; bh=OcHaP9EeizDA+Z5wUrovHX3/o8EcD6C43YFxkuMlDjs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cm2ajG3NWiuTyUKjHWJ5ZqEULJaaXsJa8SV7bba6H95g830V+Hv9d9UCmBw9J29a/KiRSCskqWhhlldGv7W+ifoKkrwtyCLDAwBqqjoz/DcwtN0lggzADhVrpJe5j4ScSJAR2fIB1u8lfai76KmJgMSXobCkiaWmmhkBKy8xjHM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-70e07c1ab31so3936611a34.0 for ; Mon, 26 Aug 2024 17:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724719062; x=1725323862; 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=hCX4M6G+uqRnmXUjmeW8t6JAC1eUsoyECUkz6u9WLS8=; b=guJtjC19vIjU1R4/VxKoFv6sHIEtoBD3j+82se52Bri3cmONyjkyncy3NqzOD32Dhk Bbvqu+GYTyi4lMgutZn3BRq/JdOL/vdh/LvIk514a+7UYvePn2pvKdsIhi5MMHZL++gt UaiSt5xgEqDIwIr18zidPrrHxsWNyJsh3GYd495QAuliERJ7d1UT/8rbFRHyUiwdKEoI s72wBVTB0bVPGevvVfVVvyMLkniaSKfVV4z2EfYF9SXMytIFBWpNZ9O0mFgPvK63ov5B FY4C6i+O48bmpUTRKh9AgZegMm1dYGyEhJkbW2PO+X9LewhOy1f7oz2Spm/BsWvrNE9t UG4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724719062; x=1725323862; 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=hCX4M6G+uqRnmXUjmeW8t6JAC1eUsoyECUkz6u9WLS8=; b=YLejQ6eVwisV+DDqMiKCin5XvZUBnoyVMOaFyhAFeR7G4Vd6xDpSJMWzjP5m4wTDIx vOCh7l6Y2lbXeWMT6m5XtIw6pEpIrOt3EuZjcwCULobcsCszPAGbW5kb324gnzBHt0Ub 0JsLxrYivxQ/7dS5gGTqqoVfGHPJOsqM1gdWwro+USJ6QEfn/8Tci59LPivUyuun/lKo UfvaU5OxJUVm8yioqavehp0O9bPcEhEjlLzYU5ahfA7aKuhArKyf++mAkATpEjZwyxAF EB1MkqBGTpdycOhmxnbM+QBL1o4gVyLX6tS9o1pWrjmsA49KdhRQcqxWSKM7a0VfMMP6 IZfQ== X-Gm-Message-State: AOJu0YzYya1Ikz8oaZfgJJEQ0ZprgsidkZCqdA8qfCzm3Rws0mfss3Zz m3Nqw3T0SYpPcbW7mtWWUU8JYGKniCEc7K3pehuqSH3CUqPxb0bGA44l8MMYjzh1Fby590h4gDN Q X-Google-Smtp-Source: AGHT+IGSGRmL4bKDiJUL2W56i4CXfeC69t72F/z1oUbJd9RtYlVLll/1tQ+lmMDZ5zfC0aFBjTVsWg== X-Received: by 2002:a05:6830:4493:b0:704:470d:638a with SMTP id 46e09a7af769-70f482ef0acmr1142576a34.3.1724719061795; Mon, 26 Aug 2024 17:37:41 -0700 (PDT) Received: from patrick-ThinkPad-X1-Carbon-Gen-8.hq.rivosinc.com ([50.145.13.30]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ac982dasm6941173a12.17.2024.08.26.17.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 17:37:41 -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 v2 2/9] RISC-V: Reorder insn cost match order to match corresponding expander match order Date: Mon, 26 Aug 2024 17:36:56 -0700 Message-ID: <20240827003710.1513605-3-patrick@rivosinc.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240827003710.1513605-1-patrick@rivosinc.com> References: <20240827003710.1513605-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 --- Ack'd here: https://inbox.sourceware.org/gcc-patches/3a97eb17-32fe-4cf4-874e-5c4a707b2c27@gmail.com/ --- gcc/config/riscv/riscv.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.34.1 diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 8538d405f50..640394e0cb8 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)) { @@ -2186,6 +2177,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. */