PR 42694: add checks to make sure sqrt is supported

From-SVN: r167594
This commit is contained in:
Michael Meissner 2010-12-08 16:34:20 +00:00 committed by Michael Meissner
parent afca0898bc
commit b0ce92b403
4 changed files with 52 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2010-12-08 Michael Meissner <meissner@linux.vnet.ibm.com>
PR middle-end/42694
* builtins.c (expand_builtin_pow_root): Don't optimize pow(x,y)
where y is 0.25, 1./6., or 0.75 if the target does not have a sqrt
instruction, but do optimize if y is 0.5 or 1./3. since that
changes an expensive call into a cheaper one.
2010-12-08 Richard Guenther <rguenther@suse.de>
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Use a shift

View File

@ -3068,7 +3068,8 @@ expand_builtin_pow_root (location_t loc, tree arg0, tree arg1, tree type,
if (REAL_VALUES_EQUAL (c, dconsthalf))
op = build_call_nofold_loc (loc, sqrtfn, 1, arg0);
else
/* Don't do this optimization if we don't have a sqrt insn. */
else if (optab_handler (sqrt_optab, mode) != CODE_FOR_nothing)
{
REAL_VALUE_TYPE dconst1_4 = dconst1;
REAL_VALUE_TYPE dconst3_4;
@ -3114,7 +3115,8 @@ expand_builtin_pow_root (location_t loc, tree arg0, tree arg1, tree type,
op = build_call_nofold_loc (loc, cbrtfn, 1, arg0);
/* Now try 1/6. */
else if (optimize_insn_for_speed_p ())
else if (optimize_insn_for_speed_p ()
&& optab_handler (sqrt_optab, mode) != CODE_FOR_nothing)
{
REAL_VALUE_TYPE dconst1_6 = dconst1_3;
SET_REAL_EXP (&dconst1_6, REAL_EXP (&dconst1_6) - 1);

View File

@ -1,3 +1,9 @@
2010-12-08 Michael Meissner <meissner@linux.vnet.ibm.com>
PR middle-end/42694
* gcc.target/powerpc/ppc-pow.c: New file to make sure pow (x,
0.75) is not optimized if the machine has no sqrt instruction.
2010-12-07 Andrey Belevantsev <abel@ispras.ru>
PR target/43603

View File

@ -0,0 +1,34 @@
/* { dg-do compile { target { { powerpc*-*-* } && { ! powerpc*-apple-darwin* } } } } */
/* { dg-options "-O2 -ffast-math -mcpu=power6" } */
/* { dg-final { scan-assembler-times "fsqrt" 3 } } */
/* { dg-final { scan-assembler-times "fmul" 1 } } */
/* { dg-final { scan-assembler-times "bl pow" 1 } } */
/* { dg-final { scan-assembler-times "bl sqrt" 1 } } */
double
do_pow_0_75_default (double a)
{
return __builtin_pow (a, 0.75); /* should generate 2 fsqrts */
}
double
do_pow_0_5_default (double a)
{
return __builtin_pow (a, 0.5); /* should generate fsqrt */
}
#pragma GCC target "no-powerpc-gpopt,no-powerpc-gfxopt"
double
do_pow_0_75_nosqrt (double a)
{
return __builtin_pow (a, 0.75); /* should call pow */
}
double
do_pow_0_5_nosqrt (double a)
{
return __builtin_pow (a, 0.5); /* should call sqrt */
}
#pragma GCC reset_options