{"id":2223020,"url":"http://patchwork.ozlabs.org/api/patches/2223020/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260414082141.763453-1-wangzicong@masscore.cn/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260414082141.763453-1-wangzicong@masscore.cn>","list_archive_url":null,"date":"2026-04-14T08:21:41","name":"RISC-V: Make tuple vector not tieable to some modes.","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"f874fac217309b1554ea88c42cc650c5171e7834","submitter":{"id":93140,"url":"http://patchwork.ozlabs.org/api/people/93140/?format=json","name":"wangzicong","email":"wangzicong@masscore.cn"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260414082141.763453-1-wangzicong@masscore.cn/mbox/","series":[{"id":499801,"url":"http://patchwork.ozlabs.org/api/series/499801/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=499801","date":"2026-04-14T08:21:41","name":"RISC-V: Make tuple vector not tieable to some modes.","version":1,"mbox":"http://patchwork.ozlabs.org/series/499801/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223020/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223020/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n dmarc=none (p=none dis=none) header.from=masscore.cn","sourceware.org; spf=none smtp.mailfrom=masscore.cn","server2.sourceware.org;\n arc=none smtp.remote-ip=159.226.251.21"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fvy2z1clWz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 18:23:00 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 57B6C4BA2E16\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 08:22:56 +0000 (GMT)","from cstnet.cn (smtp21.cstnet.cn [159.226.251.21])\n by sourceware.org (Postfix) with ESMTPS id 588704BA2E07\n for <gcc-patches@gcc.gnu.org>; Tue, 14 Apr 2026 08:22:03 +0000 (GMT)","from localhost.localdomain (unknown [118.112.177.130])\n by APP-01 (Coremail) with SMTP id qwCowABXAm4c+d1pvrQgDQ--.13S2;\n Tue, 14 Apr 2026 16:21:49 +0800 (CST)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 57B6C4BA2E16","OpenDKIM Filter v2.11.0 sourceware.org 588704BA2E07"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 588704BA2E07","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 588704BA2E07","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776154924; cv=none;\n b=eAQs/vOm1/VA75qYrpBA/klovIq7c3nML0bhHCHEJx42ltWIenyY4/xXyuzdmYU6hGJkLCQYzODuruKoTMCIxAloHsoPMoOFwMptykfaGZAGrh1VQtDycPEDVi9LfK7ualZiGJRLl7roG1fMrTzS1Pz7GFOKbUaGjjks0K9jrZ4=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776154924; c=relaxed/simple;\n bh=R0fPTHeiq+OoM/lxoWpB62La1rpsclIRl7Tjr+CC2gI=;\n h=From:To:Subject:Date:Message-Id:MIME-Version;\n b=lRc2wKsw+y9kvqkKD8hdG3OqeWJvZxmJb0zRwhB51udRFrgSIp+lqAjKoRJwn5fwiK12X2gUh2AFrB6euXQiHAZ51iTZu6xDX3EqYCaVbdSY1Gxm4CqIZ/r3GPh4v48OB7wFi958ETmNEjpcIHWinWWFVZ9+3V+tw9sWAEuIu7w=","ARC-Authentication-Results":"i=1; server2.sourceware.org","From":"wangzicong <wangzicong@masscore.cn>","To":"gcc-patches@gcc.gnu.org","Cc":"Zicong Wang <wangzicong@masscore.cn>","Subject":"[PATCH] RISC-V: Make tuple vector not tieable to some modes.","Date":"Tue, 14 Apr 2026 16:21:41 +0800","Message-Id":"<20260414082141.763453-1-wangzicong@masscore.cn>","X-Mailer":"git-send-email 2.25.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-CM-TRANSID":"qwCowABXAm4c+d1pvrQgDQ--.13S2","X-Coremail-Antispam":"1UD129KBjvJXoWxZrW5ZF1fCFW8uryDtFWDJwb_yoW5KrWxpa\n 17Gw4IkF1kAFZrJF1fKry7Jw43u34kGrn8Ww1fur47Ca9YqrWvvFyqqw4fWFy7GFWrCry7\n Cwn8CF1Y9w1DX3DanT9S1TB71UUUUUJqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2\n 9KBjDU0xBIdaVrnRJUUUkS14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0\n rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02\n 1l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r1j\n 6r4UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJV\n WxJr1ln4kS14v26r1Y6r17M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE\n 6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72\n CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7\n MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr\n 0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUXVWUAwCIc40Y0x0E\n wIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJV\n W8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAI\n cVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjfUnCJmUUUUU","X-Originating-IP":"[118.112.177.130]","X-CM-SenderInfo":"pzdqw6xlfr0w46pd22pfruvhdfq/","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"From: Zicong Wang <wangzicong@masscore.cn>\n\nThis patch makes riscv tuple vector modes not tieable to vector modes with \ndifferent inner mode.  Without this patch some unnecessary type conversions \nmay occur, especially when zvl is specified.  \nE.g. RVVMF2x4HI and RVVM2DI are tieable in gcc trunk, and when extracting \nan inner vector mode RVVMF2HI from RVVMF2x4HI and zvl is specified, it will \nbe converted to DI, which is not expected.\n\n        PR 124448\n\ngcc/ChangeLog:\n\n        * config/riscv/riscv.cc (riscv_modes_tieable_p):\n        Make tuple vector modes not tieable to vector modes with different \n        inner mode.\n\ngcc/testsuite/ChangeLog:\n\n        * gcc.target/riscv/rvv/autovec/pr124448.c: New test.\n\nSigned-off-by: Zicong Wang <wangzicong@masscore.cn>\n\n---\n gcc/config/riscv/riscv.cc                     | 25 +++++++++++++\n .../gcc.target/riscv/rvv/autovec/pr124448.c   | 37 +++++++++++++++++++\n 2 files changed, 62 insertions(+)\n create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/pr124448.c","diff":"diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc\nindex a6106547757..9aba7b763fc 100644\n--- a/gcc/config/riscv/riscv.cc\n+++ b/gcc/config/riscv/riscv.cc\n@@ -10897,6 +10897,31 @@ riscv_modes_tieable_p (machine_mode mode1, machine_mode mode2)\n      E.g. V2SI and DI are not tieable.  */\n   if (riscv_vector_mode_p (mode1) != riscv_vector_mode_p (mode2))\n     return false;\n+\n+  /* We don't allow tuple vector modes to be tied to any vector mode\n+     that has different inner mode.  It may cause unnecessary type\n+     conversions.\n+     E.g.  RVVMF2x4HI and RVVM2DI are not tieable.  */\n+  if (riscv_tuple_mode_p (mode1) || riscv_tuple_mode_p (mode2))\n+  {\n+    machine_mode subpart_mode1, subpart_mode2;\n+    if (riscv_tuple_mode_p (mode1))\n+    {\n+      subpart_mode1 = riscv_vector::get_subpart_mode (mode1);\n+      subpart_mode1 = GET_MODE_INNER (subpart_mode1);\n+    }\n+    else\n+      subpart_mode1 = GET_MODE_INNER (mode1);\n+    if (riscv_tuple_mode_p (mode2))\n+    {\n+      subpart_mode2 = riscv_vector::get_subpart_mode (mode2);\n+      subpart_mode2 = GET_MODE_INNER (subpart_mode2);\n+    }\n+    else\n+      subpart_mode2 = GET_MODE_INNER (mode2);\n+    if (subpart_mode1 != subpart_mode2)\n+      return false;\n+  }\n   return (mode1 == mode2\n \t  || !(GET_MODE_CLASS (mode1) == MODE_FLOAT\n \t       && GET_MODE_CLASS (mode2) == MODE_FLOAT));\ndiff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr124448.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr124448.c\nnew file mode 100644\nindex 00000000000..fd74c509849\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr124448.c\n@@ -0,0 +1,37 @@\n+/* { dg-do compile } */\n+/* { dg-options \"-march=rv64gcv_zvl128b -O3 -mrvv-vector-bits=zvl\" } */\n+/* { dg-skip-if \"\" { *-*-* } { \"-O0\" \"-O1\" \"-O2\" \"-Os\" \"-Og\" \"-Oz\" } } */\n+\n+#include <stdint-gcc.h>\n+\n+void dct( int16_t d[16], int16_t dct[16] )\n+{\n+    int16_t tmp[16];\n+    for( int i = 0; i < 4; i++ )\n+    {\n+        int s03 = d[i*4+0] + d[i*4+3];\n+        int s12 = d[i*4+1] + d[i*4+2];\n+        int d03 = d[i*4+0] - d[i*4+3];\n+        int d12 = d[i*4+1] - d[i*4+2];\n+        tmp[0*4+i] =   s03 +   s12;\n+        tmp[1*4+i] = 2*d03 +   d12;\n+        tmp[2*4+i] =   s03 -   s12;\n+        tmp[3*4+i] =   d03 - 2*d12;\n+    }\n+    for( int i = 0; i < 4; i++ )\n+    {\n+        int s03 = tmp[i*4+0] + tmp[i*4+3];\n+        int s12 = tmp[i*4+1] + tmp[i*4+2];\n+        int d03 = tmp[i*4+0] - tmp[i*4+3];\n+        int d12 = tmp[i*4+1] - tmp[i*4+2];\n+\n+        dct[i*4+0] =   s03 +   s12;\n+        dct[i*4+1] = 2*d03 +   d12;\n+        dct[i*4+2] =   s03 -   s12;\n+        dct[i*4+3] =   d03 - 2*d12;\n+    }\n+}\n+\n+/* { dg-final { scan-assembler-times {vsetivli} 1 } } */\n+/* { dg-final { scan-assembler-not {vslidedown\\.vi} } } */\n+\n","prefixes":[]}