From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 0AD053898395 for ; Mon, 3 Jun 2024 17:18:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0AD053898395 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0AD053898395 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717435099; cv=none; b=CNcY1atXqfHAdbFXt3EfLeeulFxzOnxeTR3ftS1BisKKcr0tl1ZcgAqOwZc9UjJLSAncNejDFmAJRswmmoL50/dpuyvQ+zqQ6dakahXKdrSgr8lmXrkgKH+pWRhsGA40h4gppwgELDa/zkBMrAAC1XBmJY+JLijbOMkxibDBsJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717435099; c=relaxed/simple; bh=d83ZFii7PSOiqFO5KC1grdBNFzuskJLOkzmKYkhjd/c=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=DD/02LEbAvz2gKeCz5rZ5Io2A63/ImpYUdlzM26+9dzS/lqTLu+5j9yPUzto1qlIdRNnC1QCUa9t76q+gUY+GtcBkuTi3NXInZKsOIh+00OpTl5m3jnGLXfNBXHdmJqrYi1x1jXu0H8sp17kb/9pIiQ372Ie20GB8yuXce9VHpk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717435088; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=yBQcE+GGBjakmseDIABJQbb0ju8Qlsk/mYUvyLpL6Gc=; b=dIpyRHZaZ+FJbdAik58nOsiqJVkcDkqhaQvm96sucOZYXkgaMsB0uTQS0RloY3SjAiqkcg CFwA7WPnvPcBfB7ZVdjeDHf0eRkxE1iwpgAGtJBQNo7dZEMbuxEyKsEX6aEzkDNDSOMNgw T+O8+5TG9KrhjnH696+XKU1hi9VQ6Yw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-389-mIkIe_p5N2Ck4mSifQI_5w-1; Mon, 03 Jun 2024 13:18:04 -0400 X-MC-Unique: mIkIe_p5N2Ck4mSifQI_5w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 503EA185AD2C; Mon, 3 Jun 2024 17:18:04 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9D3E40AD3DE; Mon, 3 Jun 2024 17:18:03 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 453HHuPC140024 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 3 Jun 2024 19:17:56 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 453HHuXh140023; Mon, 3 Jun 2024 19:17:56 +0200 Date: Mon, 3 Jun 2024 19:17:55 +0200 From: Jakub Jelinek To: Michael Matz Cc: Andi Kleen , gcc-patches@gcc.gnu.org, Richard Biener Subject: Re: [PATCH v6 1/8] Improve must tail in RTL backend Message-ID: Reply-To: Jakub Jelinek References: <20240521143203.2893096-1-ak@linux.intel.com> <20240521143203.2893096-2-ak@linux.intel.com> <357aa546-91d8-8d98-f941-ac2bdafab656@suse.de> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 Mon, Jun 03, 2024 at 07:02:00PM +0200, Michael Matz wrote: > Hello, > > On Fri, 31 May 2024, Andi Kleen wrote: > > > > I think the ultimate knowledge if a call can or cannot be implemented as > > > tail-call lies within calls.cc/expand_call: It is inherently > > > target and ABI specific how arguments and returns are layed out, how the > > > stack frame is generated, if arguments are or aren't removed by callers > > > or callees and so on; all of that being knowledge that tree-tailcall > > > doesn't have and doesn't want to have. As such tree-tailcall should > > > not be regarded as ultimate truth, and failures of tree-tailcall to > > > recognize something as tail-callable shouldn't matter. > > > > It's not the ultimate truth, but some of the checks it does are not > > duplicated at expand time nor the backend. So it's one necessary pre > > condition with the current code base. > > > > Yes maybe the checks could be all moved, but that's a much larger > > project. > > Hmm. I count six tests in about 25 lines of code in > tree-tailcall.cc:suitable_for_tail_opt_p and suitable_for_tail_call_opt_p. > > Are you perhaps worrying about the sibcall discovery itself (i.e. much of > find_tail_calls)? Why would that be needed for musttail? Is that > attribute sometimes applied to calls that aren't in fact sibcall-able? > > One thing I'm worried about is the need for a new sibcall pass at O0 just > for sibcall discovery. find_tail_calls isn't cheap, because it computes > live local variables for the whole function, potentially being quadratic. But the pass could be done only if there is at least one musttail call in a function (remembered in some cfun flag). If people use that attribute, guess they are willing to pay for it. Jakub