diff options
author | Richard Guenther <rguenther@suse.de> | 2010-12-07 10:43:38 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-12-07 10:43:38 +0000 |
commit | e9f7ad799c9f099ba1c44ab7948310aa246c221c (patch) | |
tree | 4232b30bfdd925a7422000dd58f28e1a77d3495b /gcc/tree-inline.c | |
parent | 0b238a9b8757b72cbac3cb24600b7230f8bdd12b (diff) | |
download | gcc-e9f7ad799c9f099ba1c44ab7948310aa246c221c.zip gcc-e9f7ad799c9f099ba1c44ab7948310aa246c221c.tar.gz gcc-e9f7ad799c9f099ba1c44ab7948310aa246c221c.tar.bz2 |
re PR tree-optimization/46726 (x*x has different cost than pow(x,2) with -ffast-math)
2010-12-07 Richard Guenther <rguenther@suse.de>
PR tree-optimization/46726
* tree-inline.c (estimate_num_insns): Special case pow (x, 2.0).
From-SVN: r167531
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 97a9869..def733f 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3496,16 +3496,37 @@ estimate_num_insns (gimple stmt, eni_weights *weights) /* Do not special case builtins where we see the body. This just confuse inliner. */ if (!decl || cgraph_node (decl)->analyzed) - cost = weights->call_cost; + ; /* For buitins that are likely expanded to nothing or inlined do not account operand costs. */ else if (is_simple_builtin (decl)) return 0; else if (is_inexpensive_builtin (decl)) return weights->target_builtin_call_cost; - else - cost = weights->call_cost; + else if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL) + { + /* We canonicalize x * x to pow (x, 2.0) with -ffast-math, so + specialize the cheap expansion we do here. + ??? This asks for a more general solution. */ + switch (DECL_FUNCTION_CODE (decl)) + { + case BUILT_IN_POW: + case BUILT_IN_POWF: + case BUILT_IN_POWL: + if (TREE_CODE (gimple_call_arg (stmt, 1)) == REAL_CST + && REAL_VALUES_EQUAL + (TREE_REAL_CST (gimple_call_arg (stmt, 1)), dconst2)) + return estimate_operator_cost (MULT_EXPR, weights, + gimple_call_arg (stmt, 0), + gimple_call_arg (stmt, 0)); + break; + + default: + break; + } + } + cost = weights->call_cost; if (decl) funtype = TREE_TYPE (decl); |