From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23900 invoked by alias); 9 Jun 2004 01:23:34 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 23875 invoked from network); 9 Jun 2004 01:23:31 -0000 Received: from unknown (HELO shockwave.systems.pipex.net) (62.241.160.9) by sourceware.org with SMTP; 9 Jun 2004 01:23:31 -0000 Received: from nowt.org (81-178-225-237.dsl.pipex.com [81.178.225.237]) by shockwave.systems.pipex.net (Postfix) with ESMTP id 18C781C000E9; Wed, 9 Jun 2004 02:23:30 +0100 (BST) Received: from wren.home (wren.home [192.168.1.7]) by nowt.org (Postfix) with ESMTP id 33B55AC92; Wed, 9 Jun 2004 02:23:30 +0100 (BST) From: Paul Brook Organization: CodeSourcery To: fortran@gcc.gnu.org Subject: Re: [gfortran] Compute x**(-n) as (1/x)**n Date: Wed, 09 Jun 2004 03:00:00 -0000 User-Agent: KMail/1.6.2 Cc: Toon Moene , "gcc-patches@gcc.gnu.org" References: <40C5F85F.80006@moene.indiv.nluug.nl> In-Reply-To: <40C5F85F.80006@moene.indiv.nluug.nl> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200406090223.29880.paul@codesourcery.com> X-SW-Source: 2004-06/txt/msg00479.txt.bz2 On Tuesday 08 June 2004 18:33, Toon Moene wrote: > The following change, which I bootstrapped on powerpc-unknown-linux-gnu > (C and f95) without regressions, leads the Fortran front-end to generate > expressions x**(-n) with n constant as if they were written (1/x)**n. > > This will enable more opportunities for CSE in case multiple powers of > the same base are needed in an expression. E.g., the following: > > function force(d) > force = d**(-2) + d**(-6) + d**(-8) + d**(-12) > end Well, it also has the reverse effect on the following code: force = d**(-2) + d**2 I guess this is probably a less common case, so your patch is ok. The real solution is to teach the optimizers how to do this transformation themselves. I'm not offering to do that though ;) Paul