This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Are BUILT_IN_POWII and BUILT_IN_POWCI necessary? (RE: Exponentiation by integral exponents)
- From: Feng Wang <wf_cs at yahoo dot com>
- To: "Tobias_Schlüter" <tobias dot schlueter at physik dot uni-muenchen dot de>
- Cc: fortran <fortran at gcc dot gnu dot org>, gcc at gcc dot gnu dot org
- Date: Thu, 29 Apr 2004 21:44:43 +0800 (CST)
- Subject: Are BUILT_IN_POWII and BUILT_IN_POWCI necessary? (RE: Exponentiation by integral exponents)
--- Tobias_Schl?er <tobias.schlueter@physik.uni-muenchen.de> 的正文:> [
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.
To this point it is reasonable. But thus we will have to build and expand
BUILT_IN_POWII (int ** int) and BUILT_IN_POWCI (complex ** int) in the BE. Is
this necessary? Maybe the GCC community can give us some suggestion.
Feng Wang
_________________________________________________________
Do You Yahoo!?
惠普TT游戏剧,玩游戏,中大奖!
http://cn.rd.yahoo.com/mail_cn/tag/SIG=1402c0to2/**http%3A%2F%2Fhp.allyes.com%2Flaserjet%2Fgamestory%2Findex.html%3Fjumpid%3Dex_hphqapcn_MongooseLJ1010%2F201073CN407016%2FYahoo