From patchwork Wed Aug 9 11:46:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiajie Chen X-Patchwork-Id: 133182 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2746579vqr; Wed, 9 Aug 2023 05:01:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFezsG6G2y3s1Mluwq23ox5uuCWw+7yRxg8Fl7mKK1PIuRm9ysViXV3yGMnaYsM9nxT6BeG X-Received: by 2002:a2e:8898:0:b0:2b9:f007:990f with SMTP id k24-20020a2e8898000000b002b9f007990fmr1685226lji.51.1691582503723; Wed, 09 Aug 2023 05:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691582503; cv=none; d=google.com; s=arc-20160816; b=Ffs45yc48SoBQzylrlguZe7ae2Cx7IHawwWRHicInpNLrKkZzLzYIt3uX+jiu4KMfG xiF/oODRfJks+PkB6kHbCRprn5DbKVJPyXxR5ijCURkV5MS5wQ7rHN7exl0fKdOT47Nr BpkJ97vT/a/6Qje5ZQ1CvN4pwkPvUJvSkZgS88fmnSEeLOhd5d+mhxMqSwLVHg8DY+TJ CtuVv4zL4stWZK7QBVQoOrnNCbncs6bqrEyNTe16gJtlmtUr6oG50FVwejLHY3xndHNW U0mJYWKKy3WWbSQRslB1O/VrlRg8u0fkz5qvJNQJ9VUrc+DnzK16L+jmy9uRL7VGZDuf UZpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=OmeEadlvEPPSOfLSFvxinzib0b1bphbrFyD256PQV1g=; fh=nBdY3vW/mgwv3C0AxagIWVpWoiWSUh4TsWT+uiKUcFM=; b=u/gsg6rc+uV4JgkcN+kCpxOwaayJ7v2/Lj40m/Dx4ENcj9VtwWODCiJ3ArMp0zNdan b3+XxtaXg7IDAIw2c7E0IDZavjWh9lHbxAoDvAzZwkSQ62R4EeodsHfa1mNL6UKQNLuq TWgT96c/w+XrPWNv1QkA/uZCZq8E3GmP/LQDSx+dRH1u4WaN5sPhTtX8c9NoFmRA2deF 6+wMwfgNRFaJLnNIVlRlIFKVYsefo9bzrcorsOEQjYTwvGLzrWZ34DftRQQq9yc6ImqH KEfjSmkqGcmRqf8Ef0+DJPaHwI6/evKs8ZdMD87rE0Ue1C3H/qw/nM9/aenc8bkYGobE Va1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ASiliSbl; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id mf10-20020a170906cb8a00b0099367afd642si8572132ejb.66.2023.08.09.05.01.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 05:01:43 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ASiliSbl; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2A2233853D06 for ; Wed, 9 Aug 2023 11:59:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A2233853D06 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691582362; bh=OmeEadlvEPPSOfLSFvxinzib0b1bphbrFyD256PQV1g=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=ASiliSbl6sKWKHEgpFUOpsXq6VukeQLP8CNBd9EYs4Xjzy+VKIyyyJQEGNiJp0oLj tboDHj4kKPIFqpl3VNalyZ2kfrU7dwN+XZ/dh8X4jKhHsY2FNxiz8zn1+KXaFkAZWg v1j2wMT5irOzvVVPNiuf9Rr5LLusBUSHj46VwDAM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from hognose1.porkbun.com (hognose1.porkbun.com [35.82.102.206]) by sourceware.org (Postfix) with ESMTPS id 118813857C5A for ; Wed, 9 Aug 2023 11:54:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 118813857C5A Received: from cslab-raptor.. (unknown [166.111.226.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: c@jia.je) by hognose1.porkbun.com (Postfix) with ESMTPSA id E9EE644026; Wed, 9 Aug 2023 11:54:05 +0000 (UTC) To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, xuchenghua@loongson.cn, Jiajie Chen Subject: [PATCH v2 10/14] LoongArch: Forbid ADDRESS_REG_REG in loongarch32 Date: Wed, 9 Aug 2023 19:46:17 +0800 Message-ID: <20230809115325.3716347-11-c@jia.je> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230809115325.3716347-1-c@jia.je> References: <20230809115325.3716347-1-c@jia.je> MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, SPF_HELO_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jiajie Chen via Gcc-patches From: Jiajie Chen Reply-To: Jiajie Chen Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773752815623021273 X-GMAIL-MSGID: 1773752815623021273 LoongArch32 does not include LDX/STD instructions, and cannot lower (plus (reg) (reg)) pattern. Forbid ADDRESS_REG_REG and do not emit ldx/stx. gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_valid_index_p): Check ADDRESS_REG_REG pattern and fail in loongarch32. (loongarch_output_move_index): assertion failed if generating ldx/stx in loongarch32. gcc/testsuite/ChangeLog: * gcc.target/loongarch/array-ldx.c: Add regression test for ldx in loongarch32. --- gcc/config/loongarch/loongarch.cc | 4 +++- gcc/testsuite/gcc.target/loongarch/array-ldx.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/loongarch/array-ldx.c diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 49df9509ba9..1fde680ccd4 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -2016,7 +2016,8 @@ loongarch_valid_index_p (struct loongarch_address_info *info, rtx x, && contains_reg_of_mode[GENERAL_REGS][GET_MODE (SUBREG_REG (index))]) index = SUBREG_REG (index); - if (loongarch_valid_base_register_p (index, mode, strict_p)) + /* LA32 does not provide LDX/STX. */ + if (loongarch_valid_base_register_p (index, mode, strict_p) && !TARGET_32BIT) { info->type = ADDRESS_REG_REG; info->offset = index; @@ -3853,6 +3854,7 @@ loongarch_output_move_index (rtx x, machine_mode mode, bool ldr) } }; + gcc_assert (!TARGET_32BIT); return insn[ldr][index]; } diff --git a/gcc/testsuite/gcc.target/loongarch/array-ldx.c b/gcc/testsuite/gcc.target/loongarch/array-ldx.c new file mode 100644 index 00000000000..0797af3bbfb --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/array-ldx.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-march=loongarch32 -mabi=ilp32d -O2" } */ +long long foo(long long *arr, long long index) +{ + return arr[index]; +} \ No newline at end of file