From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 09CBB3858D38 for ; Fri, 14 Oct 2022 17:10:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 09CBB3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x436.google.com with SMTP id 3so5473943pfw.4 for ; Fri, 14 Oct 2022 10:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=OAi7dFgA9BsBNy6RtjTHqr6Kni53vly4Tirt9ACWz1E=; b=GwSyFLV8RIXSPyyVn9HRpCD9XH2t+ybd9sm4l/o8pdlcBYCCW1VmSspUJ7k0xKGJDW w+zgH6RFTVSEaQ/RqwhKIP5LGttJNHdlnf5eXACYvjzM0ZKtBz8bBNNyLNKvItxSA0mI LOEAxxlFZnQqCuOv4NYlO+TW6dBAZN5zdX/Va51a2Ycqmnog4HUs9UEBsusUHGYVaDIX lXrdYKuoutIxWLYmXqsv5wJkuwFghOpet1hbOvvVGOHTs98Hymg8ejJljSSYAJbEgLcT RTc+5U0Ry5Y9w3HHS9mRs8NC+LFhgFzV8vz0cXDJWqRACNZXnb4Kn+//tLwdNns2E0nO nu1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=OAi7dFgA9BsBNy6RtjTHqr6Kni53vly4Tirt9ACWz1E=; b=D/SFPsZS1hCRWY9P3GGL+YSF3A7jqWRdxqILbXConLc/Nr8iTHJl7VZwGoBwJUD2aW XQIsO8iiCSCmUwW+dtfnBByFU+5IXsUEsX1s+ixjaq6iULZZUHMyyROKFtZqdHN3FL1Q DtZ0l4WbLdgHB06fkztCo9PWUY2mUGsNKSpvf5LCypzreqAOeRJjDe1LZY2ROYatRS5a 6ZxFGfxI9keDduiPQjlP/Wyja74VUgDbUohofGG4T6zwo1uRHdKgMIjf6dBnjyA5e0Fa Is60cfVcyCL2edJpZqtHOzBQnBzl2/LonE8bm5LQremyE73fHKyoQkuyBMFGFLgC4htk hXGA== X-Gm-Message-State: ACrzQf0k1q/PTrJ0MLZ8rFof/FheQO2a90lAqhp7VfyWHgGf9TOuMDbz 9xUOv5m0i9LomBkIm7m/RT083hVwows= X-Google-Smtp-Source: AMsMyM65fMoiswX2/iWjIQmB5XxPsUDs4/JWvLHSn1ULcFsVTQMgfpFXy9upxYqHZatMA++4SKFhrA== X-Received: by 2002:a63:2b4b:0:b0:440:2963:5863 with SMTP id r72-20020a632b4b000000b0044029635863mr5288397pgr.28.1665767420925; Fri, 14 Oct 2022 10:10:20 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id o63-20020a62cd42000000b0056258a3606csm1942938pfg.215.2022.10.14.10.10.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Oct 2022 10:10:20 -0700 (PDT) Message-ID: Date: Fri, 14 Oct 2022 11:10:18 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH] Always enable LRA Content-Language: en-US To: "Koning, Paul" Cc: GCC Patches References: <40062fc8-42d4-40a7-cb53-250af8c98b89@gmail.com> <7C52148F-A6D1-475F-B19D-2C340770B8EC@dell.com> From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.1 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 10/14/22 10:37, Koning, Paul wrote: > >> On Oct 14, 2022, at 10:38 AM, Jeff Law via Gcc-patches wrote: >> >> >> On 10/14/22 06:37, Koning, Paul wrote: >>>> On Oct 13, 2022, at 9:07 PM, Jeff Law via Gcc-patches wrote: >>>> >>>> >>>> On 10/13/22 17:56, Segher Boessenkool wrote: >>>>> h8300 fails during GCC build: >>>>> /home/segher/src/gcc/libgcc/unwind.inc: In function '_Unwind_SjLj_RaiseException': >>>>> /home/segher/src/gcc/libgcc/unwind.inc:141:1: error: could not split insn >>>>> 141 | } >>>>> | ^ >>>>> (insn 69 256 327 (set (mem/f:SI (pre_dec:SI (reg/f:SI 7 sp)) [12 S4 A32]) >>>>> (reg/f:SI 7 sp)) "/home/segher/src/gcc/libgcc/unwind.inc":118:12 19 {*movsi} >>>>> (expr_list:REG_ARGS_SIZE (const_int 4 [0x4]) >>>>> (nil))) >>>>> during RTL pass: final >>>>> which looks like a backend bug, I don't see a pattern that could split >>>>> this (without needing an extra clobber)? >>>> I'm aware of this -- its invalid RTL: >>>> >>>> Uses of the register outside of an address are not permitted within the >>>> same insn as a use in an embedded side effect expression because such >>>> insns behave differently on different machines and hence must be treated >>>> as ambiguous and disallowed. >>> I had a bit of a fight with this sort of thing in pdp11, where in fact such operations are executed differently on different machine models. The solution I picked is to create two sets of machine-specific constraint codes, one for "register N" and the other for "autoinc/dec of any register other than N" and pairing those. (You can see this in pdp11.md, the mov definition.) >> I've long suspected the pdp11 was the inspiration for this restriction (I have memories of noting it before I relocated to Utah, so circa 1992). The key problem is the generic parts of the compiler don't know what the semantics ought to be -- so it's not obvious when they do a substitution whether or not the substitution of one reg for another is actually valid. It's important to remember that sometimes when we substitute one register for another, we don't have any contextual information about source vs dest -- it's a long standing wart that causes problems in other cases as well. >> >> That punts the problem to the backends and the H8 actually tries to deal with this restriction. Basically in the movxx pattern conditions, when the destination uses an autoinc addressing mode, the pattern's condition will check that the source register is different. I would expect other ports likely to do something similar. >> >> But that approach falls down with reload/lra doing substitutions without validating the result. I guess it might be possible to cobble together something with secondary reloads, but it's way way way down on my todo list. > Aren't the constraints enforced? My experience is that I was getting these bad addressing modes in some test programs, and that the constraints I created to make the requirement explicit cured that. Maybe I'm expecting too much from constraints, but my (admittedly inexperienced) understanding of them is that they inform reload what sort of things it can construct, and what it cannot. It's not really a constraint issue -- the pattern's condition would cause this not to recognize, but LRA doesn't re-recognize the insn.  We might be able to hack something in the constraints to force a reload of the source operand in this case.   Ugly, but a possibility. Jeff