From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by sourceware.org (Postfix) with ESMTPS id 9F5943858D3C for ; Fri, 19 Jan 2024 23:21:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F5943858D3C 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 9F5943858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705706499; cv=none; b=Wunicpkk73dd/lD9BJ5hXrCSdiereAc61mAuluSJNoghsFTGJ0pg/5T0VOktKHBjjoJfb4U5P6+qDqi+zbxWJmdDAxngCF3qoGL48NP52zS+21LFI1Mk6PK1SmVw6FDvyvnz+aTvVpnvUp71K5IR5PuMFolDtTmUMW78ApQjVvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705706499; c=relaxed/simple; bh=qIcue2MstmbuNfZu0dZIbOgyi0WBw/5rIA87vOldhUc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=PPr48N1lSLK6AhzgN2BUdrpIdWoaS5Md1Bs1h4PWaZNSWBxvDQazBJQej/13n0XaeLsNcm/xM5boSqZ6F2SduOJpnf1M7khzIqo9ErFPC2WY3MOyg325TwKnBQeGkFoyXfN0gZ7Y0qmtfClh8ntwoT+ikGqBqn9GmOaqL2jf3hY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-7bf5829c697so42210739f.1 for ; Fri, 19 Jan 2024 15:21:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705706497; x=1706311297; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=9/FDcmOXl13kgFlHLhcDCI1NKeGtpL2/GOikbEm+jGk=; b=RFBjqYOmC8CVV1lSvPlOKR5bg6tdzKAVKjIaLDXm0Hw8UGg55KnHxtMrlEevS+1If8 dWpc/imYqIsYZvTjYVffzC8LFGl4QZLjZSHlScMHKeXj7yohoLcQqHjaF6b3Q4oRbOyJ xSAQ5L3A4VEfwduDSG9oZt/W/Dkge4tTvkYQlvFDYEFt8p7kMRVhVjRnOknE8OZU/MzB nDZKZ62KzEmy2oy7jXw5mzprJeewXiUk9tW/X6+Hp3d+QYj/ugJXQFnWly1sPU2d9GzR +8UtGpx+2s5RQUlIl9qH/El2vX+uxygnRqrxzQ6M0kOfLpw34Cg6OPRMGIElDJK522j+ nIVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705706497; x=1706311297; h=content-transfer-encoding:in-reply-to:from:references: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=9/FDcmOXl13kgFlHLhcDCI1NKeGtpL2/GOikbEm+jGk=; b=episiLCGvv5MLivPUkx830JY+LTl8q2D2B7E0IYgxf4RTZSHn/MMv3ISHNL6pT6tpy X93yjwtsYAf0DoY/seM3gA/17iNJ7JRzQx0b6oinWI3h7by2GWNjR48V5/An8Jx0ENe2 R984iE0J4LPI4Ok1iP4nK66OZkgo1Nbe9dGulLkuFHKc1RpNE0foTf00bBIXooObxkiS 1jFbYAA4JmZ1bCcedPH4oPXe2mhIyaJJAedOYTYGo99OiAC9q7OK+YARMEX1dwqZGMSu VKwCbIN7EVyREcPsFNDdlhVJoTTWwEgk8GtDHyfjUXP4Sl5lKvi2L0BIVEQqebdO98Lb 67Ow== X-Gm-Message-State: AOJu0YyaHBMN4bbniyUlNSyh6sUTIR8j7ckZco9iDohpMu1eZuM/mlY2 l4ZpOvIXTj4VNir2luEjrJs/t/wcx8YfIfNT/vNZ1RHD3KnDmjef7zoIOzHM X-Google-Smtp-Source: AGHT+IH24G3fWfNWjHMv8/2Piu5Oq0jimDE5amO5Ftlxb87tFoN8iCcoK5h0m+44jlgSI/9hGEaLjA== X-Received: by 2002:a5e:c201:0:b0:7bf:885e:bd6e with SMTP id v1-20020a5ec201000000b007bf885ebd6emr76229iop.41.1705706496727; Fri, 19 Jan 2024 15:21:36 -0800 (PST) Received: from [172.31.0.109] ([136.36.72.243]) by smtp.gmail.com with ESMTPSA id g17-20020a02b711000000b0046e7bf8731csm1800610jam.126.2024.01.19.15.21.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Jan 2024 15:21:36 -0800 (PST) Message-ID: <8a2551f1-37d3-45f8-90ad-9a17217a4a18@gmail.com> Date: Fri, 19 Jan 2024 16:21:34 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Avoid ICE on m68k -fzero-call-used-regs -fpic [PR110934] Content-Language: en-US To: Mikael Pettersson , gcc-patches@gcc.gnu.org References: <20240117172527.27233-1-mikpelinux@gmail.com> From: Jeff Law In-Reply-To: <20240117172527.27233-1-mikpelinux@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 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 1/17/24 10:03, Mikael Pettersson wrote: > PR110934 is a problem on m68k where -fzero-call-used-regs -fpic ICEs > when clearing an FP register. > > The generic code generates an XFmode move of zero to that register, > which becomes an XFmode load from initialized data, which due to -fpic > uses a non-constant address, which the backend rejects. The > zero-call-used-regs pass runs very late, after register allocation and > frame layout, and at that point we can't allow new uses of the PIC > register or new pseudos. > > To clear an FP register on m68k it's enough to do the move in SFmode, > but the generic code can't be told to do that, so this patch updates > m68k to use its own TARGET_ZERO_CALL_USED_REGS. > > Bootstrapped and regression tested on m68k-linux-gnu. > > Ok for master? (I don't have commit rights.) We can certainly have new uses of the PIC register after reload. What we can't do is allocate a new scratch register after reload to hold the address of the object from the GOT. It's a subtle difference. Because we're zeroing call used registers and we only do this at return points, we could (in theory) use one of the call-used address registers as a scratch. Doing that requires (AFAICT) defining the same target hook you're using, so it's not any cleaner from that point of view. > > +/* Implement TARGET_ZERO_CALL_USED_REGS. */ > + > +static HARD_REG_SET > +m68k_zero_call_used_regs (HARD_REG_SET need_zeroed_hardregs) > +{ > + rtx zero_fpreg = NULL_RTX; > + > + for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) > + if (TEST_HARD_REG_BIT (need_zeroed_hardregs, regno)) > + { > + rtx reg, zero; > + > + if (INT_REGNO_P (regno)) > + { > + reg = regno_reg_rtx[regno]; > + zero = CONST0_RTX (SImode); > + } > + else if (FP_REGNO_P (regno)) > + { > + reg = gen_raw_REG (SFmode, regno); > + if (zero_fpreg == NULL_RTX) > + { > + /* On the 040/060 clearing an FP reg loads a large > + immediate. To reduce code size use the first > + cleared FP reg to clear remaing ones. Don't do Minor typo. s/remaing/remaining/ I'll fix that and push the patch to the trunk. It's as clean as other approaches I pondered would likely be. Jeff