From patchwork Mon Dec 11 07:30:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "juzhe.zhong@rivai.ai" X-Patchwork-Id: 176511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6882318vqy; Sun, 10 Dec 2023 23:30:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDbRRq01Hf9bfAHnmLh8IOXUKjV2cfznngimHAXA97wrPYij3uH7Vc7j5aiDY9ePDB39M8 X-Received: by 2002:a05:6870:799:b0:1fb:75b:99c7 with SMTP id en25-20020a056870079900b001fb075b99c7mr5702394oab.118.1702279855105; Sun, 10 Dec 2023 23:30:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702279855; cv=pass; d=google.com; s=arc-20160816; b=u0KatJda5ylxzy14ZAO38aGAqdZ3gyGb9qYHOiETFnF74ujraXOEVuUrDXjGrdHM5b RAYQaDh4Oz8el5bw+ntGOinQu/sMwCsXMdNDJ/tRwqloLYc5iu0Y1bHLjEgefZp7rUiZ 4hw4rKTHiWdI3I9Sfm9uQL0cowXMbtdwBF7G5Jnoec5h98DD8ETfS+Iruop1UtlutyY+ s4MQeUSteL9FSP/y5qoJnxI+UCUtbxksFgcnN1ERyW51h8dYeuem527rtPa7w4x53XDs aY+L1wBoWwwR0k0g5059Z9IyYaqwOMLkphDEtBAmaEa8Qc7EQB7VlLB18BQyTbdPItX6 yMIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:arc-filter:dmarc-filter:delivered-to; bh=QvFXqriEh3bYUn0V0lwWwK4ep3tb4KTtBhkSOXuI/GI=; fh=idvV5TQ1gmHAoU8u1GUGfjilVySOK+BR5TeZLoSouN8=; b=MAjfKIbtlKDczj+fN4bdrp+hZhR9Pnzw0LC/4tKNBWlfJUf+/OXSrQJc6lcbJwCX4o xVnsPJdIiCnCq03isXD6XSc1i11aZKvwi/k9DMpSbUhMZPu2YGPCUaNBlwuCoqml9br2 BNC/AhobVgAfxo5RSqAKoxUUYxmHtYqwdZk4JxS/mWNBo0R7RnZ3CjpiknC/qZ+54GBO MM+Fvcis6+KGQxCDcoHEnrBew8o46KUYFNkXBdUX6Btp3SedSHyJPT9vm5Bo+ZBDEQDr HRSJWxhhK8QX1VFEJ4jNwluVSMlrs6v1z2Fi6tYWIKN72fGfAkfFc4HaAgoKKDJGIcUy eVNg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id t8-20020a0cea28000000b0067a1b0570d1si7868212qvp.302.2023.12.10.23.30.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 23:30:55 -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; arc=pass (i=1); 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 D7D713858D37 for ; Mon, 11 Dec 2023 07:30:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) by sourceware.org (Postfix) with ESMTPS id 65CC53858C74 for ; Mon, 11 Dec 2023 07:30:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 65CC53858C74 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 65CC53858C74 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=52.59.177.22 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702279833; cv=none; b=DiyjLVxcZ6Vqnzc60pl9qnYZwAXLuAK6tcm23nLrT9VcNOeo2jhekbufR1TvzdqCQIuagkJz28MDyOBoaJu6uuBo1P6//drTWwQM5Mw+3y6K8FAJk0BhG5Q6LQQ/0eeJX9KKL3VxWhuSkl5VklC2lTzFadt2XqCd9Rczrqa/cbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702279833; c=relaxed/simple; bh=a4BMt9nwy5NzVOxasGNjvcxeZyG8gYvafBGjHpHfRVk=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=PcQjVuid3LwUP7iAX0bLH3AMzZ7ZIu51WuC5ckXpbi+HN065PRmaTzYCwwrueHYf45yi4aNhkGM4DNiYnQpTbJKjx+mGWJPMoHX3+kqKsRtfWdMWW5Rigna4wVCIu+d8wLaHqG3qSbojELVVvLXvg2KDOM7r565LwtxpVXeyJ6Q= ARC-Authentication-Results: i=1; server2.sourceware.org X-QQ-mid: bizesmtp81t1702279822t7w14zkm Received: from rios-cad122.hadoop.rioslab.org ( [58.60.1.26]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 11 Dec 2023 15:30:20 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: RrZlkntZBfkOBDY5Hh0ZslDJGPaBdJsJzQuy4FRpJSVmtOF+qb70wvaHzMd75 R19Xfb3xAKxNiW9VBzuZFELEGekKSctMEbZqIwCE4OAULX3E5pdCEKAwAjJFHsIuf1Gle+V /xnIQHvZsdDrHrf7e2xXFTTjN+MKuPuz8jK5MD+fcGNkoGz5UlAmjg5jrKQEjAi3ZSkT5OW babWGRzQvesAnnsoifG57z8vdFYZbu9rv/TMfgvwNDB1cIPABMUdJdw8AYlKUi+v6HrGUwp MuWnrdUaJ6byZFJxgyRyv1Flhjs4mbaV/dSK6GkW7UmZARxTHIcuuqjtI4ZzCVnueJV39Qp wwxBhgjARLnZ6XqCS1cE+GfDpJDzD+A/Sec0/kSGBFcyKSOhfwM2ec74+1naVLNzJ4oiL14 UqfHOWYl7c0= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 9958572244396518861 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Cc: Juzhe-Zhong Subject: [Committed] RISC-V: Fix ICE in extract_single_source Date: Mon, 11 Dec 2023 15:30:19 +0800 Message-Id: <20231211073019.2352703-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, T_SPF_HELO_TEMPERROR, WEIRD_PORT 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784969801148408793 X-GMAIL-MSGID: 1784969801148408793 This patch fixes the following ICE in VSETVL PASS: bug.c:39:1: internal compiler error: Segmentation fault 39 | } | ^ 0x1ad5a08 crash_signal ../../../../gcc/gcc/toplev.cc:316 0x7f7f55feb90f ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0x218d7c7 extract_single_source ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:583 0x218d95d extract_single_source ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:604 0x218fbc5 pre_vsetvl::compute_lcm_local_properties() ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:2703 0x2190ef4 pre_vsetvl::earliest_fuse_vsetvl_info() ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:2890 0x2193e62 pass_vsetvl::lazy_vsetvl() ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:3537 0x219406a pass_vsetvl::execute(function*) ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:3584 The rootcause we have a case that the def info can not be traced: (insn 208 327 333 27 (use (reg/i:DI 10 a0)) "bug.c":36:1 -1 (nil)) It's obvious, we conservatively disable any optimization in this situation if AVL def_info can not be tracded. Committed as it is obvious. gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (extract_single_source): Fix ICE. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/vsetvl/avl_use_bug-1.c: New test. --- gcc/config/riscv/riscv-vsetvl.cc | 2 + .../riscv/rvv/vsetvl/avl_use_bug-1.c | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/vsetvl/avl_use_bug-1.c diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index 90477f331d7..ed5a2b58ab0 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -579,6 +579,8 @@ extract_single_source (set_info *set) if (!set->insn ()->is_phi ()) return nullptr; hash_set sets = get_all_sets (set, true, false, true); + if (sets.is_empty ()) + return nullptr; insn_info *first_insn = (*sets.begin ())->insn (); if (first_insn->is_artificial ()) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/avl_use_bug-1.c b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/avl_use_bug-1.c new file mode 100644 index 00000000000..330221c2d7b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/avl_use_bug-1.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvl256b -mabi=lp64 --param=riscv-autovec-lmul=m8 --param=riscv-autovec-preference=fixed-vlmax -O2" } */ + +struct a_struct +{ + unsigned char a_character; +}; + +struct a_struct an_array[5]; +struct a_struct *a_ptr; +int yabba = 1; + +int +f (a, b) + unsigned char a; + unsigned long b; +{ + long i, j, p, q, r, s; + + if (b != (unsigned long) 0) + { + if (yabba) + return -1; + s = 4000000 / b; + for (i = 0; i < 11; i++) + { + for (j = 0; j < 256; j++) + { + if (((p - s < 0) ? -s : 0) < (( q - s < 0) ? -s : q)) + r = i; + } + } + } + + if (yabba) + return 0; + a_ptr = &an_array[a]; + a_ptr->a_character = (unsigned char) r; +}