From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id A84923858D33 for ; Sun, 10 Sep 2023 13:34:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A84923858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c1f8aaab9aso30874975ad.1 for ; Sun, 10 Sep 2023 06:34:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694352844; x=1694957644; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=OwU1zQNDC2+tLO4li5DUqJ5FyDWtEy/X/h4A7uRXlbA=; b=LHnq1gJ1RWPyu7O78WNJ6gkTPJA2YLpQ5oaI6kogTq8B/tFYzJl9FJfBz+oyowfgTY gIUuvDK6zsK2A+yr2rUGwu94OvObb8IbljVLcm5f2o81HjcsJgwMNNGEhboIowCcT6cq NcoGblu2yDZZsv3l+PefOTQrvJJU0gnmc7RYhShSI+NWAt+Q/R9I054ZJ3egtFm6eGwz bZnEHDyicWUFlV0TMg61ykGnbBrNH/HHcAi1ltUKYAsVTLJJBR4XnqNWZz5Qxhs9umke EUQX2mxKLBPZbXSUpTFZc73F5wirkHVCyjn9XIP94u7v/uqF7AlI7TASBsvMx1h6eAUV 9QHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694352844; x=1694957644; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OwU1zQNDC2+tLO4li5DUqJ5FyDWtEy/X/h4A7uRXlbA=; b=ptUx/WPJVUFHpCKOhJxuKQZAY/61y7IvR2TDJqWU5n/94tET3EuyR+NZDlSzoX6pau yRV5fSbYa3CZtK3uRQufcoJDnYIIrzIBsWpdvsnF3b+NUiHVLaj7MmSB88PByX59yt6N 1alxWRxRv5eGSn852ZHsGi4LfLXPOtr0CUgntv7CAVKQ7oa7m8AWV0J0uuZunNucMcbL lfUwOXUgjqnufQJnwQYBA+0myenTJzZzsvi7ktPbXt1PIj/D017LfFUsAVk8ypso17gJ sVKQzOBGsiZ2TOgy5VVmXkZifhKS1tHQjQvZAkLs+cevnEnUJhZZ2ZR1SuxEtgxeugXP yr+A== X-Gm-Message-State: AOJu0Yzh8hC+K/2YRIawpgnh/pIi5K3PBgd2AS2nijZs8LeSBcpscZ70 4wNNK8cD+iSOebgY7wxzw9E= X-Google-Smtp-Source: AGHT+IH9BQjcKRhs5weUCBCHa7FThtlVBuiN4k6H5VauaVbkMKO7Tp9hC0SQ9HVugchHJeSjSOfPAw== X-Received: by 2002:a17:902:d2d1:b0:1bd:c6ca:e0db with SMTP id n17-20020a170902d2d100b001bdc6cae0dbmr9443856plc.37.1694352844330; Sun, 10 Sep 2023 06:34:04 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id jj19-20020a170903049300b001b06c106844sm4648463plb.151.2023.09.10.06.34.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Sep 2023 06:34:03 -0700 (PDT) Message-ID: Date: Sun, 10 Sep 2023 07:34:02 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] RISC-V: Avoid unnecessary slideup in compress pattern of vec_perm To: Juzhe-Zhong , gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, kito.cheng@sifive.com, rdapp.gcc@gmail.com References: <20230910035538.2034153-1-juzhe.zhong@rivai.ai> Content-Language: en-US From: Jeff Law In-Reply-To: <20230910035538.2034153-1-juzhe.zhong@rivai.ai> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,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 List-Id: On 9/9/23 21:55, Juzhe-Zhong wrote: > If a const vector all elements are same, the slide up is unnecessary. > > gcc/ChangeLog: > > * config/riscv/riscv-v.cc (shuffle_compress_patterns): Avoid unnecessary slideup. > > --- > gcc/config/riscv/riscv-v.cc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc > index bee60de1d26..7ef884907b8 100644 > --- a/gcc/config/riscv/riscv-v.cc > +++ b/gcc/config/riscv/riscv-v.cc > @@ -2697,7 +2697,7 @@ shuffle_compress_patterns (struct expand_vec_perm_d *d) > rtx mask = force_reg (mask_mode, builder.build ()); > > rtx merge = d->op1; > - if (need_slideup_p) > + if (need_slideup_p && !const_vec_duplicate_p (d->op1)) > { > int slideup_cnt = vlen - (d->perm[vlen - 1].to_constant () % vlen) - 1; > rtx ops[] = {d->target, d->op1, gen_int_mode (slideup_cnt, Pmode)}; Would it be better to adjust how we compute need_slidup_p to check !const_vec_duplicate_p (d->op1) instead of doing it here? That way the name "need_slideup_p" stays consistent with the intent of the code. It would also mean we wouldn't need to duplicate the additional check if we wanted to model the use of slideup in the cost calculations. Jeff