From patchwork Tue Apr 18 17:55:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 85012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3029841vqo; Tue, 18 Apr 2023 10:55:52 -0700 (PDT) X-Google-Smtp-Source: AKy350bWQNepsohajHXmSQf3nk2eXgiKdnPuMRCDUd7UoC9jYbyAazJsW18qswGdxjYxFHBJjuK1 X-Received: by 2002:a17:907:6d11:b0:94f:59aa:8a7c with SMTP id sa17-20020a1709076d1100b0094f59aa8a7cmr9245739ejc.20.1681840552467; Tue, 18 Apr 2023 10:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681840552; cv=none; d=google.com; s=arc-20160816; b=huKYknrmKMxn9CyFWHzV26yx9H3ir6m+V7ZvPgSO413XxXh2K1/Wc5O+yrhVV6oBtb KFBgF7yQX2EoToHuBIxntSAtZ46uMvj4wo+pD3wkIyWYSGq77Spb22jDsT8aFItcuidO i4bpmSCZ/kYo1H5m19K0Q7oKnpON8alOo1UnKyQmlZH/3xmoZ9VCvth3X8HX2R+qY5PY nzkFAjFre5iNXs9ubMj69jPrzjllSvOpUvBLKLQhyOgwBX3SRnAf6A22Zpplf7gmuPVz Bb0Uedz/Qmm/4dH1/12Nx/oiD0OESA/ymZGDEM7oOHBA3Sld6IUW5aY521bJ6/LG9evn TPqA== 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:date:message-id :content-transfer-encoding:mime-version:subject:to:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=M3K/V0X9n5D+J7f1o+4sCshlJY3ubPGYeqoU4IPk3oI=; b=BH2+oz90Gyl0+Exd3+w3PVe713JtbKDbHPO2+HX6ESqTrGyNrq+i5BhO5EevDipwZJ f/dbUQzVcRWSP+hMDBMxfgHPR5pvGkP6kzfrmbl5Mdyf+hbkNc5Sw104tA8OEKhfg7Uz oc5CuzoPAyfJ3HysqnaQMrxVdyZA1omsXncSF/oyMyCrWhReNJpvMjpDrDHxPRl7rxTM OH55I03voIpCHZ1ghM4fDJ7SROv6ttgeNePPHx0YgB3DyyB4XUDSrCyo4r1evPVc8Qot nU4Q8SPWBPeIM4tmwh1bZinAo/sz/47T+E66IGa4Tmd6+WT58Uo9zicCGIqufJH4fGrr fzAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PT5ejtxl; 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 p5-20020aa7cc85000000b0050694aea395si7323633edt.616.2023.04.18.10.55.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 10:55:52 -0700 (PDT) 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=PT5ejtxl; 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 226083858002 for ; Tue, 18 Apr 2023 17:55:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 226083858002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681840551; bh=M3K/V0X9n5D+J7f1o+4sCshlJY3ubPGYeqoU4IPk3oI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=PT5ejtxl09Bgj32HhLbhZVpRtEhsnAXRvl3W7P2QVHS1v0k54KnftsNdsXbRrhDXY 9k+QyL1Va84CVs8RCSEqtn0cKaayUkQndkg7gMSSn8zd+nb8Po0ezhbS0OFVi617ZP pv5ot4PKCoVVUObByyHD69G6oIwnR9hju7O16/sg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by sourceware.org (Postfix) with ESMTPS id 8CDBE3858D1E for ; Tue, 18 Apr 2023 17:55:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8CDBE3858D1E To: Subject: [PATCH] doc: Document order of define_peephole2 scanning MIME-Version: 1.0 Message-ID: <20230418175507.2C40B2040B@pchp3.se.axis.com> Date: Tue, 18 Apr 2023 19:55:07 +0200 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, 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 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: Hans-Peter Nilsson via Gcc-patches From: Hans-Peter Nilsson Reply-To: Hans-Peter Nilsson 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?1763537639324768219?= X-GMAIL-MSGID: =?utf-8?q?1763537639324768219?= Generated pdf inspected. Ok to commit? Thoughts on fixing the IMHO wart to also expose all replacements to all define_peephole2? Looks feasible (famous last words), but then again I haven't checked the history yet. -- >8 -- I was a bit surprised when my define_peephole2 didn't match, but it was because it was expected to partially match the generated output of a previous define_peephole2. I had assumed that the algorithm exposed newly created opportunities to all define_peephole2's. While things can change in that direction, let's start with documenting the current state. * doc/md.texi (define_peephole2): Document order of scanning. --- gcc/doc/md.texi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 07bf8bdebffb..0f9e32d2c648 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -9362,6 +9362,14 @@ If the preparation falls through (invokes neither @code{DONE} nor @code{FAIL}), then the @code{define_peephole2} uses the replacement template. +Insns are scanned in forward order from beginning to end for each basic +block, but the basic blocks are scanned in reverse order of appearance +in a function. After a successful replacement, scanning for further +opportunities for @code{define_peephole2} matches, resumes at the last +generated insn. I.e. for the example above, the first insn that can be +matched by another @code{define_peephole2}, is @code{(set (match_dup 3) +(match_dup 4))}. + @end ifset @ifset INTERNALS @node Insn Attributes