From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id 1DDD93849AEA for ; Fri, 10 May 2024 12:51:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1DDD93849AEA 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 1DDD93849AEA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::129 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715345472; cv=none; b=UK3qvs9fhVWCu/XVofTlx2wTdm8v5tPZUev0PmZ08TrW8S2pd0wz2LfRALjJRKjUx/dpfDx8hL7Hc/r8ohJZrjeEMEAIferWibSjPBkD6bqK7mWhxTXiCjxQDbWcOHFjRb/isJvIvOkOtCN5dNMlKYNwfNx4R8u+F6wlb2m1Hz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715345472; c=relaxed/simple; bh=bjhzaXNzV5sK+Z4YbpUYZss1Gy9yV/8taurCouJYBzs=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=GKUlNIrtdTo7SypuVUIQ3tRob6IoERawwTtLV2FfGSMahcHDBggNcKDwfePLnYx0DtZwa6HU6xgmgxDw82X7QNHUkywoMubzuuk9C6fdBafJHq23U2RxOZO7/4U1mtAgxSo5iZ/q9zGl/f/LF2wNjz7JmkCcuyWJQQPRsWHePWA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-51f12ccff5eso2672523e87.1 for ; Fri, 10 May 2024 05:51:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715345468; x=1715950268; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=md6umWEThFE4Hs7+bGyFpNPGqTHZF6XoNwDpoayuvEw=; b=D1d5GKwwxpf0JUhdvIgCkpWQYXhqP9sDr0rXIsxrf3lBlAoLyoJJ0CtqDCXTQK30RV Rq//8LAnJKHPTffQvPhDFGsDRnhtzoZQqpBx0CkEn4ROGFohQ5Hk+wevESZ9Ipvfu5Pw YbhZPjkjqniUDLLQLh3IShUEV5ZlFA2tXJkTmmSOAtujWv9e7Ktxw5F5UIDfNXwIT2RU KK50FBi96q3mRHCdUegkLZoCSeIUdsHCTvqU3o7x6uQklOzX//Hr+r1o7rXxTt9pjJip 9Y/OHBucU++d2Jm+hS4k6bxmBBPiBmTt4cUSYgsYIh13my/pSLHogqgyIjr3MPWS9hl/ 2lZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715345468; x=1715950268; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=md6umWEThFE4Hs7+bGyFpNPGqTHZF6XoNwDpoayuvEw=; b=KycYioDbTzg0E2ozOM7aFWmFfWr+CudRhM8UdwcBS+EWJ88up/skpI02S4FIBoM7jL /6W7eIhJtnUcmsiUVhum2sLH8SkK74wx790qRfXqC30WdG53bCzLoP7CxwoKNvLtfGCY KUf4JWQMUAS6ALRtyFjCLboQccjw+24Kr8tyGPwZXJchXrhJCXUzcfMGW/v1TseJk+oQ bil8pFCkBGUNy9EPYJeA0TvoCM4Z1ggCCSyblQEOKYVxeqiHXH668I4Rc8EjoilpkXCX /EnsiFCHw8TYwZH1PmXE74BObSk3p/VYm50uX6tRLphwvCtI9yNOCmEOYg0gnZj265F2 Qucw== X-Forwarded-Encrypted: i=1; AJvYcCWpwSL6q0nfbbT3p7ADZg2g7e8/6IAag0n4HcqilXst9sZE5KMiI1uFyMBr96El+GNdatFUJKZMXsbwltwl2aC8Re8IvTDXsw== X-Gm-Message-State: AOJu0YxIWcqhpsOaSjP0RKL/9TLJc8CyENq+qCtcImRYuJb5yBh4sikN Fdn7DmA4uAWsTcb94r5PRYw5WKPYD3QZxMH/zRs8Gk+XNU4z2VBit6hpT8f/wUbS3FrFaTVU0ev ak6e3MdQsHFMvri/ezQgh/VQUK1C3aw== X-Google-Smtp-Source: AGHT+IEKmOQu8Vn0GlWYYcyMm52eyGlVVbC9j0bMIP9vFMyWcIRNyl5BFkmWDQC7tm4Q18vNnwLrEpno5/tM9ahnML8= X-Received: by 2002:a05:6512:21e:b0:521:a96:bf15 with SMTP id 2adb3069b0e04-5221017e306mr1611374e87.38.1715345468158; Fri, 10 May 2024 05:51:08 -0700 (PDT) MIME-Version: 1.0 References: <9b57c474-b33b-4a89-82f2-f9a33b1810df@linux.ibm.com> <20240510090421.GA19790@gate.crashing.org> <20240510105211.GB19790@gate.crashing.org> In-Reply-To: <20240510105211.GB19790@gate.crashing.org> From: Richard Biener Date: Fri, 10 May 2024 14:50:56 +0200 Message-ID: Subject: Re: [PATCH] rtlanal: Correct cost regularization in pattern_cost To: Segher Boessenkool Cc: HAO CHEN GUI , gcc-patches , David , "Kewen.Lin" , Peter Bergner , Jeff Law Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.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 Fri, May 10, 2024 at 12:54=E2=80=AFPM Segher Boessenkool wrote: > > On Fri, May 10, 2024 at 12:19:35PM +0200, Richard Biener wrote: > > On Fri, May 10, 2024 at 11:06=E2=80=AFAM Segher Boessenkool > > wrote: > > > *All* code using a cost will have to be inspected and possibly adjust= ed > > > if you decide to use a different value for "unknown" than what we hav= e > > > had for ages. All other cost functions interacting with this one, to= o. > > > > Btw, looking around pattern_cost is the only API documenting this speci= al > > value and the function after it using this function, insn_cost does the= same > > but > > > > int > > insn_cost (rtx_insn *insn, bool speed) > > { > > if (targetm.insn_cost) > > return targetm.insn_cost (insn, speed); > > > > and the target hook doesn't document this special value. set_src_cost > > doesn't either, btw (that just uses rtx_cost). So I don't think how > > pattern_cost handles the set_src_cost result is warranted. There's > > simply no way to detect whether set_src_cost returns an actual > > value - on the contrary, it always does. > > I introduced insn_cost. I didn't think about documenting that 0 means > unknown, precisely because that is so pervasive! But for example a reg-reg move when optimizing for speed could have a zero associated cost. You might argue that's a bug since there's an actual instruction and thus at least a size cost (and decode cost) but then I've seen too much zero cost stuff in backends (like that combine PR causing s390 backend making address-cost zero even though it's just "same cost"). IMO give we're dispatching to the rtx_cost hook eventually it needs documenting there or alternatively catching zero and adjusting its result there. Of course cost =3D=3D 0 ? 1 : cost is wrong as it makes zero vs. one the same cost - using cost + 1 when from rtx_cost might be more correct, at least preserving relative costs. Richard. > > > Segher