From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com 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 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: [PR106746] drop cselib addr lookup in debug insn mem Organization: Free thinker, does not speak for AdaCore Errors-To: aoliva@lxoliva.fsfla.org 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 Content-Type: text/plain 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 List-Id: 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; +} -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Disinformation flourishes because many people care deeply about injustice but very few check the facts. Ask me about