From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25971 invoked by alias); 29 Apr 2004 11:25:34 -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 25944 invoked from network); 29 Apr 2004 11:25:32 -0000 Received: from unknown (HELO mail.physik.uni-muenchen.de) (192.54.42.129) by sources.redhat.com with SMTP; 29 Apr 2004 11:25:32 -0000 Received: from localhost (unknown [127.0.0.1]) by mail.physik.uni-muenchen.de (Postfix) with ESMTP id 28AA82044A; Thu, 29 Apr 2004 11:25:32 +0000 (UTC) Received: from mail.physik.uni-muenchen.de ([127.0.0.1]) by localhost (mail.physik.uni-muenchen.de [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 14493-01-41; Thu, 29 Apr 2004 13:25:30 +0200 (CEST) Received: from mailhost.cip.physik.uni-muenchen.de (kaiser.cip.physik.uni-muenchen.de [141.84.136.1]) by mail.physik.uni-muenchen.de (Postfix) with ESMTP id 730EE20443; Thu, 29 Apr 2004 13:25:30 +0200 (CEST) Received: from physik.uni-muenchen.de (pD9EBFAB1.dip.t-dialin.net [217.235.250.177]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by mailhost.cip.physik.uni-muenchen.de (Postfix) with ESMTP id 7A1548514F; Thu, 29 Apr 2004 13:25:25 +0200 (CEST) Message-ID: <4090E61F.1040305@physik.uni-muenchen.de> Date: Thu, 29 Apr 2004 12:20:00 -0000 From: =?ISO-8859-15?Q?Tobias_Schl=FCter?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115 MIME-Version: 1.0 To: Feng Wang Cc: fortran , gcc@gcc.gnu.org Subject: Re: [gfortran] Exponentiation by integral exponents References: <20040429024944.52618.qmail@web15212.mail.bjs.yahoo.com> In-Reply-To: <20040429024944.52618.qmail@web15212.mail.bjs.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at physik.uni-muenchen.de X-SW-Source: 2004-04/txt/msg01373.txt.bz2 [ forwarding to gcc@gcc.gnu.org so more knowledgeable people can comment on the point I make in the last paragraph ] Feng Wang wrote: > Hi, Tobi, Paul, etc > I missed the discussion because of my poor modem. But I have implemented this > and the patch is under test. IMHO, we have to implement the algorithm described > by Knuth in the FE. BUILT_IN_POW only deals with Real type. How about complex > type? There are also many problems to consider when an integer is raised to an > negative integer. The result is just 0, -1, or 1. So it is not correct to > convert integer to real. This is a good point that I hadn't thought about. > I think we should also implement the runtime library > function powi. When a value is raised to an varible integer, we just call the > library function. The value may be of integer type, real type or complex type. Yeah, I thought so as well. I was already looking for an implementation. > I have done these and in a few days I will give the patch. I didn't port Andy's > implementation. Andy's vertion only deal with exponent under 100 and don't > consider (integer ** negative integer). The main algorithm in my implementation > is from builtins.c and can deal with an arbitrary integer exponent. The > algorithm in powi library function is from libf77. If your patch is finished I agree that we should go with your patch, as mine is far from finished. I chose to port Andy's implementation as this was my first step in GCC trees, and I didn't want to do something from scratch :-) I don't necessarily agree that this should be handled in the FE, though. There might be other languages that have an "integral exponent" idiom, so a language independent solution might be preferable. - Tobi