diff options
author | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-04-18 08:08:47 +0000 |
---|---|---|
committer | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-04-18 08:08:47 +0000 |
commit | b614a751475968cbe5a9834315188d5e92076e26 (patch) | |
tree | 7ddbd6a82296f6aef5984bd9f4df28dfddae3be7 /gcc/tree-ssa-math-opts.c | |
parent | 2ae2da33e61962538727bc21aecbf03b2abc7b10 (diff) | |
download | gcc-b614a751475968cbe5a9834315188d5e92076e26.tar.gz |
2006-04-18 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/26821
* tree-ssa-math-opts.c (get_constant_one): New.
(insert_reciprocals): Use it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113025 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-math-opts.c')
-rw-r--r-- | gcc/tree-ssa-math-opts.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 609c408ed8c..4d02894eb29 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -279,6 +279,35 @@ is_division_by (tree use_stmt, tree def) && TREE_OPERAND (TREE_OPERAND (use_stmt, 1), 1) == def; } +/* Return the LHS of a RDIV_EXPR that computes a reciprocal in type TYPE. */ +static tree +get_constant_one (tree type) +{ + tree scalar, cst; + int i; + + gcc_assert (FLOAT_TYPE_P (type)); + switch (TREE_CODE (type)) + { + case REAL_TYPE: + return build_real (type, dconst1); + + case VECTOR_TYPE: + scalar = build_real (TREE_TYPE (type), dconst1); + + /* Create 'vect_cst_ = {cst,cst,...,cst}' */ + cst = NULL_TREE; + for (i = TYPE_VECTOR_SUBPARTS (type); --i >= 0; ) + cst = tree_cons (NULL_TREE, scalar, cst); + + return build_vector (type, cst); + + default: + /* Complex operations have been split already. */ + gcc_unreachable (); + } +} + /* Walk the subset of the dominator tree rooted at OCC, setting the RECIP_DEF field to a definition of 1.0 / DEF that can be used in the given basic block. The field may be left NULL, of course, @@ -304,8 +333,8 @@ insert_reciprocals (block_stmt_iterator *def_bsi, struct occurrence *occ, type = TREE_TYPE (def); recip_def = make_rename_temp (type, "reciptmp"); new_stmt = build2 (MODIFY_EXPR, void_type_node, recip_def, - fold_build2 (RDIV_EXPR, type, - build_real (type, dconst1), def)); + fold_build2 (RDIV_EXPR, type, get_constant_one (type), + def)); if (occ->bb_has_division) |