From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7219 invoked by alias); 27 Apr 2004 23:09:19 -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 7126 invoked from network); 27 Apr 2004 23:09:17 -0000 Received: from unknown (HELO mail.physik.uni-muenchen.de) (192.54.42.129) by sources.redhat.com with SMTP; 27 Apr 2004 23:09:17 -0000 Received: from localhost (unknown [127.0.0.1]) by mail.physik.uni-muenchen.de (Postfix) with ESMTP id A14C920159; Tue, 27 Apr 2004 23:09:16 +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 26425-01-8; Wed, 28 Apr 2004 01:09:13 +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 9BD9C20096; Wed, 28 Apr 2004 01:09:13 +0200 (CEST) Received: from physik.uni-muenchen.de (pD9EBFAE8.dip.t-dialin.net [217.235.250.232]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by mailhost.cip.physik.uni-muenchen.de (Postfix) with ESMTP id 05F508514F; Wed, 28 Apr 2004 01:09:12 +0200 (CEST) Message-ID: <408EE815.10100@physik.uni-muenchen.de> Date: Wed, 28 Apr 2004 03:48:00 -0000 From: =?ISO-8859-1?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: Paul Brook Cc: fortran@gcc.gnu.org, Andrew Pinski , "gcc@gcc.gnu.org list" Subject: Re: [gfortran] Exponentiation by integral exponents References: <408ECD52.2090709@physik.uni-muenchen.de> <23B628D8-9891-11D8-9EA6-000393A6D2F2@physics.uc.edu> <408ED9A7.5060603@physik.uni-muenchen.de> <200404272315.48828.paul@codesourcery.com> In-Reply-To: <200404272315.48828.paul@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at physik.uni-muenchen.de X-SW-Source: 2004-04/txt/msg01291.txt.bz2 Paul Brook wrote: > On Tuesday 27 April 2004 23:07, Tobias Schlüter wrote: > >>Andrew Pinski wrote: >> >>>On Apr 27, 2004, at 17:14, Tobias Schlüter wrote: >>> >>>>FYI I have ported Andy's code for exponentiation by an integral >>>>exponent to our tree. This is an implementation of Knuth's algorithm >> >>... >> >> >>>You should not need it if you use __builtin_pow and you turn on >>>flag_unsafe_math_optimizations on. Maybe the best way is to have >>>another flag >>>to say expand __builtin_pow always. >> >>Does the builtin recognize the case pow(x,(float)i), where i is an >>integer? Then this sounds like a very good idea. > > > Maybe the way to indicate we always want to expand __builtin_pow would be to > pass the second parameter with an integer type. It may be easier to add > __builtin_powi to avoid needing polymorphic builtins. Definitely. Anyway, I tried to implement Andrew's suggestion as a quick'n'dirty hack. Right now I get an ICE. What is the correct way to generate the equivalent of a typecast in C? What I tried was this: gfc_conv_power_op has this code: type = TREE_TYPE (lse.expr); kind = expr->op1->ts.kind; switch (expr->op2->ts.type) { case BT_INTEGER: /* Integer powers are expanded inline as multiplications. */ gfc_conv_integer_power (se, lse.expr, rse.expr); return; Instead of calling gfc_integer_power and returning, I want to convert rse.expr to the type of lse.expr. So I tried both of the following (gfc_conv_expr_type has no explanatory comment, so I'm just guessing that this might be the function I'm looking for): gfc_conv_expr_type (&rse, expr->op2, type); // first try rse.expr = convert (type, rse.expr); // second try After that I select the function based on the type of lse.expr as in the real case and continue as if rse.expr had not been int all the time. What am I missing? I'm still within my first three hours of messing with gcc trees, so I might well be missing the obvious. - Tobi