From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 5EB8D3858424 for ; Tue, 30 Jul 2024 21:04:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5EB8D3858424 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 5EB8D3858424 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::633 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722373498; cv=none; b=RvWG/ZSJ74RNZKAjD3en+Itp+eezU2xkELejvX+k3/GJfDD3iBG8WEqt/7+X6zLDcVHd/E2JFGCyf9l/Gmsw4GYdU0rr6mb2KLHVFGH6dIspInGTlLvUKh6qcHURjwJC0oZX/zlGuMN/NDLFeBuQJzBKlE9nLRpBRB7I2HiulpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722373498; c=relaxed/simple; bh=QbbsBwHHlXiyWaCxMIu4OmG3fmcF++oTkoCfrSoCB+0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=p5hUYUK2LmedIbkbqnglRXshy4E/8xsQffggvDIZ7GKSsO5MbN0N/6B00IBpeobQYMJR7T8Oh9825TuM6WtwIkrwQ63Wk0Uy/XeDeIzoRbsb8mqMMT7EIy3eeQQ1/CXMd75Mk14w79fh5bLlu62YcrN8xHy/b7tNSgPT2IDh2qE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1fc569440e1so44864025ad.3 for ; Tue, 30 Jul 2024 14:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722373493; x=1722978293; 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=hSmgLgqwlulWlyXPuf2A/cvf9CQJCHGCH+Acaq+qN6Q=; b=eKkkkSm6JjQEif8haC7o3uUoxVRApbr0yMJqDD36MZ+DAAtXSY2Mb1C5jwQ2tcGQE8 LW5PC3RdO7wQKuRyL0V64qrk8tBlcJAPseA19IUENx4vKhOKcQikGYLh08pimJkc7RM9 y1wn2PEK6hnhzdDR6moR80ASpdZXTOLdQFZqRiJH+zSrl9klGV2n4J42jPWG2eNACL4S HuED5R/hpV6r10mYMe895n7aG5aRz1zoIbBbW3Vr/DjQ2oqnLIv0dqvEkiGNg65l1+V4 xbiJMr+E3bVuJSjw464ACpwEWdTckqoZvjVHfvVRO9g4ZXmCiv6qFHxHKScDzWphrZ7b D1SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722373493; x=1722978293; 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=hSmgLgqwlulWlyXPuf2A/cvf9CQJCHGCH+Acaq+qN6Q=; b=I1Y0AEHteoG/F9ubXA+9GTIwcgxTRcbjcJRxt7M09fazCCZbiaoqa6qoUt/SKPCdMD EUcnspSFulMwkvb08c0XIkRiwokW6834EoL7HMnR3+8MBrBtku9dyarSeAvPjEENxQJ0 j7IECt6wDwun7b8LtGzewoaSoVSOEhuG1mCU7X+KRpJGCBoZoRDmZrKpdb3x3tQLBJfM i1fUgpoB9qBoKXNvBn5KrgcZM6B2d/EZXJue6ijthRBW1VHEIZj/ljhjXppGoIkgtlcB pPg5sH0tW4LYiS/Va/fTE90bmYHsxdtyRUhnnKRHnXML/pZW/bD7d0eNd/h/GzAaCIa+ gEHg== X-Gm-Message-State: AOJu0YzVako6xOgUYVa+oKGRW5A6k6mp5Uiwm5OOSeSYqcp/Uco3i7zD Wicune1172HvNtm2KshTmZIX2difIF4Qa8WmQt01dxxDJ3dBBltXxhrGbmNC X-Google-Smtp-Source: AGHT+IFwk+yWCcnLk53dsFKbCKsNmuD9ksdXv32DOJNM/mpma/2bFfB+e9U7hGvfH64zgkHMc38vqA== X-Received: by 2002:a17:902:dac9:b0:1fb:48c6:a2b0 with SMTP id d9443c01a7336-1ff047e46e7mr122723985ad.5.1722373493403; Tue, 30 Jul 2024 14:04:53 -0700 (PDT) Received: from [172.31.0.109] ([136.36.72.243]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fdb31dsm106215525ad.287.2024.07.30.14.04.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Jul 2024 14:04:52 -0700 (PDT) Message-ID: Date: Tue, 30 Jul 2024 15:04:52 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH] recog: Disallow subregs in mode-punned value [PR115881] Content-Language: en-US To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com References: From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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,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 7/19/24 11:37 AM, Richard Sandiford wrote: > In g:9d20529d94b23275885f380d155fe8671ab5353a, I'd extended > insn_propagation to handle simple cases of hard-reg mode punning. > The punned "to" value was created using simplify_subreg rather > than simplify_gen_subreg, on the basis that hard-coded subregs > aren't generally useful after RA (where hard-reg propagation is > expected to happen). > > This PR is about a case where the subreg gets pushed into the > operands of a plus, but the subreg on one of the operands > cannot be simplified. Specifically, we have to generate > (subreg:SI (reg:DI sp) 0) rather than (reg:SI sp), since all > references to the stack pointer must be via stack_pointer_rtx. > > However, code in x86 (reasonably) expects no subregs of registers > to appear after RA, except for special cases like strict_low_part. > This leads to an awkward situation where we can't ban subregs of sp > (because of the strict_low_part use), can't allow direct references > to sp in other modes (because of the stack_pointer_rtx requirement), > and can't allow rvalue uses of the subreg (because of the "no subregs > after RA" assumption). It all seems a bit of a mess... > > I sat on this for a while in the hope that a clean solution might > become apparent, but in the end, I think we'll just have to check > manually for nested subregs and punt on them. > > Tested on aarch64-linux-gnu & x86_64-linux-gnu. OK to install? > > Richard > > > gcc/ > PR rtl-optimization/115881 > * recog.cc: Include rtl-iter.h. > (insn_propagation::apply_to_rvalue_1): Check that the result > of simplify_subreg does not include nested subregs. > > gcc/tetsuite/ > PR rtl-optimization/115881 > * cc.c-torture/compile/pr115881.c: New test. OK jeff