From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by sourceware.org (Postfix) with ESMTPS id E4EB43858D20 for ; Sat, 11 Nov 2023 20:12:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E4EB43858D20 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 E4EB43858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699733569; cv=none; b=rC0p2tm2AEGY3KYY+WFXzr2llmOofPsQWHFsUM9sYg7OVOnVmE05WZKUsUASC/iTwU9lZnxlFevGPjseim5deZKC5LyZPzLF8U1rslN+i6Jk6gfTfIlzEXjdaxzgdU9+D5gYlPT1/wi/kyemzWXTmedKClaHV5v28M/1jN9Wxk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699733569; c=relaxed/simple; bh=Tfh2oAMvxodrOMeg8N+cU/uWIGNgjFg6tQrz3cD/Xhg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=cnFx3C1d/o2Y1pzeaa3hiHeZ49we1JLWEMuxXWISsSYzoVjWq0zeC86CqDRDZs9JUBTNQ0BpSmXf32DXaLZVCK4MdZzU/IqIdx+iBTeuaD7DE+DZRF9VukTQv7n8rhsFTNnvx/d7+O8svWM5kWDz8wrnEGi5NzZeN1BH8juKNv4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-7ad1236c419so113418939f.0 for ; Sat, 11 Nov 2023 12:12:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699733567; x=1700338367; 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=Vtsm2q5JSK7YitLyfzF2pMhwXMUZuD8+rT6Z6p/SO5A=; b=Y+RpDhuH6rJnIlCBb74UnfvsOGaMdTfsI9pkNBCkqlJKpNmkx+DcvnGY+hGFn+t5Po N40KyTukV2L6X8dFo903QW1JYndojIgUL2L6aGa5h31slPiZwuYlFGhnpONmK23v3HEo ZEI1n6swFzP8UyQnnn02DryS4fXtiQBJ+ZPakXJUJK+1y3F22n3s3J6fpn+rSIbbfQQk ATfeBCAVnAxptw8v1FhMioZw2r9/cf8j7AUDfNg6TkYjit/FnP70rlcPRTwgFaV+i3yJ Rc5rdB1OtaorPfq8F0tnAs3u83CdpOAFj8dDhQ37EXv4U2rmqpXQRpvzNMdUnQqE1R8z f8rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699733567; x=1700338367; 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=Vtsm2q5JSK7YitLyfzF2pMhwXMUZuD8+rT6Z6p/SO5A=; b=SvE1u+qpofBb0PWdghLvk6o/rjerYEOb7Yei6vQ+EtlY/YTRmNI9wD/V2uAKgoHwTc rF9QjsQhWVeYX8IVmPgKysZX4ABYGR95tohrju91YK86Wx8tW2HviMJRfuWyeG7ThjS4 sfO3GarKfg4IWvIVOwu4/Pq+pnki7wfDGKJcN86+We3/nSn59O+1Rd10nQlR2EK+BdWh gcad5D7VCq1a0ebF0sAon9ZKfX2KOmQTqFcAbAujkyAaLb/nV+yOYr+GuZUVDZXVUHoE SgJXD80v1kfymm95AK9KaMVEWV9Ka/FVKptsH1Rs3zDIL0KP5KPlOUSCswqe3nLoFjBc SApg== X-Gm-Message-State: AOJu0YxM2vBokaDjZH8HPc+DvcTyZTXwMCBTrupsqrmMAH2lGtDU3oHk IBlVgVecO3of4+HAxX1v9fk= X-Google-Smtp-Source: AGHT+IGqHBNojLwVP1na92nfx2cQoLUDYNARVJFLsqkPJ6gQ272MfmmZntrBRFjqfPRLLPktqUvufg== X-Received: by 2002:a05:6602:2ac4:b0:792:8230:c175 with SMTP id m4-20020a0566022ac400b007928230c175mr3993900iov.6.1699733567047; Sat, 11 Nov 2023 12:12:47 -0800 (PST) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id q3-20020a0566380d0300b0042b2f0b77aasm612576jaj.95.2023.11.11.12.12.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Nov 2023 12:12:46 -0800 (PST) Message-ID: Date: Sat, 11 Nov 2023 13:12:44 -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: 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> From: Jeff Law In-Reply-To: <20230814112255.2071-1-jinma@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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,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 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. Thanks for your patience, jeff