From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id ABE043858D20 for ; Sun, 12 Nov 2023 18:02:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ABE043858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ABE043858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699812149; cv=none; b=hJTpOyyggB5o31nHSPgs0TP8BkVGMnjvSEvePpPqQXvzLCClsxRON0VERmEZ0GIkhKXE3NB97wVc697/ZYeVT4ZYD+AtMLC3VOKtgnMl0rTpKAYb2scMY1dM7sDaEVudwWsOOQC9H/NI0xVCssxq2xybqzqUHNzKrWYbdlt0VZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699812149; c=relaxed/simple; bh=lJRHoZqUZQeKp5dL9d0aRoM5vO0bxXE/uRwrEVhm6FQ=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=atacAfcvr1YXF+EwWNWjyHG7Ru78BP35M+wp5SuB9ZDbrDgp+qxmd2CAXWtad5sfU9BVIZ2yb2gf8etW9+RyEZK0YnPymUYS7WMkcyrjMm0/APiIGnoSROInUOpHZOPUe6uFhPrTl1KjSFjUeGgwisMMJO7c4NHKOoPqO5SNCJA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1cc3bb4c307so26870085ad.0 for ; Sun, 12 Nov 2023 10:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699812146; x=1700416946; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=2ZxZMUDcEraudC+6uRho6wD5VxtgI9lw8wfdrTTE30I=; b=TofZ6Dets3IWxxwtRdVJylfe29z5bvTYTPkC3GS7LOKiSMb8yBl+RP8zt4VN8C3+pK a6Z2zLOW8UjToOwMg5+aBx8kv4d7n6ytlBrzhr6bTI+WN/I7O5UUja578bGvdRhHQeUB pP+OTBYnlpkSgJ3yQ6+hDfIDu9bxDIsoA7TqmKkmvOJqEpUFEuF5OJctzXF658j04XJJ Re8BYM8faCyR3XifyZPEO4wwFROnpBKo8cxFI2eR2x+L7PBY4B1gsijDTM42ssYZXjJm 6xRNv01gBgONoMT3yiYQX1L/PYmTMoqpz68KRxmbVLtlMVr9dvTRPR7YEinQ3jGRUSps aAvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699812146; x=1700416946; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2ZxZMUDcEraudC+6uRho6wD5VxtgI9lw8wfdrTTE30I=; b=SaRo4zRwjMimn3GDyyKmcyXTKldNao5CPaA5UAnVpswtK2jt26CeECRKIUk9//T2AG 1Jlj/KWMK99PEvTMa2HYk5ekn6eVgjB0kfQYJmskxfj/kDpF+42Y8ctqebVSVS+5PvRZ ie3fmH2ySwvPTb7sy3pXsruHhjUP2rAMd+UV3Y2PIkZFot597ow/Z7PmGsFKsSVgFPzy Tiq/AKTvB1ZQMYZlebz8YRseEzLKaxB/oQVy92NClBPe7LcL03kqVO0eVhtHFKdW/RkW uPKOPCp76fu3PLXRQFkCpLfnXawmMX06NXKFXTWvhuUXgV0JBSKS3jPmGMHg2/pvGEnY 9nXQ== X-Gm-Message-State: AOJu0YwY+ZhU9HUcYLhb9hPJqE2R1Q76GeXcNll44YnDJszKcsrYF8Fl 8gg0IBI398agAqKOrWCQYjw= X-Google-Smtp-Source: AGHT+IGfFUPhiOSZt/bTZcfIHP+5t1LOP2/cz6c9Wwvp2Uq6Op0LuDeueWEhuIMWKGXwSllGr+MHVQ== X-Received: by 2002:a17:902:e801:b0:1cc:25b7:e30d with SMTP id u1-20020a170902e80100b001cc25b7e30dmr3325369plg.60.1699812146383; Sun, 12 Nov 2023 10:02:26 -0800 (PST) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id g9-20020a170902934900b001cc50c5699asm2775411plp.301.2023.11.12.10.02.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Nov 2023 10:02:25 -0800 (PST) Message-ID: <68dc5f7e-2cc6-43ba-a1ec-bf17af244476@gmail.com> Date: Sun, 12 Nov 2023 11:02:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] In the pipeline, USE or CLOBBER should delay execution if it starts a new live range. Content-Language: en-US To: Xi Ruoyao , Jin Ma , gcc-patches@gcc.gnu.org Cc: palmer@dabbelt.com, richard.sandiford@arm.com, kito.cheng@gmail.com, philipp.tomsich@vrull.eu, christoph.muellner@vrull.eu, rdapp.gcc@gmail.com, juzhe.zhong@rivai.ai, vineetg@rivosinc.com, jinma.contrib@gmail.com References: <20230814112255.2071-1-jinma@linux.alibaba.com> <37172a21172cbe6ddb580d2619ca3bf3e93b580c.camel@xry111.site> From: Jeff Law In-Reply-To: <37172a21172cbe6ddb580d2619ca3bf3e93b580c.camel@xry111.site> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: On 11/12/23 10:41, Xi Ruoyao wrote: > On Sat, 2023-11-11 at 13:12 -0700, Jeff Law wrote: >> >> >> On 8/14/23 05:22, Jin Ma wrote: >>> CLOBBER and USE does not represent real instructions, but in the >>> process of pipeline optimization, they will wait for transmission >>> in ready list like other insns, without considering resource >>> conflicts and cycles. This results in a multi-issue CPU architecture >>> that can be issued at any time if other regular insns have resource >>> conflicts or cannot be launched for other reasons. As a result, >>> its position is advanced in the generated insns sequence, which >>> will affect register allocation and often lead to more redundant >>> mov instructions. >>> >>> A simple example: >>> https://github.com/majin2020/gcc-test/blob/master/test.c >>> This is a function in the dhrystone benchmark. >>> >>> https://github.com/majin2020/gcc-test/blob/0b08c1a13de9663d7d9aba7539b960ec0607ca24/test.c.299r.sched1 >>> This is a log of the pass 'sched1' When -mtune=rocket but issue_rate >>> == 2. >>> >>> The pipeline is: >>> ;; | insn | prio | >>> ;; |  17  |  3   | r142=a0 alu >>> ;; |  14  |  0   | clobber r136 nothing >>> ;; |  13  |  0   | clobber a0 nothing >>> ;; |  18  |  2   | r143=a1 alu >>> ... >>> ;; |  12  |  0   | a0=r136 alu >>> ;; |  15  |  0   | use a0 nothing >>> >>> In this log, insn 13 and 14 are much ahead of schedule, which risks >>> generating >>> redundant mov instructions, which seems unreasonable. >>> >>> Therefore, I submit patch again on the basis of the last review >>> opinions to try to solve this problem. >>> >>> https://github.com/majin2020/gcc-test/commit/efcb43e3369e771bde702955048bfe3f501263dd#diff-805031b1be5092a2322852a248d0b0f92eef7cad5784a8209f4dfc6221407457L189 >>> This is the diff log of shed1 after patch is added. >>> >>> The new pipeline is: >>> ;; | insn | prio | >>> ;; |  17  |  3   | r142=a0 alu >>> ... >>> ;; |  10  |  0   | [r144]=r141 alu >>> ;; |  13  |  0   | clobber a0 nothing >>> ;; |  14  |  0   | clobber r136 nothing >>> ;; |  12  |  0   | a0=r136 alu >>> ;; |  15  |  0   | use a0 nothing >>> >>> gcc/ChangeLog: >>> * haifa-sched.cc (use_or_clobber_starts_range_p): New. >>> (prune_ready_list): USE or CLOBBER should delay execution >>> if it starts a new live range. >> OK for the trunk.  It doesn't look like you have write access and I >> don't see anything about what testing was done.  Standard practice is >> to >> do a bootstrap and regression test on a primary platform such as x86, >> aarch64, ppc64. >> >> I went ahead and did a bootstrap and regression test on x86_64, then >> pushed this to the trunk. > > Unfortunately this patch has triggered a bootstrap comparison failure on > loongarch64-linux-gnu: https://gcc.gnu.org/PR112497. It's also causing simple build failures on other targets. For example c6x-elf aborts when compiling gcc.c-torture/execute/pr82210 (and others) with -O2 with that patch applied. I've reverted it for now. I'm not going to have time to investigate this week. Jeff >