From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15994 invoked by alias); 29 Jul 2003 11:57:30 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 15986 invoked from network); 29 Jul 2003 11:57:28 -0000 Received: from unknown (HELO mx03.uni-tuebingen.de) (134.2.3.13) by sources.redhat.com with SMTP; 29 Jul 2003 11:57:28 -0000 Received: from bellatrix.tat.physik.uni-tuebingen.de (bellatrix.tat.physik.uni-tuebingen.de [134.2.170.113]) by mx03.uni-tuebingen.de (8.12.3/8.12.3) with ESMTP id h6TBvQen018828; Tue, 29 Jul 2003 13:57:26 +0200 Received: from bellatrix.tat.physik.uni-tuebingen.de (localhost [127.0.0.1]) by bellatrix.tat.physik.uni-tuebingen.de (8.12.3/8.12.2/SuSE Linux 0.6) with ESMTP id h6TBvQKA030141; Tue, 29 Jul 2003 13:57:26 +0200 Received: from localhost (rguenth@localhost) by bellatrix.tat.physik.uni-tuebingen.de (8.12.3/8.12.3/Submit) with ESMTP id h6TBvPIS030097; Tue, 29 Jul 2003 13:57:25 +0200 X-Authentication-Warning: bellatrix.tat.physik.uni-tuebingen.de: rguenth owned process doing -bs Date: Tue, 29 Jul 2003 12:25:00 -0000 From: Richard Guenther To: Gabriel Dos Reis cc: gcc@gcc.gnu.org Subject: Re: std::pow implementation In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-AntiVirus: checked by AntiVir Milter 1.0.2; AVE 6.20.0.1; VDF 6.20.0.50 X-SW-Source: 2003-07/txt/msg01964.txt.bz2 On 29 Jul 2003, Gabriel Dos Reis wrote: > Richard Guenther writes: > > | On 29 Jul 2003, Gabriel Dos Reis wrote: > | > | > Richard Guenther writes: > | > > | > | Can such be done for 3.4 and possibly 3.3, too? > | > > | > This is mainly an inlining problem with the compiler. Please fix the > | > compiler, don't obfuscate the library. > | > | cmath.tcc:std::__cmath_power is not even declared inline. > > That can be fixed if I'm given enough data ways to reproduce them. > (The body of that function is already available in any translation > unit that use it) Testcase would be: double foo(double x, int n) { switch (n) { case 0: return std::pow(x, 0); case 1: return std::pow(x, 1); case 2: return std::pow(x, 2); default: return 0.0; } } And scan for the call to std::__cmath_power. It should be absent for -O2. > | to something avoiding the call to std::__cmath_power. And I dont > | expect inlining heuristics to consider constant arguments even for > | tree-ssa in 3.5 timeframe. > > Assume __cmath_power is defined inline, then if GCC refuses to > inline it is because it is broken: it thinks it knows better than the > programmer whereas it does not. I know. But its easy to fix the common case with existing gcc infrastructure and it gets me away from Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls ms/call ms/call name 9.50 1.67 1.67 105523470 0.00 0.00 double std::__cmath_power(double, unsigned) for my scientific app. If this ends up the same way as the __attribute__((leafify)) discussion, I'll stop complaining now and instead just file a PR for the record. Richard. -- Richard Guenther WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/