Bug 28252 - pow(x,1/3.0) should be converted to cbrt(x)
Summary: pow(x,1/3.0) should be converted to cbrt(x)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Uroš Bizjak
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: patch
Depends on:
Blocks: 28177
  Show dependency treegraph
 
Reported: 2006-07-04 22:23 UTC by Francois-Xavier Coudert
Modified: 2006-10-21 21:26 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-07-05 08:26:53


Attachments
Patch to implement pow(x,1.0/3.0) = cbrt(x) optimization (738 bytes, patch)
2006-07-05 08:25 UTC, Uroš Bizjak
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Francois-Xavier Coudert 2006-07-04 22:23:26 UTC
pow(x,1/3.0) isn't converted to cbrt(x), even though cbrt() is C99 and thus widely available.
Comment 1 Richard Biener 2006-07-04 22:52:33 UTC
Confirmed.  Whether it's a good idea is another question.
Comment 2 Uroš Bizjak 2006-07-05 08:25:55 UTC
Created attachment 11824 [details]
Patch to implement pow(x,1.0/3.0) = cbrt(x) optimization

I have the patch that implements the optimization ready, just waiting for the mainline to open again. Should I post it to gcc-patches anyway?

2006-07-05  Uros Bizjak  <uros@kss-loka.si>

	* builtins.c (fold_builtin): Fold pow(x,1.0/3.0) as cbrt(x) if
	flag_unsafe_math_optimizations is set.

testsuite:

	* gcc.dg/builtins-8.c: Also check pow(x,1.0/3.0) to cbrt(x)
	transformation.
Comment 3 Steven Bosscher 2006-07-06 08:57:17 UTC
Uros,

You could post it now, just so that people can have a look at it and maybe suggest some changes. You know how that goes.

It would be interesting to see if this actually gives speedups...
Comment 4 uros 2006-10-21 20:05:44 UTC
Subject: Bug 28252

Author: uros
Date: Sat Oct 21 20:05:35 2006
New Revision: 117937

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117937
Log:
2006-10-21  Uros Bizjak  <uros@kss-loka.si>

        PR middle-end/28252
        * builtins.c (fold_builtin): Fold pow(x,1.0/3.0) as cbrt(x) if
        flag_unsafe_math_optimizations is set.

testsuite/ChangeLog:

        PR middle-end/28252
        * gcc.dg/builtins-8.c: Also check pow(x,1.0/3.0) to cbrt(x)
        transformation.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/builtins-8.c

Comment 5 Andrew Pinski 2006-10-21 21:26:43 UTC
Fixed.