From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 334D43849ACA for ; Fri, 10 May 2024 10:19:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 334D43849ACA 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 334D43849ACA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715336389; cv=none; b=XByfVrzGuS9IzWYEud3TxizYjeCsB6DG+nSg92PJ8d7XUDFfqH6ka3JJYhc9ODi9WBNA/8r3nCiWTbiXPckb/8LksXJxe9L8wVoWfxB7rSfBNY9kUTiBOly+ozUcH7nNlX6G9XqMtYYSGjCXUaQdMwnr9Ju07FTrdDgduEVbLQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715336389; c=relaxed/simple; bh=rZ+4M6DDkCcond2+7m3x3af5PgsoBGJMiSsxi6+SbHc=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=ti14sPjRfO5bd6ZTb8zqGxB75cf2LkZqfO+QVvxMm6EAup4ad6b2CYRetTq4A0qCp62MmdlHx6dLnMaNwFYXrjbaKKH0WqU687apyf/4x/oAlalbWBAqjU7uvRMsED+Yx3bJWAblnSWv8AKVj5eZ92bk1Fy3fzTudr85Lv66hNg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-51ff65b1e14so1973687e87.2 for ; Fri, 10 May 2024 03:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715336386; x=1715941186; 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=GHMfvRir0kaimxMbQhYJ2mdKuRSP5feQ2nhwJA+h5UY=; b=hErbr3n4BIZkDTEwIJy2ZIejWZ4TfCSB/rU9UthuleQeldohJe1Px1f+j4NywJOs5x f9nImO4Ejhx+efz4G1ztXQ6tPCcOpPDKBYySX3XiIs9hZdO9w1U1+T4Oiy77TFMJMzrz RNTxN3GfsBgUJjjntNZ6OceK2S/DE5guINu8uS7ZO3DkvDvk9HgjEcI0tuHLEJNBEYPu EcdlCwLMruSbwzEOrAFp9zQY/K86iSTJU4/ez2jyqefKxh71Yk2PGHW6JnqqLNThB3nr ARgZFIwdENItpuyO58S26zXzms1CASUAaLw/5Ew+fd9p3OtX0goqGyTNlGmSzL4OqvSE 88JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715336386; x=1715941186; 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=GHMfvRir0kaimxMbQhYJ2mdKuRSP5feQ2nhwJA+h5UY=; b=ocUsUMERFTMEYsYwIk8ftOZqa7ADvb9zt0TJGw5i6LhMYXQzzNfUBe3h0RaW7TcgPT hrBr1jYHUP6IDIEm5QKxuEZwbo4zXHU/Wo2FJN137aLR0FGQbUQHx2YJxu41Y3rHN426 Z2RtpzX5rGQ1Vo3iS2Fm6e2IMJnK3gbvIAc+cI1qNNXhwrVtHSfU2FqU9dRlwJ0xJBGB jZMGf+PLs+Yi8i2Ae0IXjThRoePYHsKbzBR+li2TYUs1IGUpdpDGjbJKiFlndXM2Ogrh YVRdRkWwFNYg0n5TOws8VhLoo6meOgxAHz4ofptu3iQUPeM01LkTr3FCJtw+6Umykzo7 C1gw== X-Forwarded-Encrypted: i=1; AJvYcCXDXyR44VTCltGiiHT/AxzV6adrqi2kfKFrTLqNpjb38IJXNWImXRAJQ/EJ3+oOXiStrUlM4I9yDIv90oLx7tK8wGjBDH7c1g== X-Gm-Message-State: AOJu0YyOBKe+GzZ0fsldmK1AzGQPjeC31ccCu6I8VCmXA8vB2jv8qXi5 29gFsXxgtKn2w4fRqiaG0RwfmbvzHcD/FBcT+YgBPhoI8mj4g0g9VfSSbZ78BBmYQbDfinFoVdK YiReH1G4BF+VhBQgQEMkN1PyV/r0= X-Google-Smtp-Source: AGHT+IETPPbTpH2vphuoqNK8XmEVDxxiH2IwDQ5mDL+fY5KIQECk5o+TvSOLxFKbS5Iow07VOJydBog1U/7z3JtU5jM= X-Received: by 2002:a05:6512:b81:b0:51e:f7de:d8eb with SMTP id 2adb3069b0e04-5220fb76879mr1776790e87.10.1715336386377; Fri, 10 May 2024 03:19:46 -0700 (PDT) MIME-Version: 1.0 References: <9b57c474-b33b-4a89-82f2-f9a33b1810df@linux.ibm.com> <20240510090421.GA19790@gate.crashing.org> In-Reply-To: <20240510090421.GA19790@gate.crashing.org> From: Richard Biener Date: Fri, 10 May 2024 12:19:35 +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.7 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 11:06=E2=80=AFAM Segher Boessenkool wrote: > > On Fri, May 10, 2024 at 04:50:10PM +0800, HAO CHEN GUI wrote: > > Hi Richard, > > Thanks for your comments. > > > > =E5=9C=A8 2024/5/10 15:16, Richard Biener =E5=86=99=E9=81=93: > > > But if targets return sth < COSTS_N_INSNS (1) but > 0 this is now no > > > longer meaningful. So shouldn't it instead be > > > > > > return cost > 0 ? cost : 1; > > Yes, it's better. > > > > > > > > ? Alternatively returning fractions of COSTS_N_INSNS (1) from set_sr= c_cost > > > is invalid and thus the target is at fault (I do think that making ze= ro the > > > unknown value is quite bad since that makes it impossible to have zer= o > > > as cost represented). > > > > > > It seems the check is to aovid pattern_cost return zero (unknown), so= the > > > comment holds to pattern_cost the same (it returns an 'int' so the be= tter > > > exceptional value would have been -1, avoiding the compare). > > But sometime it adds an insn cost. If the unknown cost is -1, the total= cost > > might be distorted. > > *All* code using a cost will have to be inspected and possibly adjusted > if you decide to use a different value for "unknown" than what we have > had for ages. All other cost functions interacting with this one, too. Btw, looking around pattern_cost is the only API documenting this special value and the function after it using this function, insn_cost does the sam= e 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. Richard. > > Segher