From patchwork Fri Aug 2 01:51:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1968090 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=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=E0t44o12; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WZpjR1ggVz1ybX for ; Fri, 2 Aug 2024 11:51:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CA19A385842C for ; Fri, 2 Aug 2024 01:51:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by sourceware.org (Postfix) with ESMTPS id 1EB923858D26 for ; Fri, 2 Aug 2024 01:51:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EB923858D26 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1EB923858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722563490; cv=none; b=fsQlslMNmIvqM4AHXG/1wzAnlMVHETaGmjf5s9Kxb5DrBamyE4YM+U4vR4j6X1c0cBagKhZvPMSfHMYnyavhEF3SN1sAQifYfNDSRT1yH460P+lj4rRTBeV29KU83ods1hLtqIrxYH5gMdTGJ0i36qgBUMZxjMVcU3U+nR0e55I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722563490; c=relaxed/simple; bh=NS7UUioR4GNAStIljxlwv6gyJ8nRdVxeJCOsXsZaMmw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qJYjdFNM7ig4B3ddKGdp/Gj183vRm36MO/P2nv2v8b4GrpaFagOqfZVI3TtxFs9ML2tC8OKjVdIqn7QpRKhcNP9UoLgnqTJaunMA7cbAbvO1MgjK4iWR3Cc/8bZ6z6AA84xZb/sd4JmBLsvJvj5E9bWSpfjXK1jY/mT5iy5x3ko= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 471LaoxD009864 for ; Fri, 2 Aug 2024 01:51:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=SAUNsqmGbncxHTiQscF/6g sL/EnmZXCGFoQE6PG2jYw=; b=E0t44o124/pAsOMFFaqpTuvp6ClpiD3kTU33kN fRanKZfrKCbNQiP84m+4vicAdVe5ka6Bs094VDh7CDDhSsJ7KkMWctIdish9BKLq /q9wJd7b92L4HJumi4bk40vWm8cLfphB9uJe44tJHW0sAPjnoxXnnyubprtAbjz7 KRF5+vKKFDLUbu9YIdVoSaiLDIwoan+Ai6IZildJw60JPsMlhNABNVaa6VFOoZTn 6J1IaQxOJ8yLjLTSkM7ivgqI+7PSGrXb+W+FpTit0Yp0PNMHKiCKMa8/dxzmUw3i HD5+b5ME24z4J/qgTizIVMe9WihQOtrTVBc58SWMbfo5Pk6A== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 40rje6gd3q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Aug 2024 01:51:26 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 4721pQKS011324 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 2 Aug 2024 01:51:26 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Thu, 1 Aug 2024 18:51:26 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] genemit: Fix handling of explicit parallels for clobbers [PR116058] Date: Thu, 1 Aug 2024 18:51:15 -0700 Message-ID: <20240802015115.1690338-1-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: k2wseZmzNVFNYyzsE_BVphpVf_x51_mC X-Proofpoint-ORIG-GUID: k2wseZmzNVFNYyzsE_BVphpVf_x51_mC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-01_23,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=541 suspectscore=0 malwarescore=0 mlxscore=0 impostorscore=0 clxscore=1015 adultscore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408020011 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, SPF_HELO_NONE, SPF_NONE, 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.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 In a define_insn, you could use either an explicit parallel for the insns or genrecog/genemit will add one for you. The problem when genemit is processing the pattern for clobbers (to create the function add_clobbers), genemit hadn't add the implicit parallel yet but at the same time forgot to ignore that there could be an explicit parallel there. This means in some cases (like in the sh backend), add_clobbers and recog had a different idea if there was clobbers on the insn. This fixes the problem by looking through the explicit parallel for the instruction in genemit. Bootstrapped and tested on x86_64-linux-gnu. PR middle-end/116058 gcc/ChangeLog: * genemit.cc (struct clobber_pat): Change pattern to be rtvec. Add code field. (gen_insn): Look through an explicit parallel if there was one. Update store to new clobber_pat. (output_add_clobbers): Update call to gen_exp for the changed clobber_pat. Signed-off-by: Andrew Pinski --- gcc/genemit.cc | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/gcc/genemit.cc b/gcc/genemit.cc index 98d0477424b..5d3d10f5061 100644 --- a/gcc/genemit.cc +++ b/gcc/genemit.cc @@ -35,10 +35,11 @@ along with GCC; see the file COPYING3. If not see struct clobber_pat { struct clobber_ent *insns; - rtx pattern; + rtvec pattern; int first_clobber; struct clobber_pat *next; int has_hard_reg; + rtx_code code; } *clobber_list; /* Records one insn that uses the clobber list. */ @@ -337,19 +338,25 @@ gen_insn (md_rtx_info *info, FILE *file) if (XVEC (insn, 1)) { int has_hard_reg = 0; + rtvec pattern = XVEC (insn, 1); - for (i = XVECLEN (insn, 1) - 1; i > 0; i--) + /* Look though an explicit parallel. */ + if (GET_NUM_ELEM (pattern) == 1 + && GET_CODE (RTVEC_ELT (pattern, 0)) == PARALLEL) + pattern = XVEC (RTVEC_ELT (pattern, 0), 0); + + for (i = GET_NUM_ELEM (pattern) - 1; i > 0; i--) { - if (GET_CODE (XVECEXP (insn, 1, i)) != CLOBBER) + if (GET_CODE (RTVEC_ELT (pattern, i)) != CLOBBER) break; - if (REG_P (XEXP (XVECEXP (insn, 1, i), 0))) + if (REG_P (XEXP (RTVEC_ELT (pattern, i), 0))) has_hard_reg = 1; - else if (GET_CODE (XEXP (XVECEXP (insn, 1, i), 0)) != MATCH_SCRATCH) + else if (GET_CODE (XEXP (RTVEC_ELT (pattern, i), 0)) != MATCH_SCRATCH) break; } - if (i != XVECLEN (insn, 1) - 1) + if (i != GET_NUM_ELEM (pattern) - 1) { struct clobber_pat *p; struct clobber_ent *link = XNEW (struct clobber_ent); @@ -363,13 +370,13 @@ gen_insn (md_rtx_info *info, FILE *file) for (p = clobber_list; p; p = p->next) { if (p->first_clobber != i + 1 - || XVECLEN (p->pattern, 1) != XVECLEN (insn, 1)) + || GET_NUM_ELEM (p->pattern) != GET_NUM_ELEM (pattern)) continue; - for (j = i + 1; j < XVECLEN (insn, 1); j++) + for (j = i + 1; j < GET_NUM_ELEM (pattern); j++) { - rtx old_rtx = XEXP (XVECEXP (p->pattern, 1, j), 0); - rtx new_rtx = XEXP (XVECEXP (insn, 1, j), 0); + rtx old_rtx = XEXP (RTVEC_ELT (p->pattern, j), 0); + rtx new_rtx = XEXP (RTVEC_ELT (pattern, j), 0); /* OLD and NEW_INSN are the same if both are to be a SCRATCH of the same mode, @@ -383,7 +390,7 @@ gen_insn (md_rtx_info *info, FILE *file) break; } - if (j == XVECLEN (insn, 1)) + if (j == GET_NUM_ELEM (pattern)) break; } @@ -392,10 +399,11 @@ gen_insn (md_rtx_info *info, FILE *file) p = XNEW (struct clobber_pat); p->insns = 0; - p->pattern = insn; + p->pattern = pattern; p->first_clobber = i + 1; p->next = clobber_list; p->has_hard_reg = has_hard_reg; + p->code = GET_CODE (insn); clobber_list = p; } @@ -662,11 +670,11 @@ output_add_clobbers (md_rtx_info *info, FILE *file) for (ent = clobber->insns; ent; ent = ent->next) fprintf (file, " case %d:\n", ent->code_number); - for (i = clobber->first_clobber; i < XVECLEN (clobber->pattern, 1); i++) + for (i = clobber->first_clobber; i < GET_NUM_ELEM (clobber->pattern); i++) { fprintf (file, " XVECEXP (pattern, 0, %d) = ", i); - gen_exp (XVECEXP (clobber->pattern, 1, i), - GET_CODE (clobber->pattern), NULL, info, file); + gen_exp (RTVEC_ELT (clobber->pattern, i), + clobber->code, NULL, info, file); fprintf (file, ";\n"); }