From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 8C6643858029 for ; Fri, 2 Feb 2024 22:48:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8C6643858029 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8C6643858029 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::634 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706914102; cv=none; b=tBqL5T28LsEGJtNRUoTc1xAbuFKCy2PwgpPpudTi4U6IPRsFhvAF702ODne7E3Y03EfL70gzzHBTNZMDdbapHTtbFwo+zq16x/dgPTWBUvn04J+crpOFI6yNU25eKvIaFqZmXG23OgcQ94UtGLgi+4GFbQPpmzIANg5K1JwDVJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706914102; c=relaxed/simple; bh=sCsP719O3P7Pd67zvvtg0gw/ZcPd61PQksRlIa5kfiE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=vKDwwX8P/m0LBT0BjwXYN5Da7tWl82ddKf9jPisc0yNLeN4PqYPUdyRbMW81uplYmreRHvtcGT9nJ++LfzIzXNVHNdNmTpK2MBCrFybyTKqThR4wXXAev8tZbLqrGVC7S8niRmX3Qkp2gPJYYUtqbr5ydpHzKm3NfSpavZZIMA4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d944e8f367so22717605ad.0 for ; Fri, 02 Feb 2024 14:48:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706914099; x=1707518899; darn=gcc.gnu.org; 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=MrKljXcAYaPAaC2Zi+zOj68lFoE2WhOrB9iHTys33yI=; b=mXrZCAf7fg2ka7KmmQKzSnmtvexhddzNPXs8OqHCmCZlf5WMpvuCurabi4QHH2WZd1 qAFiRiKHGsTyxrJtgk3+bHK9/KLZScyBjVFtWuy00/IkDfGe48djd1KNSaIkv3z7Hp+r Jkua6jtiuAbelBDBR6P2/9yb2UaJ3Tgi5356ANdVAeOeWsZmsQuaxaMlJiMpFek4/pTK b87NmwifzWLqj3o0mlybx3nXlJh6zdF2j4sDbHZdHKaCXgbkbgoFcRQBIaknGsqSLssa iD63PosJraUFZF4LiVwbvDkzZpIgc0x+IVk6OLLXMN0iz0LE55bpQho44hY9WORF/0TQ 1zmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914099; x=1707518899; 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=MrKljXcAYaPAaC2Zi+zOj68lFoE2WhOrB9iHTys33yI=; b=HfxG5aZDzGE2jJwVDX8pBEOZATNaGUG13kpTTA9X2egNEhgxRCBoBUrZtB88BXS4tr ThzxbXUQkdzJTJr28N5UbfO3s0r4/WkEMaLvNAK098YIGiURlbQSyGsSLt73Y/F0Kpxh MjpBW6r59BlOHoILog/xcONxOmYSfH5peWpxp6f5XnjcTire7e5EDNgy1ngmlUyNKtc7 aVMqCqV5RwBh2Q3tPg8ahDjslxa6bE1DaSr2h38IKjG12ktNx0Qy7JsgLpChX4zx7mse C16axd9AuaNObRJFmDtHXqJY0iebgDof7sa+jv2wyMX4kXZ44DdLnOSOjwscHQ6kkwxd QIJw== X-Gm-Message-State: AOJu0YygjDrW3x3eLNnx/7d7ecuvTuA4kPHnGtowczCG9Lzd7RO50M9W 8vzH7l7iVxdpOnFQDc0mV+ZCh9ilBa4iD6t0x7we+E4NYqVnLA1xblqUt8+hWtG3BQkcjW8x2Np u+NQ= X-Google-Smtp-Source: AGHT+IFDsH09+jKT0Y9PvK3BABFWdzXGiQl4D34cVIZgx7aqdVNrHhmjZbFkbjjonGatdcVfZeKfcg== X-Received: by 2002:a17:902:e546:b0:1d9:5b0d:a2bc with SMTP id n6-20020a170902e54600b001d95b0da2bcmr6884406plf.53.1706914099533; Fri, 02 Feb 2024 14:48:19 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUrmWkLD9VWLn64C8XiYjwrkhbKG1kfIPM+fM1X7Yr/x/6QziUOyGc8M7LO8V45+KwrhW75fp8xPHMnwIpfdSKBLlsqEpnMGQeIPQ== Received: from [192.168.0.2] (67-1-159-105.tcso.qwest.net. [67.1.159.105]) by smtp.gmail.com with ESMTPSA id jc18-20020a17090325d200b001d9537cf238sm2096972plb.295.2024.02.02.14.48.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Feb 2024 14:48:19 -0800 (PST) Message-ID: <3f212170-f555-4f78-aff9-2ebdb8d4cc78@rivosinc.com> Date: Fri, 2 Feb 2024 15:48:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] combine: Don't optimize SIGN_EXTEND of MEM on WORD_REGISTER_OPERATIONS targets [PR113010] Content-Language: en-US To: Jeff Law , Richard Biener Cc: gcc-patches@gcc.gnu.org References: <20240116221914.267015-1-gkm@rivosinc.com> <03b351a0-a5f4-48ab-bc67-765eabf5dbcd@rivosinc.com> From: Greg McGary In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,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 2/1/24 10:24 PM, Jeff Law wrote: > > On 2/1/24 18:24, Greg McGary wrote: > >> However, for a machine where (WORD_REGISTER_OPERATIONS && >> load_extend_op (inner_mode) == SIGN_EXTEND), the high part of a PSoM >> isĀ  only known at runtime as 0s or 1s. That's the downstream bug. The >> fix for such machines is either (A) forbid static evaluation of the >> high part of a PSoM, or (B) forbid transforming (SIGN_EXTEND (MEM >> ...) ) into a PSoM. My patch does B. Perhaps you prefer A? The >> trouble with A is that in the zero-extend case, it is valid to >> statically evaluate as 0. It is only the sign-extend case that isn't >> known until runtime. By the time we have a PSoM, its upstream >> ancestor as sign- or zero-extend is already lost. >> >> Does that give you the understanding you desire, or are there deeper >> mysteries to probe? > It's a good start and I can see what you're trying to do -- and it may > in fact be correct -- the quick discussion with Palmer Tuesday and > your follow-up have helped a lot). > > But just to be sure, what's the incoming rtl at function entry? just > "debug_rtx (x)" should be sufficient. input: (sign_extend:DI (mem/c:SI (symbol_ref:DI ("minus_1") [flags 0x86] ) [1 minus_1+0 S4 A32])) result: (subreg:DI (mem/c:SI (symbol_ref:DI ("minus_1") [flags 0x86] ) [1 minus_1+0 S4 A32]) 0) Later, the high part of the PSoM statically evaluates to 0, the code to load and test is elided, and the incorrect alternative is emitted unconditionally. G