From patchwork Sat Jan 14 11:26:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 43747 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp240883wrn; Sat, 14 Jan 2023 03:26:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXtD9Hpd+8TTInBbQo5W1qrCn6GZ6VLHIRlRZbyEL8Lq9zICFeuOF5Yi8cz3mm3Oh6aeiZBL X-Received: by 2002:a17:907:2113:b0:84d:4b39:1448 with SMTP id qn19-20020a170907211300b0084d4b391448mr21964333ejb.67.1673695619421; Sat, 14 Jan 2023 03:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673695619; cv=none; d=google.com; s=arc-20160816; b=IMmuI/tWSMFMIMweHqvBhQqKjQo6u/PlNyhYGVVkYS6iR3nUzsRx7aGx7mSfZXXiAG oIUY20lTueD8OyKJyMypEQub6acRUuk8y2x1hjlyljMpeaXbJ/ZztxxGBDht0uJNkVvr NtnuX1v2GPEaIclpq5hMQcqalw9H/dyRcJUoD5qAqe6AkHCLQbVKyfeZaQZRXY5qt22C SODg7+ut2h3gKWOFClwd5JzpCZWcsfSuQGKwqU5B6lG+JvcMz0zBgBydOis7Cjx2Mhgq q+ec5D9BKdniStJhJd6bD3x9AGtgMpzhx92JdZ/pPh8JFTwvLJGjqrngJTSjb37LAyGC W3ug== 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:mime-version :user-agent:message-id:date:organization:subject:to:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=Br8mxvKWt9VSaLaAaZx5lefKBJf7KfgSosynuR11POc=; b=S6vnynVGxO4wCguDQUVLvXSQu2lZHLdxMc1TFQjNXzbf77VrfgdMX7LjgUkI0Zol7v wTDlGw8Kaf0oKexvKa4T+epaGh8mAym0m74MFNafglsVqWKRORkmIg8U/eMx7aACvGV+ o75Ye40QzC2qSOrqVNAZzFkmzZ4O+SrlyVCodvAjNfYJJGUfe+1e8xS8TzfRIrSqA/lt NVuhLIPy43xn9xybZhtZJF1ycGxeiSsXPcYWdclc0yF9T3hQjx6WsedaITnod3rrF1pU 4S1N/DBC7Z+5XUC0p2ZHGhlH7eg8wTODmdge3PFGVTZ71c74u2oS5SrXhC/Dq6YeCO07 pwyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HP1UloKU; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l6-20020a170906794600b007c0a4c149bfsi512622ejo.403.2023.01.14.03.26.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Jan 2023 03:26:59 -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; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HP1UloKU; 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"; 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 2F243383FB8B for ; Sat, 14 Jan 2023 11:26:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F243383FB8B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673695618; bh=Br8mxvKWt9VSaLaAaZx5lefKBJf7KfgSosynuR11POc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=HP1UloKUv3j6n3zB0ksfl8k4mdOcuPbDJ6bMycwn7jJqv+z0zHc82i15XNtiwiB84 iNE+eefDDF73dRxTPx6CFuFljmaGEOO48yI4/xHoDY97QX3ChlScoGngw9zTrC38VW PNxJN315J2Q66hpDCNcxK/KG6HSiIo48RdU5tIgE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id 4B86E3858D39 for ; Sat, 14 Jan 2023 11:26:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B86E3858D39 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 421B4116998; Sat, 14 Jan 2023 06:26:13 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id LelbzriR7-zz; Sat, 14 Jan 2023 06:26:13 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id D55F3116993; Sat, 14 Jan 2023 06:26:11 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 30EBQ0Lb1316067 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 14 Jan 2023 08:26:01 -0300 To: gcc-patches@gcc.gnu.org Subject: [PR106746] drop cselib addr lookup in debug insn mem Organization: Free thinker, does not speak for AdaCore Date: Sat, 14 Jan 2023 08:26:00 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SCC_5_SHORT_WORD_LINES, 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 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: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754997057572495205?= X-GMAIL-MSGID: =?utf-8?q?1754997057572495205?= The testcase used to get scheduled differently depending on the presence of debug insns with MEMs. It's not clear to me why those MEMs affected scheduling, but the cselib pre-canonicalization of the MEM address is not used at all when analyzing debug insns, so the memory allocation and lookup are pure waste. Somehow, avoiding that waste fixes the problem, or makes it go latent. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog PR debug/106746 * sched-deps.cc (sched_analyze_2): Skip cselib address lookup within debug insns. for gcc/testsuite/ChangeLog PR debug/106746 * gcc.dg/target/i386/pr106746.c: New. --- gcc/sched-deps.cc | 36 +++++++++++++++--------------- gcc/testsuite/gcc.target/i386/pr106746.c | 29 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr106746.c diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc index f9371b81fb41e..a9214f674329a 100644 --- a/gcc/sched-deps.cc +++ b/gcc/sched-deps.cc @@ -2605,26 +2605,26 @@ sched_analyze_2 (class deps_desc *deps, rtx x, rtx_insn *insn) case MEM: { - /* Reading memory. */ - rtx_insn_list *u; - rtx_insn_list *pending; - rtx_expr_list *pending_mem; - rtx t = x; - - if (sched_deps_info->use_cselib) - { - machine_mode address_mode = get_address_mode (t); - - t = shallow_copy_rtx (t); - cselib_lookup_from_insn (XEXP (t, 0), address_mode, 1, - GET_MODE (t), insn); - XEXP (t, 0) - = cselib_subst_to_values_from_insn (XEXP (t, 0), GET_MODE (t), - insn); - } - if (!DEBUG_INSN_P (insn)) { + /* Reading memory. */ + rtx_insn_list *u; + rtx_insn_list *pending; + rtx_expr_list *pending_mem; + rtx t = x; + + if (sched_deps_info->use_cselib) + { + machine_mode address_mode = get_address_mode (t); + + t = shallow_copy_rtx (t); + cselib_lookup_from_insn (XEXP (t, 0), address_mode, 1, + GET_MODE (t), insn); + XEXP (t, 0) + = cselib_subst_to_values_from_insn (XEXP (t, 0), GET_MODE (t), + insn); + } + t = canon_rtx (t); pending = deps->pending_read_insns; pending_mem = deps->pending_read_mems; diff --git a/gcc/testsuite/gcc.target/i386/pr106746.c b/gcc/testsuite/gcc.target/i386/pr106746.c new file mode 100644 index 0000000000000..14f7dab71d691 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr106746.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fsched2-use-superblocks -fcompare-debug -Wno-psabi" } */ + +typedef char __attribute__((__vector_size__ (64))) U; +typedef short __attribute__((__vector_size__ (64))) V; +typedef int __attribute__((__vector_size__ (64))) W; + +char c; +U a; +U *r; +W foo0_v512u32_0; + +void +foo (W) +{ + U u; + V v; + W w = __builtin_shuffle (foo0_v512u32_0, foo0_v512u32_0); + u = + __builtin_shufflevector (a, u, 3, 0, 4, 9, 9, 6, 7, 8, 5, + 0, 6, 1, 8, 1, 2, 8, 6, + 1, 8, 4, 9, 3, 8, 4, 6, 0, 9, 0, 1, 8, 2, 3, 3, + 0, 4, 9, 9, 6, 7, 8, 5, + 0, 6, 1, 8, 1, 2, 8, 6, + 1, 8, 4, 9, 3, 8, 4, 6, 0, 9, 0, 1, 8, 2, 3); + v *= c; + w &= c; + *r = (U) v + (U) w; +}