From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by sourceware.org (Postfix) with ESMTPS id 4A82C38A815F for ; Mon, 3 Jun 2024 17:31:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A82C38A815F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=linux.intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4A82C38A815F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717435902; cv=none; b=mv8Xe4IU/YEQGBgcbC1S3K066/H6gc2kQ7V379PpmQliMt7nleJmIoAw9NpB5mnqN/hqqcY6pjsvVRoPuY3ykT2Dp+t3KCjm8V5NPdFtKqFktb7AbSvZN+2p0bBkjiqe+N985ivcAs+NbRlpOhgkN0fvNBsUAoY4IzCc+5ssXHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717435902; c=relaxed/simple; bh=Mmdwf4IOpqdYVKhSoutg7dx4iGqKvx88KGMUXbt8s9o=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=E97nOE3X6P1uMfqBpuHVJvBgF+cdOa7st5se/s6bg5kWstVWz6nehR/1PAQ44pGtD0bRmLnXlZFfpKKp2nMgTSNrVUexkP2mduBEle7fVQo2lD9yV57bBku8AVaHmK8z9lvPk2E8IgUdmGTMBtYQs/0QEWjH9ejj6ExAFvxK4k8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717435900; x=1748971900; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Mmdwf4IOpqdYVKhSoutg7dx4iGqKvx88KGMUXbt8s9o=; b=KVjBOry7LYDCz5pWb9/IpVxd6qCU9VYti/wRUtmyMjWQRJiAPhIFNSdq BNHZXlBvXvyV++EoN2XBpY4LKxy2v4EIDtv2LlF1tCD1SvGGvPWsenFgE Wm8qd3sVYmgA4evQ6lKfWxuz02iGFdDityR7jhJ5N5T9qPESAVN16V2Nf 2XPlGM39xXDjRT1zcEPfTAdR3UC+AWAtm4FfZ9uP7D6qmuliHsVQ9rI0+ kBzKd4no+lqSWV+1e/uJNspZ2RQuNUxHS4ny6x5shL+/mORS5vvMEr5vr zzVnLoXPx5QUlbrcrjrmPnLemjC8WeMHVk3CSDWdKY+yHza/rGQt3wFzm w==; X-CSE-ConnectionGUID: wEHrYXP+SJigVumY2kz9FA== X-CSE-MsgGUID: 3ThKhNCdRLuoB641s7fAQQ== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="39346189" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="39346189" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 10:31:38 -0700 X-CSE-ConnectionGUID: PRZdHCl9Sy+G6TE0jVOcYQ== X-CSE-MsgGUID: THZFedrLTQmzqkLNTarR1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="36834219" Received: from tassilo.jf.intel.com (HELO tassilo) ([10.54.38.190]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 10:31:37 -0700 Date: Mon, 3 Jun 2024 10:31:36 -0700 From: Andi Kleen To: Michael Matz Cc: gcc-patches@gcc.gnu.org, Richard Biener Subject: Re: [PATCH v6 1/8] Improve must tail in RTL backend Message-ID: 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,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: > > 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. There are more checks in find_tail_calls. The logic is fairly spread out. Some of it is needed to determine if it is valid. > > 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? The rules the compilers use for this are hard to understand for programmers. So that's the whole point of the attribute. If they miss some subtle requirement they get a compile time error instead of a stack overflow at runtime. So yes it has to do all the checks. > > 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. The live local variables computation is only done when there are actual suitable tail calls. And the new -O0 variant only does it for musttail, nothing else. So by default it is just a BB backwards walk until it sees a BB with enough edges to give up. -Andi