From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 2E2183858415 for ; Sun, 19 Sep 2021 15:14:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E2183858415 Received: by mail-pf1-x433.google.com with SMTP id c1so10927115pfp.10 for ; Sun, 19 Sep 2021 08:14:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=U1SuFBeOpFM5fpemr9WuJMhcBTSMwINSIZVEU3U8/3k=; b=F7y/Ba9jyEtgbJkfpupGXVjP5p9lD5LqgbtQCDrGcOxoBonh+JwE+C7a8KjhboIHZi 3gTd5LPIN5ZhKVT4rfcFgdCPYPDDbPiUF1SQBI7yyorTQKLLZSiruqtCcru9MFi1q3sa RCpt3J0uDfTx3oNjiSjUaaw8I+tlh69lLhwjvIq+fS5GDeEv1BQi1RDYkt5FFGaaCwXp BlUFSDMsZydrNXO2TM0gK4L8UED+0KMUd+jXPodWwnCjEUWEqCwi558pOfCcCUQ4fNsA HqfigbqORpcDxz3nQ0oBWWuhu5y2mdkAzZl+uATT9hOhtSjHrgOHiHBT98JI+O+/jmu2 px0A== X-Gm-Message-State: AOAM530gG0zOdZLOtnX5GJCpVTS1eKWyxrxczndzZLymqI3o3LitVtRQ omaTznNm3PDhSgx/aWoEgV3I8wkGeT0= X-Google-Smtp-Source: ABdhPJwKTTOEmqIav2G30Fr04CF1AG0U9M60E55ZTkmB7EpByp8P28Qd/a50x+dnfk1TSq8YVDVJ8g== X-Received: by 2002:a63:215c:: with SMTP id s28mr19324740pgm.99.1632064496686; Sun, 19 Sep 2021 08:14:56 -0700 (PDT) Received: from [172.31.0.175] (c-98-202-48-222.hsd1.ut.comcast.net. [98.202.48.222]) by smtp.gmail.com with ESMTPSA id a1sm790315pjg.0.2021.09.19.08.14.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Sep 2021 08:14:56 -0700 (PDT) Subject: Re: [PATCH] Simplify paradoxical subreg extensions of TRUNCATE To: Segher Boessenkool , Roger Sayle Cc: 'GCC Patches' References: <001401d7a2a5$5bf07db0$13d17910$@nextmovesoftware.com> <20210906101414.GT1583@gate.crashing.org> <001401d7a312$d7ca09c0$875e1d40$@nextmovesoftware.com> <20210906142454.GU1583@gate.crashing.org> From: Jeff Law Message-ID: <7c18f738-6399-451d-d1d1-25f010d2e555@gmail.com> Date: Sun, 19 Sep 2021 09:14:55 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210906142454.GU1583@gate.crashing.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Sun, 19 Sep 2021 15:14:59 -0000 On 9/6/2021 8:24 AM, Segher Boessenkool wrote: > Hi! > > On Mon, Sep 06, 2021 at 12:32:13PM +0100, Roger Sayle wrote: >> I think the current documentation is sufficient. During compilation, GCC's >> combine pass will often substitute a register with an expression defining >> it's value, and then attempt to simplify it. As you point out, this often >> produces >> (temporary intermediate) expressions with poorly defined semantics. > Not "poorly defined". The documentation says (in rtl.texi) > > @findex subreg > @item (subreg:@var{m1} @var{reg:m2} @var{bytenum}) > > @code{subreg} expressions are used to refer to a register in a machine > mode other than its natural one, or to refer to one register of > a multi-part @code{reg} that actually refers to several registers. > > It goes on to say there also are subregs of mem currently; it > exhaustively lists all things you can take a subreg of, what the > different semantics of those are, how the semantics are further > "modified" (read: completely different) if some RTL flags are set, etc. > > The instruction combiner very often creates invalid RTL (only > structurally valid, like, no missing operands). Invalid RTL is supposed > to never match (because backends will not have patterns that match > these). combine even creates invalid RTL on purpose (a clobber of > const0_rtx) to ensure its result is deemed invalid, when it wants to > abort a combination attempt for some reason. > >> The >> purpose of my patch is to avoid (constructing) SUBREGs that have TRUNCATE >> as an argument (that some folks consider undefined) and instead simplify >> them to either a single TRUNCATE or a SUBREG of a REG, both of which are >> well defined. I'm making/helping the implementation match the >> documentation. > But this should never make it to simplify-rtx at all. You can only > validly do such transformations in combine, because you need to know > what insns you started with etc. > > simplify-rtx is a part of combine, sure, but it is used from other > contexts as well nowadays. If you can safely do this from combine, > you can do it in combine. [ ... ] So what I think is missing here is some concrete path forward.  If I'm understanding your objection Segher, you'd like to see Roger look at where these (subreg (truncate)) expressions came from and address them earlier than simplify_rtx?  The theory being that the simplification bits could be used from other contexts than just combine and in those other contexts (subreg (truncate)) isn't valid? Jeff