2005-05-17 14:10:19 +02:00
|
|
|
/* Global, SSA-based optimizations using mathematical identities.
|
2014-01-02 23:23:26 +01:00
|
|
|
Copyright (C) 2005-2014 Free Software Foundation, Inc.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2005-05-17 14:10:19 +02:00
|
|
|
This file is part of GCC.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2005-05-17 14:10:19 +02:00
|
|
|
GCC is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the
|
2007-07-26 10:37:01 +02:00
|
|
|
Free Software Foundation; either version 3, or (at your option) any
|
2005-05-17 14:10:19 +02:00
|
|
|
later version.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2005-05-17 14:10:19 +02:00
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2005-05-17 14:10:19 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-07-26 10:37:01 +02:00
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2005-05-17 14:10:19 +02:00
|
|
|
|
|
|
|
/* Currently, the only mini-pass in this file tries to CSE reciprocal
|
|
|
|
operations. These are common in sequences such as this one:
|
|
|
|
|
|
|
|
modulus = sqrt(x*x + y*y + z*z);
|
|
|
|
x = x / modulus;
|
|
|
|
y = y / modulus;
|
|
|
|
z = z / modulus;
|
|
|
|
|
|
|
|
that can be optimized to
|
|
|
|
|
|
|
|
modulus = sqrt(x*x + y*y + z*z);
|
|
|
|
rmodulus = 1.0 / modulus;
|
|
|
|
x = x * rmodulus;
|
|
|
|
y = y * rmodulus;
|
|
|
|
z = z * rmodulus;
|
|
|
|
|
|
|
|
We do this for loop invariant divisors, and with this pass whenever
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
we notice that a division has the same divisor multiple times.
|
|
|
|
|
|
|
|
Of course, like in PRE, we don't insert a division if a dominator
|
|
|
|
already has one. However, this cannot be done as an extension of
|
|
|
|
PRE for several reasons.
|
|
|
|
|
|
|
|
First of all, with some experiments it was found out that the
|
|
|
|
transformation is not always useful if there are only two divisions
|
|
|
|
hy the same divisor. This is probably because modern processors
|
|
|
|
can pipeline the divisions; on older, in-order processors it should
|
|
|
|
still be effective to optimize two divisions by the same number.
|
|
|
|
We make this a param, and it shall be called N in the remainder of
|
|
|
|
this comment.
|
|
|
|
|
|
|
|
Second, if trapping math is active, we have less freedom on where
|
|
|
|
to insert divisions: we can only do so in basic blocks that already
|
|
|
|
contain one. (If divisions don't trap, instead, we can insert
|
|
|
|
divisions elsewhere, which will be in blocks that are common dominators
|
|
|
|
of those that have the division).
|
|
|
|
|
|
|
|
We really don't want to compute the reciprocal unless a division will
|
|
|
|
be found. To do this, we won't insert the division in a basic block
|
|
|
|
that has less than N divisions *post-dominating* it.
|
|
|
|
|
|
|
|
The algorithm constructs a subset of the dominator tree, holding the
|
|
|
|
blocks containing the divisions and the common dominators to them,
|
|
|
|
and walk it twice. The first walk is in post-order, and it annotates
|
|
|
|
each block with the number of divisions that post-dominate it: this
|
|
|
|
gives information on where divisions can be inserted profitably.
|
|
|
|
The second walk is in pre-order, and it inserts divisions as explained
|
|
|
|
above, and replaces divisions by multiplications.
|
|
|
|
|
|
|
|
In the best case, the cost of the pass is O(n_statements). In the
|
|
|
|
worst-case, the cost is due to creating the dominator tree subset,
|
|
|
|
with a cost of O(n_basic_blocks ^ 2); however this can only happen
|
|
|
|
for n_statements / n_basic_blocks statements. So, the amortized cost
|
|
|
|
of creating the dominator tree subset is O(n_basic_blocks) and the
|
|
|
|
worst-case cost of the pass is O(n_statements * n_basic_blocks).
|
|
|
|
|
|
|
|
More practically, the cost will be small because there are few
|
|
|
|
divisions, and they tend to be in the same basic block, so insert_bb
|
|
|
|
is called very few times.
|
|
|
|
|
|
|
|
If we did this using domwalk.c, an efficient implementation would have
|
|
|
|
to work on all the variables in a single pass, because we could not
|
|
|
|
work on just a subset of the dominator tree, as we do now, and the
|
|
|
|
cost would also be something like O(n_statements * n_basic_blocks).
|
|
|
|
The data structures would be more complex in order to work on all the
|
|
|
|
variables in a single pass. */
|
2005-05-17 14:10:19 +02:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "coretypes.h"
|
|
|
|
#include "tm.h"
|
|
|
|
#include "flags.h"
|
|
|
|
#include "tree.h"
|
2013-11-22 16:58:51 +01:00
|
|
|
#include "basic-block.h"
|
|
|
|
#include "tree-ssa-alias.h"
|
|
|
|
#include "internal-fn.h"
|
|
|
|
#include "gimple-fold.h"
|
|
|
|
#include "gimple-expr.h"
|
|
|
|
#include "is-a.h"
|
gimplify-be.h: New file.
* gimplify-be.h: New file. Add prototypes.
* gimplify.h: Don't include gimple.h.
(struct gimplify_hasher, struct gimplify_ctx, is_gimple_sizepos,
gimplify_hasher::hash, gimplify_hasher::equal): Relocate from gimple.h.
* gimple.h (struct gimplify_hasher, gimplify_hasher::hash,
gimplify_hasher::equal, struct gimplify_ctx, is_gimple_sizepos): Move
to gimplify.h.
(enum gsi_iterator_update): Move to gimple-iterator.h.
* gimple-iterator.h (enum gsi_iterator_update): Relocate from gimple.h.
* gimplify-be.c: New File.
(force_gimple_operand_1, force_gimple_operand,
force_gimple_operand_gsi_1, force_gimple_operand_gsi): Relocate from
gimplify.c.
* gimplify.c (force_gimple_operand_1, force_gimple_operand,
force_gimple_operand_gsi_1, force_gimple_operand_gsi): Move to
gimplify-be.c.
* Makefile.in (OBJS): Add gimplify-be.o
* asan.c: Include only gimplify.h, gimplify-be.h, and/or gimple.h as
required.
* cfgloopmanip.c: Likewise.
* cgraphunit.c: Likewise.
* cilk-common.c: Likewise.
* fold-const.c: Likewise.
* function.c: Likewise.
* gimple-expr.c: Likewise.
* gimple-fold.c: Likewise.
* gimple-ssa-strength-reduction.c: Likewise.
* gimple.c: Likewise.
* graphite-clast-to-gimple.c: Likewise.
* graphite-sese-to-poly.c: Likewise.
* ipa-prop.c: Likewise.
* ipa-split.c: Likewise.
* ipa.c: Likewise.
* langhooks.c: Likewise.
* omp-low.c: Likewise.
* sese.c: Likewise.
* stor-layout.c: Likewise.
* targhooks.c: Likewise.
* trans-mem.c: Likewise.
* tree-affine.c: Likewise.
* tree-cfg.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-complex.c: Likewise.
* tree-if-conv.c: Likewise.
* tree-inline.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-nested.c: Likewise.
* tree-parloops.c: Likewise.
* tree-predcom.c: Likewise.
* tree-profile.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-address.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-ifcombine.c: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-loop-unswitch.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-strlen.c: Likewise.
* tree-ssa.c: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-tailcall.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-generic.c: Likewise.
* tree-vect-loop-manip.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-stmts.c: Likewise.
* tree.c: Likewise.
* tsan.c: Likewise.
* value-prof.c: Likewise.
* config/aarch64/aarch64.c: Likewise.
* config/alpha/alpha.c: Likewise.
* config/darwin.c: Likewise.
* config/i386/i386.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/mep/mep.c: Likewise.
* config/mips/mips.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/s390/s390.c: Likewise.
* config/sh/sh.c: Likewise.
* config/sparc/sparc.c: Likewise.
* config/spu/spu.c: Likewise.
* config/stormy16/stormy16.c: Likewise.
* config/tilegx/tilegx.c: Likewise.
* config/tilepro/tilepro.c: Likewise.
* config/xtensa/xtensa.c: Likewise.
* c/c-typeck.c: Include only gimplify.h and gimple.h as needed.
* c-family/c-common.c: Likewise.
* c-family/c-gimplify.c: Likewise.
* c-family/cilk.c: Likewise.
* cp/class.c: Include only gimplify.h and gimple.h as needed.
* cp/cp-gimplify.c: Likewise.
* cp/error.c: Likewise.
* cp/init.c: Likewise.
* cp/optimize.c: Likewise.
* cp/pt.c: Likewise.
* cp/semantics.c: Likewise.
* cp/tree.c: Likewise.
* cp/vtable-class-hierarchy.c: Likewise.
* fortran/trans-expr.c: Include only gimplify.h and gimple.h as needed.
* fortran/trans-openmp.c: Likewise.
* go/go-lang.c: Include only gimplify.h and gimple.h as needed.
* java/java-gimplify.c: Include only gimplify.h and gimple.h as needed.
* objc/objc-act.c: Include only gimplify.h and gimple.h as needed.
From-SVN: r204812
2013-11-14 20:39:38 +01:00
|
|
|
#include "gimple.h"
|
gimple-walk.h: New File.
* gimple-walk.h: New File. Relocate prototypes from gimple.h.
(struct walk_stmt_info): Relocate here from gimple.h.
* gimple-iterator.h: New File. Relocate prototypes from gimple.h.
(struct gimple_stmt_iterator_d): Relocate here from gimple.h.
(gsi_start_1, gsi_none, gsi_start_bb, gsi_last_1, gsi_last_bb,
gsi_end_p, gsi_one_before_end_p, gsi_next, gsi_prev, gsi_stmt,
gsi_after_labels, gsi_next_nondebug, gsi_prev_nondebug,
gsi_start_nondebug_bb, gsi_start_nondebug_after_labels_bb,
gsi_last_nondebug_bb, gsi_bb, gsi_seq): Relocate here from gimple.h.
* gimple.h (struct gimple_stmt_iterator_d): Move to gimple-iterator.h.
(gsi_start_1, gsi_none, gsi_start_bb, gsi_last_1, gsi_last_bb,
gsi_end_p, gsi_one_before_end_p, gsi_next, gsi_prev, gsi_stmt,
gsi_after_labels, gsi_next_nondebug, gsi_prev_nondebug,
gsi_start_nondebug_bb, gsi_start_nondebug_after_labels_bb,
gsi_last_nondebug_bb, gsi_bb, gsi_seq): Move to gimple-iterator.h.
(struct walk_stmt_info): Move to gimple-walk.h.
(gimple_seq_set_location): Move to gimple.c
* gimple-walk.c: New File.
(walk_gimple_seq_mod, walk_gimple_seq, walk_gimple_asm, walk_gimple_op,
walk_gimple_stmt, get_base_loadstore, walk_stmt_load_store_addr_ops,
walk_stmt_load_store_ops): Relocate here from gimple.c.
* gimple-iterator.c: Include gimple-iterator.h.
* gimple.c (walk_gimple_seq_mod, walk_gimple_seq, walk_gimple_asm,
walk_gimple_op, walk_gimple_stmt, get_base_loadstore,
walk_stmt_load_store_addr_ops, walk_stmt_load_store_ops): Move to
gimple-walk.c.
(gimple_seq_set_location): Relocate from gimple.h.
* tree-phinodes.h (set_phi_nodes): Move to tree-phinodes.c.
* tree-phinodes.c (set_phi_nodes): Relocate from tree-phinodes.h.
* gengtype.c (open_base_files): Add gimple-iterator.h to include list.
* Makefile.in (OBJS): Add gimple-walk.o
* asan.c: Update Include list as required for gimple-iterator.h and
gimple-walk.h.
* cfgexpand.c: Likewise.
* cfgloop.c: Likewise.
* cfgloopmanip.c: Likewise.
* cgraph.c: Likewise.
* cgraphbuild.c: Likewise.
* cgraphunit.c: Likewise.
* gimple-fold.c: Likewise.
* gimple-low.c: Likewise.
* gimple-pretty-print.c: Likewise.
* gimple-ssa-isolate-paths.c: Likewise.
* gimple-ssa-strength-reduction.c: Likewise.
* gimple-streamer-in.c: Likewise.
* gimple-streamer-out.c: Likewise.
* gimplify.c: Likewise.
* graphite-blocking.c: Likewise.
* graphite-clast-to-gimple.c: Likewise.
* graphite-dependences.c: Likewise.
* graphite-interchange.c: Likewise.
* graphite-optimize-isl.c: Likewise.
* graphite-poly.c: Likewise.
* graphite-scop-detection.c: Likewise.
* graphite-sese-to-poly.c: Likewise.
* graphite.c: Likewise.
* ipa-inline-analysis.c: Likewise.
* ipa-profile.c: Likewise.
* ipa-prop.c: Likewise.
* ipa-pure-const.c: Likewise.
* ipa-split.c: Likewise.
* lto-streamer-in.c: Likewise.
* lto-streamer-out.c: Likewise.
* omp-low.c: Likewise.
* predict.c: Likewise.
* profile.c: Likewise.
* sese.c: Likewise.
* tracer.c: Likewise.
* trans-mem.c: Likewise.
* tree-call-cdce.c: Likewise.
* tree-cfg.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-complex.c: Likewise.
* tree-data-ref.c: Likewise.
* tree-dfa.c: Likewise.
* tree-eh.c: Likewise.
* tree-emutls.c: Likewise.
* tree-if-conv.c: Likewise.
* tree-inline.c: Likewise.
* tree-into-ssa.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-nested.c: Likewise.
* tree-nrv.c: Likewise.
* tree-object-size.c: Likewise.
* tree-outof-ssa.c: Likewise.
* tree-parloops.c: Likewise.
* tree-predcom.c: Likewise.
* tree-profile.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-coalesce.c: Likewise.
* tree-ssa-copy.c: Likewise.
* tree-ssa-copyrename.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-ssa-dom.c: Likewise.
* tree-ssa-dse.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-ifcombine.c: Likewise.
* tree-ssa-live.c: Likewise.
* tree-ssa-loop-ch.c: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-loop.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sink.c: Likewise.
* tree-ssa-strlen.c: Likewise.
* tree-ssa-structalias.c: Likewise.
* tree-ssa-tail-merge.c: Likewise.
* tree-ssa-ter.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* tree-ssa-threadupdate.c: Likewise.
* tree-ssa-uncprop.c: Likewise.
* tree-ssa-uninit.c: Likewise.
* tree-ssa.c: Likewise.
* tree-stdarg.c: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-tailcall.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-generic.c: Likewise.
* tree-vect-loop-manip.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-slp.c: Likewise.
* tree-vect-stmts.c: Likewise.
* tree-vectorizer.c: Likewise.
* tree-vrp.c: Likewise.
* tree.c: Likewise.
* tsan.c: Likewise.
* value-prof.c: Likewise.
* vtable-verify.c: Likewise.
* config/aarch64/aarch64-builtins.c: Include gimple-iterator.h.
* config/rs6000/rs6000.c: Include gimple-iterator.h and gimple-walk.h.
* testsuite/g++.dg/plugin/selfassign.c: Include gimple-iterator.h.
* testsuite/gcc.dg/plugin/selfassign.c: Likewise.
From-SVN: r204763
2013-11-14 00:54:17 +01:00
|
|
|
#include "gimple-iterator.h"
|
2014-05-23 05:33:28 +02:00
|
|
|
#include "gimplify.h"
|
gimplify-be.h: New file.
* gimplify-be.h: New file. Add prototypes.
* gimplify.h: Don't include gimple.h.
(struct gimplify_hasher, struct gimplify_ctx, is_gimple_sizepos,
gimplify_hasher::hash, gimplify_hasher::equal): Relocate from gimple.h.
* gimple.h (struct gimplify_hasher, gimplify_hasher::hash,
gimplify_hasher::equal, struct gimplify_ctx, is_gimple_sizepos): Move
to gimplify.h.
(enum gsi_iterator_update): Move to gimple-iterator.h.
* gimple-iterator.h (enum gsi_iterator_update): Relocate from gimple.h.
* gimplify-be.c: New File.
(force_gimple_operand_1, force_gimple_operand,
force_gimple_operand_gsi_1, force_gimple_operand_gsi): Relocate from
gimplify.c.
* gimplify.c (force_gimple_operand_1, force_gimple_operand,
force_gimple_operand_gsi_1, force_gimple_operand_gsi): Move to
gimplify-be.c.
* Makefile.in (OBJS): Add gimplify-be.o
* asan.c: Include only gimplify.h, gimplify-be.h, and/or gimple.h as
required.
* cfgloopmanip.c: Likewise.
* cgraphunit.c: Likewise.
* cilk-common.c: Likewise.
* fold-const.c: Likewise.
* function.c: Likewise.
* gimple-expr.c: Likewise.
* gimple-fold.c: Likewise.
* gimple-ssa-strength-reduction.c: Likewise.
* gimple.c: Likewise.
* graphite-clast-to-gimple.c: Likewise.
* graphite-sese-to-poly.c: Likewise.
* ipa-prop.c: Likewise.
* ipa-split.c: Likewise.
* ipa.c: Likewise.
* langhooks.c: Likewise.
* omp-low.c: Likewise.
* sese.c: Likewise.
* stor-layout.c: Likewise.
* targhooks.c: Likewise.
* trans-mem.c: Likewise.
* tree-affine.c: Likewise.
* tree-cfg.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-complex.c: Likewise.
* tree-if-conv.c: Likewise.
* tree-inline.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-nested.c: Likewise.
* tree-parloops.c: Likewise.
* tree-predcom.c: Likewise.
* tree-profile.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-address.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-ifcombine.c: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-loop-unswitch.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-strlen.c: Likewise.
* tree-ssa.c: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-tailcall.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-generic.c: Likewise.
* tree-vect-loop-manip.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-stmts.c: Likewise.
* tree.c: Likewise.
* tsan.c: Likewise.
* value-prof.c: Likewise.
* config/aarch64/aarch64.c: Likewise.
* config/alpha/alpha.c: Likewise.
* config/darwin.c: Likewise.
* config/i386/i386.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/mep/mep.c: Likewise.
* config/mips/mips.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/s390/s390.c: Likewise.
* config/sh/sh.c: Likewise.
* config/sparc/sparc.c: Likewise.
* config/spu/spu.c: Likewise.
* config/stormy16/stormy16.c: Likewise.
* config/tilegx/tilegx.c: Likewise.
* config/tilepro/tilepro.c: Likewise.
* config/xtensa/xtensa.c: Likewise.
* c/c-typeck.c: Include only gimplify.h and gimple.h as needed.
* c-family/c-common.c: Likewise.
* c-family/c-gimplify.c: Likewise.
* c-family/cilk.c: Likewise.
* cp/class.c: Include only gimplify.h and gimple.h as needed.
* cp/cp-gimplify.c: Likewise.
* cp/error.c: Likewise.
* cp/init.c: Likewise.
* cp/optimize.c: Likewise.
* cp/pt.c: Likewise.
* cp/semantics.c: Likewise.
* cp/tree.c: Likewise.
* cp/vtable-class-hierarchy.c: Likewise.
* fortran/trans-expr.c: Include only gimplify.h and gimple.h as needed.
* fortran/trans-openmp.c: Likewise.
* go/go-lang.c: Include only gimplify.h and gimple.h as needed.
* java/java-gimplify.c: Include only gimplify.h and gimple.h as needed.
* objc/objc-act.c: Include only gimplify.h and gimple.h as needed.
From-SVN: r204812
2013-11-14 20:39:38 +01:00
|
|
|
#include "gimplify-me.h"
|
2013-11-19 13:31:09 +01:00
|
|
|
#include "stor-layout.h"
|
2013-10-23 14:16:58 +02:00
|
|
|
#include "gimple-ssa.h"
|
|
|
|
#include "tree-cfg.h"
|
|
|
|
#include "tree-phinodes.h"
|
|
|
|
#include "ssa-iterators.h"
|
2013-11-19 13:31:09 +01:00
|
|
|
#include "stringpool.h"
|
2013-10-23 14:16:58 +02:00
|
|
|
#include "tree-ssanames.h"
|
2013-11-19 13:31:09 +01:00
|
|
|
#include "expr.h"
|
2013-10-23 14:16:58 +02:00
|
|
|
#include "tree-dfa.h"
|
tree-ssa.h: New.
* tree-ssa.h: New. Move content from tree-flow.h and
tree-flow-inline.h.
* tree-flow.h (_edge_var_map, edge_var_map_vector): Move to tree-ssa.h.
Move prototypes belonging to tree-ssa.c.
* tree-flow-inline.h (redirect_edge_var_map_def,
redirect_edge_var_map_result, redirect_edge_var_map_location): Move to
tree-ssa.h.
* gimple.h: Adjust prototypes.
* tree-ssa.c (useless_type_conversion_p, types_compatible_p): Move to...
* gimple.c (useless_type_conversion_p, types_compatible_p): Here.
* tree.h: Move prototype to tree-ssa.h.
* gengtype.c (open_base_files): Replace tree-flow.h with tree-ssa.h.
* Makefile.in: (TREE_SSA_H, TREE_FLOW_H): Adjust dependencies.
* alias.c, asan.c, builtins.c, calls.c, cfgexpand.c, cfghooks.c,
cfgloop.c, cfgloopmanip.c, cgraph.c, cgraphbuild.c, cgraphclones.c,
cgraphunit.c, dse.c, except.c, expr.c, final.c, fold-const.c,
ggc-page.c, gimple-fold.c, gimple-iterator.c, gimple-low.c,
gimple-pretty-print.c, gimple-ssa-strength-reduction.c,
gimple-streamer-in.c, gimple-streamer-out.c, gimple.c, gimplify.c,
graphite-blocking.c, graphite-clast-to-gimple.c, graphite-dependences.c,
graphite-interchange.c, graphite-optimize-isl.c, graphite-poly.c,
graphite-scop-detection.c, graphite-sese-to-poly.c, graphite.c,
ipa-cp.c, ipa-inline-analysis.c, ipa-inline-transform.c, ipa-inline.c,
ipa-prop.c, ipa-pure-const.c, ipa-reference.c, ipa-split.c, ipa-utils.c,
loop-init.c, lto-cgraph.c, lto-section-in.c, lto-section-out.c,
lto-streamer-in.c, lto-streamer-out.c, lto-streamer.c, omp-low.c,
passes.c, predict.c, print-tree.c, profile.c, sese.c, targhooks.c,
tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c, tree-cfgcleanup.c,
tree-chrec.c, tree-complex.c, tree-data-ref.c, tree-dfa.c, tree-eh.c,
tree-emutls.c, tree-if-conv.c, tree-inline.c, tree-into-ssa.c,
tree-loop-distribution.c, tree-mudflap.c, tree-nested.c, tree-nrv.c,
tree-object-size.c, tree-optimize.c, tree-outof-ssa.c, tree-parloops.c,
tree-phinodes.c, tree-predcom.c, tree-pretty-print.c, tree-profile.c,
tree-scalar-evolution.c, tree-sra.c, tree-ssa*.c, tree-stdarg.c,
tree-streamer-in.c, tree-switch-conversion.c, tree-tailcall.c,
tree-vect-data-refs.c, tree-vect-generic.c, tree-vect-loop-manip.c,
tree-vect-loop.c, tree-vect-patterns.c, tree-vect-slp.c,
tree-vect-stmts.c, tree-vectorizer.c, tree-vrp.c, tsan.c,
value-prof.c, var-tracking.c,
varpool.c, vtable-verify.c: Replace tree-flow.h with tree-ssa.h
From-SVN: r202523
2013-09-12 15:03:18 +02:00
|
|
|
#include "tree-ssa.h"
|
2005-05-17 14:10:19 +02:00
|
|
|
#include "tree-pass.h"
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
#include "alloc-pool.h"
|
|
|
|
#include "target.h"
|
diagnostic.c: Don't include tm.h, tree.h, tm_p.h, langhooks.h or langhooks-def.h.
* diagnostic.c: Don't include tm.h, tree.h, tm_p.h, langhooks.h or
langhooks-def.h.
(diagnostic_initialize): Initialize x_data not last_function.
(diagnostic_report_current_function): Move to tree-diagnostic.c.
(default_diagnostic_starter): Call
diagnostic_report_current_module not
diagnostic_report_current_function.
(diagnostic_report_diagnostic): Initialize x_data not
abstract_origin.
(verbatim): Likewise.
* diagnostic.h (struct diagnostic_info): Change abstract_origin to
x_data.
(struct diagnostic_context): Change last_function to x_data.
(diagnostic_auxiliary_data): Replace with
diagnostic_context_auxiliary_data and
diagnostic_info_auxiliary_data.
(diagnostic_last_function_changed, diagnostic_set_last_function,
diagnostic_report_current_function): Move to tree-diagnostic.h.
(print_declaration, dump_generic_node, print_generic_stmt,
print_generic_stmt_indented, print_generic_expr,
print_generic_decl, debug_c_tree, dump_omp_clauses,
print_call_name, debug_generic_expr, debug_generic_stmt,
debug_tree_chain, default_tree_printer): Move to
tree-pretty-print.h.
(debug_gimple_stmt, debug_gimple_seq, print_gimple_seq,
print_gimple_stmt, print_gimple_expr, dump_gimple_stmt): Move to
gimple-pretty-print.h.
* pretty-print.c: Don't include tree.h
(pp_base_format): Don't handle %K here.
(pp_base_tree_identifier): Move to tree-pretty-print.c.
* pretty-print.h (text_info): Change abstract_origin to x_data.
(pp_tree_identifier, pp_unsupported_tree,
pp_base_tree_identifier): Move to tree-pretty-print.h.
* gimple-pretty-print.h, tree-diagnostic.c, tree-diagnostic.h,
tree-pretty-print.h: New files.
* tree-pretty-print.c: Include tree-pretty-print.h.
(percent_K_format): New. Moved from pretty-print.c.
(pp_base_tree_identifier): Move from pretty-print.c.
* c-objc-common.c: Include tree-pretty-print.h.
(c_tree_printer): Handle %K here.
* langhooks.c: Include tree-diagnostic.h.
(lhd_print_error_function): Use diagnostic_abstract_origin macro.
* toplev.c: Include tree-diagnostic.h and tree-pretty-print.h.
(default_tree_printer): Handle %K using percent_K_format.
(general_init): Use default_tree_diagnostic_starter.
* tree.c: Include tree-diagnostic.h and tree-pretty-print.h.
(free_lang_data): Use default_tree_diagnostic_starter.
* c-pretty-print.c: Include tree-pretty-print.h.
* cfgexpand.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* cgraphunit.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* dwarf2out.c: Include tree-pretty-print.h.
* except.c: Include tree-pretty-print.h.
* gimple-pretty-print.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* gimplify.c: Include tree-pretty-print.h.
* graphite-poly.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* ipa-cp.c: Include tree-pretty-print.h.
* ipa-inline.c: Include gimple-pretty-print.h.
* ipa-prop.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* ipa-pure-const.c: Include gimple-pretty-print.h.
* ipa-struct-reorg.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* ipa-type-escape.c: Include tree-pretty-print.h.
* print-rtl.c: Include tree-pretty-print.h.
* print-tree.c: Include gimple-pretty-print.h.
* sese.c: Include tree-pretty-print.h.
* tree-affine.c: Include tree-pretty-print.h.
* tree-browser.c: Include tree-pretty-print.h.
* tree-call-cdce.c: Include gimple-pretty-print.h.
* tree-cfg.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-chrec.c: Include tree-pretty-print.h.
* tree-data-ref.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-dfa.c: Include tree-pretty-print.h.
* tree-if-conv.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-inline.c: Include tree-pretty-print.h.
* tree-into-ssa.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-nrv.c: Include tree-pretty-print.h.
* tree-object-size.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-outof-ssa.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-parloops.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-predcom.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-scalar-evolution.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-sra.c: Include tree-pretty-print.h.
* tree-ssa-address.c: Include tree-pretty-print.h.
* tree-ssa-alias.c: Include tree-pretty-print.h.
* tree-ssa-ccp.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-coalesce.c: Include tree-pretty-print.h.
* tree-ssa-copy.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-copyrename.c: Include tree-pretty-print.h.
* tree-ssa-dce.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-dom.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-dse.c: Include gimple-pretty-print.h.
* tree-ssa-forwprop.c: Include tree-pretty-print.h.
* tree-ssa-ifcombine.c: Include tree-pretty-print.h.
* tree-ssa-live.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-im.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-ivcanon.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-ivopts.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-niter.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-prefetch.c: Include tree-pretty-print.h.
* tree-ssa-math-opts.c: Include gimple-pretty-print.h.
* tree-ssa-operands.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-phiprop.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-pre.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-propagate.c: Include gimple-pretty-print.h.
* tree-ssa-reassoc.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-sccvn.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-sink.c: Include gimple-pretty-print.h.
* tree-ssa-ter.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-uninit.c: Include gimple-pretty-print.h.
* tree-ssa.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-stdarg.c: Include gimple-pretty-print.h.
* tree-switch-conversion.c: Include gimple-pretty-print.h.
* tree-tailcall.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-data-refs.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-loop-manip.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-loop.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-patterns.c: Include gimple-pretty-print.h.
* tree-vect-slp.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-stmts.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vectorizer.c: Include tree-pretty-print.h.
* tree-vrp.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* value-prof.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* var-tracking.c: Include tree-pretty-print.h.
* Makefile.in (OBJS-common): Add tree-diagnostic.o.
(tree-diagnostic.o): New dependencies.
(c-objc-common.o, c-pretty-print.o, langhooks.o, tree.o,
tree-inline.o, print-tree.o, stor-layout.o, tree-ssa-uninit.o,
tree-ssa.o, tree-into-ssa.o, tree-ssa-ter.o, tree-ssa-coalesce.o,
tree-outof-ssa.o, tree-ssa-forwprop.o, tree-ssa-phiprop.o,
tree-ssa-ifcombine.o, tree-nrv.o, tree-ssa-copy.o,
tree-ssa-propagate.o, tree-ssa-dom.o, tree-ssa-uncprop.o,
tree-ssa-live.o, tree-ssa-copyrename.o, tree-ssa-pre.o,
tree-ssa-sccvn.o, tree-vrp.o, tree-cfg.o, tree-tailcall.o,
tree-ssa-sink.o, tree-if-conv.o, tree-dfa.o, tree-ssa-operands.o,
tree-ssa-address.o, tree-ssa-loop-niter.o,
tree-ssa-loop-ivcanon.o, tree-ssa-loop-prefetch.o, tree-predcom.o,
tree-ssa-loop-ivopts.o, tree-affine.o, tree-ssa-loop-im.o,
tree-ssa-math-opts.o, tree-ssa-alias.o, tree-ssa-reassoc.o,
gimplify.o, tree-browser.o, tree-chrec.o, tree-scalar-evolution.o,
tree-data-ref.o, sese.o, graphite-poly.o, tree-vect-loop.o,
tree-vect-loop-manip.o, tree-vect-patterns.o, tree-vect-slp.o,
tree-vect-stmts.o, tree-vect-data-refs.o, tree-vectorizer.o,
tree-parloops.o, tree-stdarg.o, tree-object-size.o,
gimple-pretty-print.o, tree-pretty-print.o, diagnostic.o,
toplev.o, print-rtl.o, except.o, dwarf2out.o, cgraphunit.o,
ipa-prop.o, ipa-cp.o, ipa-inline.o, ipa-pure-const.o,
ipa-type-escape.o, ipa-struct-reorg.o, tree-ssa-dce.o,
tree-call-cdce.o, tree-ssa-ccp.o, tree-sra.o,
tree-switch-conversion.o, var-tracking.o, value-prof.o,
cfgexpand.o, pretty-print.o): Update dependencies.
cp:
* error.c: Include tree-diagnostic.h and tree-pretty-print.h.
(cp_print_error_function): Use diagnostic_abstract_origin macro.
(cp_printer): Handle %K here using percent_K_format.
* cxx-pretty-print.c: Include tree-pretty-print.h.
* Make-lang.in (cp/error.o, cp/cxx-pretty-print.o): Update
dependencies.
From-SVN: r159685
2010-05-22 00:34:26 +02:00
|
|
|
#include "gimple-pretty-print.h"
|
expr.h: Remove prototypes of functions defined in builtins.c.
* expr.h: Remove prototypes of functions defined in builtins.c.
* tree.h: (build_call_expr_*, build_string_literal): Add prototypes.
Remove prototypes of functions defined in builtins.c.
* builtins.h: Update prototype list to include all exported functions.
* builtins.c: (default_libc_has_function, gnu_libc_has_function,
no_c99_libc_has_function): Move to targhooks.c
(build_string_literal, build_call_expr_loc_array,
build_call_expr_loc_vec, build_call_expr_loc, build_call_expr): Move
to tree.c.
(expand_builtin_object_size, fold_builtin_object_size): Make static.
* targhooks.c (default_libc_has_function, gnu_libc_has_function,
no_c99_libc_has_function): Relocate from builtins.c.
* tree.c: Include builtins.h.
(build_call_expr_loc_array, build_call_expr_loc_vec,
build_call_expr_loc, build_call_expr, build_string_literal): Relocate
from builtins.c.
* fold-const.h (fold_fma): Move prototype to builtins.h.
* realmpfr.h (do_mpc_arg2): Move prototype to builtins.h.
* fortran/trans.c (trans_runtime_error_vararg): Call
fold_build_call_array_loc instead of fold_builtin_call_array.
* asan.c: Include builtins.h.
* cfgexpand.c: Likewise.
* convert.c: Likewise.
* emit-rtl.c: Likewise.
* except.c: Likewise.
* expr.c: Likewise.
* fold-const.c: Likewise.
* gimple-fold.c: Likewise.
* gimple-ssa-strength-reduction.c: Likewise.
* gimplify.c: Likewise.
* ipa-inline.c: Likewise.
* ipa-prop.c: Likewise.
* lto-streamer-out.c: Likewise.
* stmt.c: Likewise.
* tree-inline.c: Likewise.
* tree-object-size.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* tree-streamer-in.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-stmts.c: Likewise.
c
* c-decl.c: Include builtins.h.
* c-parser.c: Likewise.
cp
* decl.c: Include builtins.h.
* semantics.c: Likewise.
go
* go-gcc.cc: Include builtins.h.
lto
* lto-symtab.c: Include builtins.h.
config
* aarch64/aarch64.c: Include builtins.h.
* alpha/alpha.c: Likewise.
* arc/arc.c: Likewise.
* arm/arm.c: Likewise.
* avr/avr.c: Likewise.
* bfin/bfin.c: Likewise.
* c6x/c6x.c: Likewise.
* cr16/cr16.c: Likewise.
* cris/cris.c: Likewise.
* epiphany/epiphany.c: Likewise.
* fr30/fr30.c: Likewise.
* frv/frv.c: Likewise.
* h8300/h8300.c: Likewise.
* i386/i386.c: Likewise.
* i386/winnt.c: Likewise.
* ia64/ia64.c: Likewise.
* iq2000/iq2000.c: Likewise.
* lm32/lm32.c: Likewise.
* m32c/m32c.c: Likewise.
* m32r/m32r.c: Likewise.
* m68k/m68k.c: Likewise.
* mcore/mcore.c: Likewise.
* mep/mep.c: Likewise.
* microblaze/microblaze.c: Likewise.
* mips/mips.c: Likewise.
* mmix/mmix.c: Likewise.
* mn10300/mn10300.c: Likewise.
* moxie/moxie.c: Likewise.
* msp430/msp430.c: Likewise.
* nds32/nds32.c: Likewise.
* pa/pa.c: Likewise.
* pdp11/pdp11.c: Likewise.
* picochip/picochip.c: Likewise.
* rl78/rl78.c: Likewise.
* rs6000/rs6000.c: Likewise.
* rx/rx.c: Likewise.
* s390/s390.c: Likewise.
* score/score.c: Likewise.
* sh/sh.c: Likewise.
* sparc/sparc.c: Likewise.
* spu/spu.c: Likewise.
* stormy16/stormy16.c: Likewise.
* tilegx/tilegx.c: Likewise.
* tilepro/tilepro.c: Likewise.
* v850/v850.c: Likewise.
* vax/vax.c: Likewise.
* xtensa/xtensa.c: Likewise.
From-SVN: r211145
2014-06-02 22:13:44 +02:00
|
|
|
#include "builtins.h"
|
tree.h: Include real.h and fixed-value.h as basic datatypes.
gcc/ChangeLog:
* tree.h: Include real.h and fixed-value.h as basic datatypes.
* dfp.c, convert.c, reload1.c, reginfo.c, tree-flow.h,
tree-ssa-threadedge.c, tree-ssanames.c, tree-loop-linear.c,
tree-into-ssa.c, tree-vect-generic.c, tree-ssa-structalias.c,
tree-ssa-loop-im.c, tree-dump.c, tree-complex.c, tree-ssa-uninit.c,
genrecog.c, tree-ssa-threadupdate.c, tree-ssa-loop-niter.c,
tree-pretty-print.c, tree-loop-distribution.c,
tree-ssa-loop-unswitch.c, c-lex.c, optabs.c, postreload-gcse.c,
tree-ssa-loop-manip.c, postreload.c, tree-ssa-loop-ch.c,
tree-tailcall.c, tree.c, reload.c, tree-scalar-evolution.c, rtlanal.c,
tree-phinodes.c, builtins.c, final.c, genoutput.c, fold-const.c,
tree-ssa-dse.c, genautomata.c, tree-ssa-uncprop.c, toplev.c,
tree-chrec.c, genemit.c, c-cppbuiltin.c, tree-ssa-sccvn.c,
tree-ssa-ccp.c, tree-ssa-loop-ivopts.c, mode-switching.c,
tree-call-cdce.c, cse.c, genpeep.c, tree-ssa-math-opts.c,
tree-ssa-dom.c, tree-nrv.c, tree-ssa-propagate.c, tree-ssa-alias.c,
tree-ssa-sink.c, jump.c, ifcvt.c, dwarf2out.c, expr.c, genattrtab.c,
genconditions.c, tree-ssa-loop-ivcanon.c, tree-ssa-loop.c,
tree-parloops.c, recog.c, tree-ssa-address.c, lcm.c, tree-eh.c,
gimple-pretty-print.c, c-pretty-print.c, print-rtl.c, gcse.c,
tree-if-conv.c, tree-data-ref.c, tree-affine.c, gimplify.c,
tree-ssa-phiopt.c, implicit-zee.c, expmed.c, tree-dfa.c, emit-rtl.c,
store-motion.c, cselib.c, tree-cfgcleanup.c, simplify-rtx.c,
tree-ssa-pre.c, genpreds.c, tree-mudflap.c, print-tree.c,
tree-ssa-copy.c, tree-ssa-forwprop.c, tree-ssa-dce.c, varasm.c,
tree-nested.c, tree-ssa.c, tree-ssa-loop-prefetch.c, rtl.c,
tree-inline.c, integrate.c, tree-optimize.c, tree-ssa-phiprop.c,
fixed-value.c, combine.c, tree-profile.c, c-common.c, sched-vis.c,
tree-cfg.c, passes.c, tree-ssa-reassoc.c, config/alpha/alpha.c,
config/frv/frv.c, config/s390/s390.c, config/m32c/m32c.c,
config/spu/spu.c, config/sparc/sparc.c, config/mep/mep.c,
config/m32r/m32r.c, config/rx/rx.c, config/i386/i386.c,
config/sh/sh.c, config/pdp11/pdp11.c, config/avr/avr.c,
config/crx/crx.c, config/xtensa/xtensa.c, config/stormy16/stormy16.c,
config/fr30/fr30.c, config/lm32/lm32.c, config/moxie/moxie.c,
config/m68hc11/m68hc11.c, config/cris/cris.c, config/iq2000/iq2000.c,
config/mn10300/mn10300.c, config/ia64/ia64.c, config/m68k/m68k.c,
config/rs6000/rs6000.c, config/picochip/picochip.c, config/darwin.c,
config/arc/arc.c, config/mcore/mcore.c, config/score/score3.c,
config/score/score7.c, config/score/score.c, config/arm/arm.c,
config/pa/pa.c, config/mips/mips.c, config/vax/vax.c,
config/h8300/h8300.c, config/v850/v850.c, config/mmix/mmix.c,
config/bfin/bfin.c:
Clean up redundant includes.
* Makefile.in: Update accordingly.
java/ChangeLog:
* typeck.c, decl.c, jcf-parse.c, except.c, expr.c:
cp/Changelog:
* error.c, tree.c, typeck2.c, cxx-pretty-print.c, mangle.c:
Clean up redundant includes.
fortran/ChangeLog:
* trans-const.c, trans-types.c, trans-intrinsic.c:
Clean up redundant includes.
From-SVN: r159663
2010-05-21 15:53:22 +02:00
|
|
|
|
|
|
|
/* FIXME: RTL headers have to be included here for optabs. */
|
|
|
|
#include "rtl.h" /* Because optabs.h wants enum rtx_code. */
|
|
|
|
#include "expr.h" /* Because optabs.h wants sepops. */
|
2009-06-14 16:45:32 +02:00
|
|
|
#include "optabs.h"
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
|
|
|
|
/* This structure represents one basic block that either computes a
|
|
|
|
division, or is a common dominator for basic block that compute a
|
|
|
|
division. */
|
|
|
|
struct occurrence {
|
|
|
|
/* The basic block represented by this structure. */
|
|
|
|
basic_block bb;
|
|
|
|
|
|
|
|
/* If non-NULL, the SSA_NAME holding the definition for a reciprocal
|
|
|
|
inserted in BB. */
|
|
|
|
tree recip_def;
|
|
|
|
|
2008-07-28 16:33:56 +02:00
|
|
|
/* If non-NULL, the GIMPLE_ASSIGN for a reciprocal computation that
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
was inserted in BB. */
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple recip_def_stmt;
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
|
|
|
|
/* Pointer to a list of "struct occurrence"s for blocks dominated
|
|
|
|
by BB. */
|
|
|
|
struct occurrence *children;
|
|
|
|
|
|
|
|
/* Pointer to the next "struct occurrence"s in the list of blocks
|
|
|
|
sharing a common dominator. */
|
|
|
|
struct occurrence *next;
|
|
|
|
|
|
|
|
/* The number of divisions that are in BB before compute_merit. The
|
|
|
|
number of divisions that are in BB or post-dominate it after
|
|
|
|
compute_merit. */
|
|
|
|
int num_divisions;
|
|
|
|
|
|
|
|
/* True if the basic block has a division, false if it is a common
|
|
|
|
dominator for basic blocks that do. If it is false and trapping
|
|
|
|
math is active, BB is not a candidate for inserting a reciprocal. */
|
|
|
|
bool bb_has_division;
|
|
|
|
};
|
|
|
|
|
2011-04-13 21:39:02 +02:00
|
|
|
static struct
|
|
|
|
{
|
|
|
|
/* Number of 1.0/X ops inserted. */
|
|
|
|
int rdivs_inserted;
|
|
|
|
|
|
|
|
/* Number of 1.0/FUNC ops inserted. */
|
|
|
|
int rfuncs_inserted;
|
|
|
|
} reciprocal_stats;
|
|
|
|
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
/* Number of cexpi calls inserted. */
|
|
|
|
int inserted;
|
|
|
|
} sincos_stats;
|
|
|
|
|
|
|
|
static struct
|
|
|
|
{
|
2014-05-23 05:33:28 +02:00
|
|
|
/* Number of hand-written 16-bit nop / bswaps found. */
|
2012-09-26 15:42:47 +02:00
|
|
|
int found_16bit;
|
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
/* Number of hand-written 32-bit nop / bswaps found. */
|
2011-04-13 21:39:02 +02:00
|
|
|
int found_32bit;
|
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
/* Number of hand-written 64-bit nop / bswaps found. */
|
2011-04-13 21:39:02 +02:00
|
|
|
int found_64bit;
|
2014-05-23 05:33:28 +02:00
|
|
|
} nop_stats, bswap_stats;
|
2011-04-13 21:39:02 +02:00
|
|
|
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
/* Number of widening multiplication ops inserted. */
|
|
|
|
int widen_mults_inserted;
|
|
|
|
|
|
|
|
/* Number of integer multiply-and-accumulate ops inserted. */
|
|
|
|
int maccs_inserted;
|
|
|
|
|
|
|
|
/* Number of fp fused multiply-add ops inserted. */
|
|
|
|
int fmas_inserted;
|
|
|
|
} widen_mul_stats;
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
|
|
|
|
/* The instance of "struct occurrence" representing the highest
|
|
|
|
interesting block in the dominator tree. */
|
|
|
|
static struct occurrence *occ_head;
|
|
|
|
|
|
|
|
/* Allocation pool for getting instances of "struct occurrence". */
|
|
|
|
static alloc_pool occ_pool;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Allocate and return a new struct occurrence for basic block BB, and
|
|
|
|
whose children list is headed by CHILDREN. */
|
|
|
|
static struct occurrence *
|
|
|
|
occ_new (basic_block bb, struct occurrence *children)
|
2005-05-17 14:10:19 +02:00
|
|
|
{
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
struct occurrence *occ;
|
|
|
|
|
2007-06-06 22:18:47 +02:00
|
|
|
bb->aux = occ = (struct occurrence *) pool_alloc (occ_pool);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
memset (occ, 0, sizeof (struct occurrence));
|
|
|
|
|
|
|
|
occ->bb = bb;
|
|
|
|
occ->children = children;
|
|
|
|
return occ;
|
2005-05-17 14:10:19 +02:00
|
|
|
}
|
|
|
|
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
|
|
|
|
/* Insert NEW_OCC into our subset of the dominator tree. P_HEAD points to a
|
|
|
|
list of "struct occurrence"s, one per basic block, having IDOM as
|
|
|
|
their common dominator.
|
|
|
|
|
|
|
|
We try to insert NEW_OCC as deep as possible in the tree, and we also
|
|
|
|
insert any other block that is a common dominator for BB and one
|
|
|
|
block already in the tree. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
insert_bb (struct occurrence *new_occ, basic_block idom,
|
|
|
|
struct occurrence **p_head)
|
2005-08-09 05:28:38 +02:00
|
|
|
{
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
struct occurrence *occ, **p_occ;
|
2005-08-09 05:28:38 +02:00
|
|
|
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
for (p_occ = p_head; (occ = *p_occ) != NULL; )
|
|
|
|
{
|
|
|
|
basic_block bb = new_occ->bb, occ_bb = occ->bb;
|
|
|
|
basic_block dom = nearest_common_dominator (CDI_DOMINATORS, occ_bb, bb);
|
|
|
|
if (dom == bb)
|
|
|
|
{
|
|
|
|
/* BB dominates OCC_BB. OCC becomes NEW_OCC's child: remove OCC
|
|
|
|
from its list. */
|
|
|
|
*p_occ = occ->next;
|
|
|
|
occ->next = new_occ->children;
|
|
|
|
new_occ->children = occ;
|
|
|
|
|
|
|
|
/* Try the next block (it may as well be dominated by BB). */
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (dom == occ_bb)
|
|
|
|
{
|
|
|
|
/* OCC_BB dominates BB. Tail recurse to look deeper. */
|
|
|
|
insert_bb (new_occ, dom, &occ->children);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (dom != idom)
|
|
|
|
{
|
|
|
|
gcc_assert (!dom->aux);
|
|
|
|
|
|
|
|
/* There is a dominator between IDOM and BB, add it and make
|
|
|
|
two children out of NEW_OCC and OCC. First, remove OCC from
|
|
|
|
its list. */
|
|
|
|
*p_occ = occ->next;
|
|
|
|
new_occ->next = occ;
|
|
|
|
occ->next = NULL;
|
|
|
|
|
|
|
|
/* None of the previous blocks has DOM as a dominator: if we tail
|
|
|
|
recursed, we would reexamine them uselessly. Just switch BB with
|
|
|
|
DOM, and go on looking for blocks dominated by DOM. */
|
|
|
|
new_occ = occ_new (dom, new_occ);
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Nothing special, go on with the next element. */
|
|
|
|
p_occ = &occ->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No place was found as a child of IDOM. Make BB a sibling of IDOM. */
|
|
|
|
new_occ->next = *p_head;
|
|
|
|
*p_head = new_occ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Register that we found a division in BB. */
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
register_division_in (basic_block bb)
|
|
|
|
{
|
|
|
|
struct occurrence *occ;
|
|
|
|
|
|
|
|
occ = (struct occurrence *) bb->aux;
|
|
|
|
if (!occ)
|
|
|
|
{
|
|
|
|
occ = occ_new (bb, NULL);
|
Eliminate ENTRY_BLOCK_PTR and EXIT_BLOCK_PTR macros
gcc/
* basic-block.h (ENTRY_BLOCK_PTR_FOR_FUNCTION): Rename macro to...
(EXIT_BLOCK_PTR_FOR_FUNCTION): ...this.
(ENTRY_BLOCK_PTR_FOR_FN): Renamed macro to...
(EXIT_BLOCK_PTR_FOR_FN): ...this.
(ENTRY_BLOCK_PTR): Eliminate macro as work towards making uses of
cfun be explicit.
(EXIT_BLOCK_PTR): Likewise.
(FOR_ALL_BB): Rework for now to eliminate use of "ENTRY_BLOCK_PTR".
(FOR_ALL_BB_FN): Update for renaming of
"ENTRY_BLOCK_PTR_FOR_FUNCTION" to "ENTRY_BLOCK_PTR_FOR_FN".
* cfg.c (init_flow): Likewise.
(check_bb_profile): Likewise.
* cfganal.c (pre_and_rev_post_order_compute_fn): Likewise.
* cfgcleanup.c (walk_to_nondebug_insn): Likewise.
* cfghooks.c (account_profile_record): Likewise.
* cfgloop.c (init_loops_structure): Likewise.
* cgraphbuild.c (record_eh_tables): Likewise.
(compute_call_stmt_bb_frequency): Likewise.
* ipa-inline-analysis.c (compute_bb_predicates): Likewise.
* lto-streamer-in.c (input_cfg): Likewise.
* predict.c (maybe_hot_frequency_p): Likewise.
* tree-cfg.c (init_empty_tree_cfg_for_function): Likewise.
* tree-inline.c (initialize_cfun): Likewise.
(copy_cfg_body): Likewise.
(copy_body): Likewise.
(tree_function_versioning): Likewise.
* bb-reorder.c (add_labels_and_missing_jumps): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(duplicate_computed_gotos): Remove usage of EXIT_BLOCK_PTR macro.
(find_rarely_executed_basic_blocks_and_crossing_edges): Remove uses of
macros: ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(connect_traces): Likewise.
(rest_of_handle_reorder_blocks): Remove usage of EXIT_BLOCK_PTR macro.
(bb_to_key): Remove usage of ENTRY_BLOCK_PTR macro.
(fix_crossing_conditional_branches): Remove usage of EXIT_BLOCK_PTR
macro.
(find_traces_1_round): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(fix_up_fall_thru_edges): Remove usage of EXIT_BLOCK_PTR macro.
(find_traces): Remove usage of ENTRY_BLOCK_PTR macro.
(fix_up_crossing_landing_pad): Remove usage of EXIT_BLOCK_PTR macro.
(rotate_loop): Likewise.
* bt-load.c (migrate_btr_def): Remove usage of ENTRY_BLOCK_PTR macro.
* cfg.c (clear_aux_for_edges): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(alloc_aux_for_edges): Likewise.
(clear_bb_flags): Remove usage of ENTRY_BLOCK_PTR macro.
(cached_make_edge): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(compact_blocks): Likewise.
(clear_edges): Likewise.
* cfganal.c (single_pred_before_succ_order): Remove usage of
ENTRY_BLOCK_PTR macro.
(bitmap_union_of_succs): Remove usage of EXIT_BLOCK_PTR macro.
(bitmap_union_of_preds): Remove usage of ENTRY_BLOCK_PTR macro.
(bitmap_intersection_of_succs): Remove usage of EXIT_BLOCK_PTR macro.
(bitmap_intersection_of_preds): Remove usage of ENTRY_BLOCK_PTR macro.
(inverted_post_order_compute): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(compute_dominance_frontiers_1): Remove usage of ENTRY_BLOCK_PTR
macro.
(post_order_compute): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(connect_infinite_loops_to_exit): Remove usage of EXIT_BLOCK_PTR
macro.
(remove_fake_edges): Remove usage of ENTRY_BLOCK_PTR macro.
(add_noreturn_fake_exit_edges): Remove usage of EXIT_BLOCK_PTR macro.
(find_pdom): Remove uses of macros: ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(remove_fake_exit_edges): Remove usage of EXIT_BLOCK_PTR macro.
(verify_edge_list): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(print_edge_list): Likewise.
(create_edge_list): Likewise.
(find_unreachable_blocks): Remove usage of ENTRY_BLOCK_PTR macro.
(mark_dfs_back_edges): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
* cfgbuild.c (find_bb_boundaries): Remove usage of ENTRY_BLOCK_PTR
macro.
(find_many_sub_basic_blocks): Remove usage of EXIT_BLOCK_PTR macro.
(make_edges): Remove uses of macros: ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
* cfgcleanup.c (delete_unreachable_blocks): Likewise.
(try_optimize_cfg): Likewise.
(try_head_merge_bb): Remove usage of EXIT_BLOCK_PTR macro.
(try_crossjump_to_edge): Remove usage of ENTRY_BLOCK_PTR macro.
(try_crossjump_bb): Remove usage of EXIT_BLOCK_PTR macro.
(merge_blocks_move): Remove usage of ENTRY_BLOCK_PTR macro.
(outgoing_edges_match): Remove usage of EXIT_BLOCK_PTR macro.
(try_forward_edges): Likewise.
(try_simplify_condjump): Likewise.
* cfgexpand.c (gimple_expand_cfg): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(construct_exit_block): Remove usage of EXIT_BLOCK_PTR macro.
(construct_init_block): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(expand_gimple_basic_block): Remove usage of EXIT_BLOCK_PTR macro.
(expand_gimple_tailcall): Likewise.
* cfghooks.c (can_duplicate_block_p): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(tidy_fallthru_edges): Likewise.
(verify_flow_info): Likewise.
* cfgloop.c (flow_bb_inside_loop_p): Likewise.
(num_loop_branches): Remove usage of EXIT_BLOCK_PTR macro.
(disambiguate_multiple_latches): Remove usage of ENTRY_BLOCK_PTR
macro.
(get_loop_exit_edges): Remove usage of EXIT_BLOCK_PTR macro.
(bb_loop_header_p): Remove usage of ENTRY_BLOCK_PTR macro.
(get_loop_body_in_bfs_order): Remove usage of EXIT_BLOCK_PTR macro.
(get_loop_body_in_dom_order): Likewise.
(get_loop_body): Likewise.
* cfgloopanal.c (mark_irreducible_loops): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
* cfgloopmanip.c (create_preheader): Remove usage of ENTRY_BLOCK_PTR
macro.
(remove_path): Remove usage of EXIT_BLOCK_PTR macro.
(fix_bb_placement): Likewise.
* cfgrtl.c (rtl_block_empty_p): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(rtl_can_remove_branch_p): Remove usage of EXIT_BLOCK_PTR macro.
(cfg_layout_split_edge): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(rtl_flow_call_edges_add): Remove usage of EXIT_BLOCK_PTR macro.
(cfg_layout_can_merge_blocks_p): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(cfg_layout_redirect_edge_and_branch): Remove usage of ENTRY_BLOCK_PTR
macro.
(fixup_fallthru_exit_predecessor): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(fixup_reorder_chain): Likewise.
(relink_block_chain): Likewise.
(cfg_layout_delete_block): Remove usage of EXIT_BLOCK_PTR macro.
(rtl_verify_bb_layout): Remove usage of ENTRY_BLOCK_PTR macro.
(cfg_layout_duplicate_bb): Remove usage of EXIT_BLOCK_PTR macro.
(force_one_exit_fallthru): Likewise.
(rtl_verify_fallthru): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(rtl_verify_edges): Likewise.
(commit_edge_insertions): Likewise.
(commit_one_edge_insertion): Likewise.
(rtl_split_edge): Likewise.
(force_nonfallthru_and_redirect): Likewise.
(outof_cfg_layout_mode): Remove usage of EXIT_BLOCK_PTR macro.
(skip_insns_after_block): Likewise.
(fixup_partition_crossing): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(purge_dead_edges): Remove usage of EXIT_BLOCK_PTR macro.
(rtl_can_merge_blocks): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(contains_no_active_insn_p): Likewise.
(emit_insn_at_entry): Remove usage of ENTRY_BLOCK_PTR macro.
(entry_of_function): Likewise.
(last_bb_in_partition): Remove usage of EXIT_BLOCK_PTR macro.
(fixup_new_cold_bb): Likewise.
(patch_jump_insn): Likewise.
(try_redirect_by_replacing_jump): Likewise.
(block_label): Likewise.
(could_fall_through): Likewise.
(can_fallthru): Likewise.
* cgraphbuild.c (cgraph_rebuild_references): Remove usage of
ENTRY_BLOCK_PTR macro.
(rebuild_cgraph_edges): Likewise.
* cgraphunit.c (init_lowered_empty_function): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(expand_thunk): Remove usage of EXIT_BLOCK_PTR macro.
* combine.c (get_last_value): Remove usage of ENTRY_BLOCK_PTR macro.
(distribute_links): Remove usage of EXIT_BLOCK_PTR macro.
(get_last_value_validate): Remove usage of ENTRY_BLOCK_PTR macro.
(try_combine): Remove usage of EXIT_BLOCK_PTR macro.
(reg_num_sign_bit_copies_for_combine): Remove usage of ENTRY_BLOCK_PTR
macro.
(reg_nonzero_bits_for_combine): Likewise.
(set_nonzero_bits_and_sign_copies): Likewise.
(combine_instructions): Likewise.
* cprop.c (one_cprop_pass): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(bypass_conditional_jumps): Likewise.
(bypass_block): Remove usage of EXIT_BLOCK_PTR macro.
(find_implicit_sets): Likewise.
(cprop_jump): Likewise.
* cse.c (cse_cc_succs): Likewise.
(cse_find_path): Likewise.
* df-problems.c (df_lr_confluence_0): Likewise.
* df-scan.c (df_entry_block_defs_collect): Remove usage of
ENTRY_BLOCK_PTR macro.
(df_exit_block_uses_collect): Remove usage of EXIT_BLOCK_PTR macro.
* dominance.c (iterate_fix_dominators): Remove usage of
ENTRY_BLOCK_PTR macro.
(calc_idoms): Remove uses of macros: ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(determine_dominators_for_sons): Remove usage of ENTRY_BLOCK_PTR
macro.
(calc_dfs_tree): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(prune_bbs_to_update_dominators): Remove usage of ENTRY_BLOCK_PTR
macro.
(calc_dfs_tree_nonrec): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
* domwalk.c (cmp_bb_postorder): Likewise.
* dse.c (dse_step1): Remove usage of EXIT_BLOCK_PTR macro.
* except.c (finish_eh_generation): Remove usage of ENTRY_BLOCK_PTR
macro.
(sjlj_emit_function_enter): Likewise.
* final.c (compute_alignments): Likewise.
* function.c (thread_prologue_and_epilogue_insns): Remove uses of
macros: ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(reposition_prologue_and_epilogue_notes): Remove usage of
EXIT_BLOCK_PTR macro.
(convert_jumps_to_returns): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(regno_clobbered_at_setjmp): Remove usage of ENTRY_BLOCK_PTR macro.
(next_block_for_reg): Remove usage of EXIT_BLOCK_PTR macro.
* gcse.c (hoist_code): Remove usage of ENTRY_BLOCK_PTR macro.
(update_bb_reg_pressure): Remove usage of EXIT_BLOCK_PTR macro.
(compute_code_hoist_vbeinout): Likewise.
(should_hoist_expr_to_dom): Remove usage of ENTRY_BLOCK_PTR macro.
(pre_expr_reaches_here_p_work): Likewise.
* gimple-iterator.c (gsi_commit_edge_inserts): Likewise.
(gimple_find_edge_insert_loc): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
* gimple-ssa-strength-reduction.c (slsr_process_phi): Remove usage of
ENTRY_BLOCK_PTR macro.
* graph.c (draw_cfg_nodes_for_loop): Remove usage of EXIT_BLOCK_PTR
macro.
* graphite-clast-to-gimple.c (translate_clast_user): Remove usage of
ENTRY_BLOCK_PTR macro.
* graphite-scop-detection.c (build_scops): Likewise.
(create_sese_edges): Remove usage of EXIT_BLOCK_PTR macro.
(scopdet_basic_block_info): Remove usage of ENTRY_BLOCK_PTR macro.
* haifa-sched.c (restore_bb_notes): Remove usage of EXIT_BLOCK_PTR
macro.
(unlink_bb_notes): Likewise.
(create_check_block_twin): Likewise.
(init_before_recovery): Likewise.
(sched_extend_bb): Likewise.
(priority): Likewise.
* hw-doloop.c (reorder_loops): Likewise.
(discover_loop): Likewise.
* ifcvt.c (dead_or_predicable): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(find_if_case_1): Remove usage of EXIT_BLOCK_PTR macro.
(block_has_only_trap): Likewise.
(cond_exec_find_if_block): Likewise.
(merge_if_block): Likewise.
* ipa-inline-analysis.c (param_change_prob): Remove usage of
ENTRY_BLOCK_PTR macro.
(record_modified): Likewise.
* ipa-pure-const.c (execute_warn_function_noreturn): Remove usage of
EXIT_BLOCK_PTR macro.
(local_pure_const): Likewise.
* ipa-split.c (split_function): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(find_split_points): Likewise.
(consider_split): Likewise.
(find_return_bb): Remove usage of EXIT_BLOCK_PTR macro.
(verify_non_ssa_vars): Remove usage of ENTRY_BLOCK_PTR macro.
* ira-build.c (ira_loop_tree_body_rev_postorder): Likewise.
* ira-color.c (print_loop_title): Remove usage of EXIT_BLOCK_PTR
macro.
* ira-emit.c (entered_from_non_parent_p): Remove usage of
ENTRY_BLOCK_PTR macro.
(ira_emit): Remove usage of EXIT_BLOCK_PTR macro.
* ira-int.h (ira_assert): Remove usage of ENTRY_BLOCK_PTR macro.
* ira.c (split_live_ranges_for_shrink_wrap): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
* lcm.c (compute_rev_insert_delete): Remove usage of ENTRY_BLOCK_PTR
macro.
(compute_nearerout): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(compute_farthest): Likewise.
(compute_available): Likewise.
(compute_insert_delete): Remove usage of EXIT_BLOCK_PTR macro.
(compute_laterin): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(compute_earliest): Likewise.
(compute_antinout_edge): Likewise.
* loop-iv.c (simplify_using_initial_values): Remove usage of
ENTRY_BLOCK_PTR macro.
* loop-unswitch.c (unswitch_loop): Remove usage of EXIT_BLOCK_PTR
macro.
* lra-assigns.c (find_hard_regno_for): Remove usage of ENTRY_BLOCK_PTR
macro.
* lra-constraints.c (lra_inheritance): Remove usage of EXIT_BLOCK_PTR
macro.
* lra-lives.c (lra_create_live_ranges): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
* lra.c (has_nonexceptional_receiver): Remove usage of EXIT_BLOCK_PTR
macro.
* lto-streamer-in.c (input_function): Remove usage of ENTRY_BLOCK_PTR
macro.
* lto-streamer-out.c (output_cfg): Likewise.
* mcf.c (adjust_cfg_counts): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(create_fixup_graph): Remove usage of ENTRY_BLOCK_PTR macro.
* mode-switching.c (optimize_mode_switching): Likewise.
(create_pre_exit): Remove usage of EXIT_BLOCK_PTR macro.
* modulo-sched.c (rest_of_handle_sms): Likewise.
(canon_loop): Likewise.
* omp-low.c (build_omp_regions): Remove usage of ENTRY_BLOCK_PTR
macro.
* postreload-gcse.c (eliminate_partially_redundant_loads): Remove uses
of macros: ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
* predict.c (rebuild_frequencies): Remove usage of ENTRY_BLOCK_PTR
macro.
(propagate_freq): Remove usage of EXIT_BLOCK_PTR macro.
(estimate_bb_frequencies): Remove usage of ENTRY_BLOCK_PTR macro.
(tree_estimate_probability_bb): Remove usage of EXIT_BLOCK_PTR macro.
(expensive_function_p): Remove usage of ENTRY_BLOCK_PTR macro.
(tree_bb_level_predictions): Remove usage of EXIT_BLOCK_PTR macro.
(counts_to_freqs): Remove usage of ENTRY_BLOCK_PTR macro.
(apply_return_prediction): Remove usage of EXIT_BLOCK_PTR macro.
(estimate_loops): Remove usage of ENTRY_BLOCK_PTR macro.
(gimple_predict_edge): Likewise.
(probably_never_executed): Likewise.
* profile.c (find_spanning_tree): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(branch_prob): Likewise.
(compute_branch_probabilities): Likewise.
(compute_frequency_overlap): Remove usage of ENTRY_BLOCK_PTR macro.
(is_inconsistent): Remove usage of EXIT_BLOCK_PTR macro.
(read_profile_edge_counts): Remove usage of ENTRY_BLOCK_PTR macro.
(set_bb_counts): Likewise.
(correct_negative_edge_counts): Likewise.
(get_exec_counts): Likewise.
(instrument_values): Likewise.
(instrument_edges): Likewise.
* reg-stack.c (convert_regs): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(compensate_edges): Remove usage of ENTRY_BLOCK_PTR macro.
(convert_regs_exit): Remove usage of EXIT_BLOCK_PTR macro.
(convert_regs_entry): Remove usage of ENTRY_BLOCK_PTR macro.
(reg_to_stack): Likewise.
* regs.h (REG_N_SETS): Likewise.
* reload.c (find_dummy_reload): Likewise.
(combine_reloads): Likewise.
(push_reload): Likewise.
* reload1.c (has_nonexceptional_receiver): Remove usage of
EXIT_BLOCK_PTR macro.
* resource.c (mark_target_live_regs): Remove usage of ENTRY_BLOCK_PTR
macro.
(find_basic_block): Likewise.
* sched-ebb.c (ebb_add_block): Remove usage of EXIT_BLOCK_PTR macro.
(schedule_ebbs): Likewise.
* sched-int.h (sel_sched_p): Likewise.
* sched-rgn.c (compute_dom_prob_ps): Remove usage of ENTRY_BLOCK_PTR
macro.
(rgn_add_block): Remove usage of EXIT_BLOCK_PTR macro.
(haifa_find_rgns): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(propagate_deps): Remove usage of EXIT_BLOCK_PTR macro.
(extend_rgns): Likewise.
(find_single_block_region): Likewise.
* sel-sched-ir.c (sel_remove_loop_preheader): Remove usage of
ENTRY_BLOCK_PTR macro.
(setup_nop_and_exit_insns): Remove usage of EXIT_BLOCK_PTR macro.
(sel_create_recovery_block): Likewise.
(bb_ends_ebb_p): Likewise.
(sel_bb_end): Likewise.
(sel_bb_head): Likewise.
(free_lv_sets): Likewise.
(init_lv_sets): Likewise.
(tidy_control_flow): Likewise.
(maybe_tidy_empty_bb): Likewise.
* sel-sched-ir.h (_succ_iter_cond): Likewise.
(_succ_iter_start): Likewise.
(sel_bb_empty_or_nop_p): Likewise.
(get_loop_exit_edges_unique_dests): Likewise.
(inner_loop_header_p): Likewise.
* sel-sched.c (create_block_for_bookkeeping): Likewise.
(find_block_for_bookkeeping): Likewise.
* store-motion.c (remove_reachable_equiv_notes): Likewise.
(insert_store): Likewise.
* trans-mem.c (ipa_tm_transform_clone): Remove usage of
ENTRY_BLOCK_PTR macro.
(tm_memopt_compute_available): Remove usage of EXIT_BLOCK_PTR macro.
(ipa_tm_scan_irr_function): Remove usage of ENTRY_BLOCK_PTR macro.
(gate_tm_init): Likewise.
(tm_region_init): Likewise.
* tree-cfg.c (execute_fixup_cfg): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(execute_warn_function_return): Remove usage of EXIT_BLOCK_PTR macro.
(split_critical_edges): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(print_loops): Remove usage of ENTRY_BLOCK_PTR macro.
(move_sese_region_to_fn): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(gimple_redirect_edge_and_branch): Remove usage of ENTRY_BLOCK_PTR
macro.
(gimple_verify_flow_info): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(remove_edge_and_dominated_blocks): Remove usage of EXIT_BLOCK_PTR
macro.
(make_edges): Remove uses of macros: ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(gimple_flow_call_edges_add): Remove usage of EXIT_BLOCK_PTR macro.
(make_blocks): Remove usage of ENTRY_BLOCK_PTR macro.
(build_gimple_cfg): Likewise.
(gimple_duplicate_bb): Remove usage of EXIT_BLOCK_PTR macro.
(gimple_can_merge_blocks_p): Likewise.
* tree-cfgcleanup.c (tree_forwarder_block_p): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
* tree-complex.c (update_parameter_components): Remove usage of
ENTRY_BLOCK_PTR macro.
* tree-if-conv.c (get_loop_body_in_if_conv_order): Remove usage of
EXIT_BLOCK_PTR macro.
* tree-inline.c (tree_function_versioning): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(delete_unreachable_blocks_update_callgraph): Likewise.
(initialize_cfun): Likewise.
(copy_cfg_body): Remove usage of ENTRY_BLOCK_PTR macro.
(copy_edges_for_bb): Remove usage of EXIT_BLOCK_PTR macro.
(remap_ssa_name): Remove usage of ENTRY_BLOCK_PTR macro.
* tree-into-ssa.c (update_ssa): Likewise.
(maybe_register_def): Remove usage of EXIT_BLOCK_PTR macro.
(insert_updated_phi_nodes_for): Remove usage of ENTRY_BLOCK_PTR macro.
(rewrite_into_ssa): Likewise.
(rewrite_debug_stmt_uses): Likewise.
* tree-outof-ssa.c (expand_phi_nodes): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
* tree-profile.c (gimple_gen_ic_func_profiler): Remove usage of
ENTRY_BLOCK_PTR macro.
* tree-scalar-evolution.h (block_before_loop): Likewise.
* tree-sra.c (sra_ipa_reset_debug_stmts): Likewise.
(dump_dereferences_table): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(analyze_caller_dereference_legality): Remove usage of ENTRY_BLOCK_PTR
macro.
(propagate_dereference_distances): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(initialize_parameter_reductions): Remove usage of ENTRY_BLOCK_PTR
macro.
* tree-ssa-ccp.c (gsi_prev_dom_bb_nondebug): Likewise.
(optimize_stack_restore): Remove usage of EXIT_BLOCK_PTR macro.
* tree-ssa-coalesce.c (create_outofssa_var_map): Likewise.
* tree-ssa-dce.c (eliminate_unnecessary_stmts): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(remove_dead_stmt): Remove usage of EXIT_BLOCK_PTR macro.
(propagate_necessity): Remove usage of ENTRY_BLOCK_PTR macro.
(mark_control_dependent_edges_necessary): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
* tree-ssa-dom.c (eliminate_degenerate_phis): Remove usage of
ENTRY_BLOCK_PTR macro.
(tree_ssa_dominator_optimize): Remove usage of EXIT_BLOCK_PTR macro.
* tree-ssa-live.c (verify_live_on_entry): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(calculate_live_on_exit): Likewise.
(set_var_live_on_entry): Remove usage of ENTRY_BLOCK_PTR macro.
(loe_visit_block): Likewise.
* tree-ssa-live.h (live_on_exit): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(live_on_entry): Likewise.
* tree-ssa-loop-ivopts.c (find_interesting_uses): Remove usage of
EXIT_BLOCK_PTR macro.
* tree-ssa-loop-manip.c (compute_live_loop_exits): Remove usage of
ENTRY_BLOCK_PTR macro.
* tree-ssa-loop-niter.c (simplify_using_initial_conditions): Likewise.
(bound_difference): Likewise.
* tree-ssa-loop-prefetch.c (may_use_storent_in_loop_p): Remove usage
of EXIT_BLOCK_PTR macro.
* tree-ssa-loop-unswitch.c (simplify_using_entry_checks): Remove usage
of ENTRY_BLOCK_PTR macro.
* tree-ssa-math-opts.c (register_division_in): Likewise.
* tree-ssa-phiprop.c (tree_ssa_phiprop): Likewise.
* tree-ssa-pre.c (compute_avail): Likewise.
(compute_antic): Remove usage of EXIT_BLOCK_PTR macro.
(insert): Remove usage of ENTRY_BLOCK_PTR macro.
* tree-ssa-propagate.c (ssa_prop_init): Likewise.
(simulate_block): Remove usage of EXIT_BLOCK_PTR macro.
(cfg_blocks_add): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
(add_control_edge): Remove usage of EXIT_BLOCK_PTR macro.
* tree-ssa-reassoc.c (do_reassoc): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(build_and_add_sum): Remove usage of ENTRY_BLOCK_PTR macro.
* tree-ssa-sink.c (nearest_common_dominator_of_uses): Likewise.
(execute_sink_code): Remove usage of EXIT_BLOCK_PTR macro.
* tree-ssa-uninit.c (find_dom): Remove usage of ENTRY_BLOCK_PTR macro.
(compute_control_dep_chain): Remove usage of EXIT_BLOCK_PTR macro.
(find_pdom): Likewise.
(warn_uninitialized_vars): Remove usage of ENTRY_BLOCK_PTR macro.
* tree-stdarg.c (reachable_at_most_once): Likewise.
* tree-tailcall.c (tree_optimize_tail_calls_1): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(eliminate_tail_call): Likewise.
* tsan.c (instrument_func_entry): Remove usage of ENTRY_BLOCK_PTR
macro.
(instrument_func_exit): Remove usage of EXIT_BLOCK_PTR macro.
* var-tracking.c (vt_initialize): Remove uses of macros:
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
(vt_add_function_parameter): Remove usage of ENTRY_BLOCK_PTR macro.
(vt_find_locations): Remove usage of EXIT_BLOCK_PTR macro.
(vt_stack_adjustments): Remove uses of macros: ENTRY_BLOCK_PTR,
EXIT_BLOCK_PTR.
* varasm.c (assemble_start_function): Remove usage of ENTRY_BLOCK_PTR
macro.
* config/bfin/bfin.c (hwloop_optimize): Likewise.
* config/nds32/nds32.c (nds32_fp_as_gp_check_available): Remove usage
of EXIT_BLOCK_PTR macro.
* config/arm/arm.c (require_pic_register): Remove usage of
ENTRY_BLOCK_PTR macro.
(arm_r3_live_at_start_p): Likewise.
(any_sibcall_could_use_r3): Remove usage of EXIT_BLOCK_PTR macro.
* config/rs6000/rs6000.c (rs6000_emit_prologue): Likewise.
* config/frv/frv.c (frv_optimize_membar_global): Likewise.
* config/alpha/alpha.c (alpha_gp_save_rtx): Remove usage of
ENTRY_BLOCK_PTR macro.
* config/i386/i386.c (ix86_count_insn): Likewise.
(ix86_seh_fixup_eh_fallthru): Remove usage of EXIT_BLOCK_PTR macro.
(ix86_pad_short_function): Likewise.
(ix86_compute_frame_layout): Remove usage of ENTRY_BLOCK_PTR macro.
(ix86_pad_returns): Remove usage of EXIT_BLOCK_PTR macro.
(ix86_eax_live_at_start_p): Remove usage of ENTRY_BLOCK_PTR macro.
(add_condition_to_bb): Remove usage of EXIT_BLOCK_PTR macro.
(ix86_expand_epilogue): Likewise.
* config/ia64/ia64.c (ia64_asm_unwind_emit): Likewise.
(ia64_expand_prologue): Likewise.
From-SVN: r205055
2013-11-19 22:57:13 +01:00
|
|
|
insert_bb (occ, ENTRY_BLOCK_PTR_FOR_FN (cfun), &occ_head);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
occ->bb_has_division = true;
|
|
|
|
occ->num_divisions++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Compute the number of divisions that postdominate each block in OCC and
|
|
|
|
its children. */
|
2005-05-17 14:10:19 +02:00
|
|
|
|
|
|
|
static void
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
compute_merit (struct occurrence *occ)
|
2005-05-17 14:10:19 +02:00
|
|
|
{
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
struct occurrence *occ_child;
|
|
|
|
basic_block dom = occ->bb;
|
2005-05-17 14:10:19 +02:00
|
|
|
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
for (occ_child = occ->children; occ_child; occ_child = occ_child->next)
|
2005-05-17 14:10:19 +02:00
|
|
|
{
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
basic_block bb;
|
|
|
|
if (occ_child->children)
|
|
|
|
compute_merit (occ_child);
|
|
|
|
|
|
|
|
if (flag_exceptions)
|
|
|
|
bb = single_noncomplex_succ (dom);
|
|
|
|
else
|
|
|
|
bb = dom;
|
|
|
|
|
|
|
|
if (dominated_by_p (CDI_POST_DOMINATORS, bb, occ_child->bb))
|
|
|
|
occ->num_divisions += occ_child->num_divisions;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Return whether USE_STMT is a floating-point division by DEF. */
|
|
|
|
static inline bool
|
2008-07-28 16:33:56 +02:00
|
|
|
is_division_by (gimple use_stmt, tree def)
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
return is_gimple_assign (use_stmt)
|
|
|
|
&& gimple_assign_rhs_code (use_stmt) == RDIV_EXPR
|
|
|
|
&& gimple_assign_rhs2 (use_stmt) == def
|
2008-01-17 13:17:24 +01:00
|
|
|
/* Do not recognize x / x as valid division, as we are getting
|
|
|
|
confused later by replacing all immediate uses x in such
|
|
|
|
a stmt. */
|
2008-07-28 16:33:56 +02:00
|
|
|
&& gimple_assign_rhs1 (use_stmt) != def;
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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,
|
|
|
|
if it is not possible or profitable to do the optimization.
|
|
|
|
|
|
|
|
DEF_BSI is an iterator pointing at the statement defining DEF.
|
|
|
|
If RECIP_DEF is set, a dominator already has a computation that can
|
|
|
|
be used. */
|
|
|
|
|
|
|
|
static void
|
2008-07-28 16:33:56 +02:00
|
|
|
insert_reciprocals (gimple_stmt_iterator *def_gsi, struct occurrence *occ,
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
tree def, tree recip_def, int threshold)
|
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
tree type;
|
|
|
|
gimple new_stmt;
|
|
|
|
gimple_stmt_iterator gsi;
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
struct occurrence *occ_child;
|
|
|
|
|
|
|
|
if (!recip_def
|
|
|
|
&& (occ->bb_has_division || !flag_trapping_math)
|
|
|
|
&& occ->num_divisions >= threshold)
|
|
|
|
{
|
|
|
|
/* Make a variable with the replacement and substitute it. */
|
|
|
|
type = TREE_TYPE (def);
|
tree-flow.h (make_rename_temp): Remove.
2012-08-02 Richard Guenther <rguenther@suse.de>
* tree-flow.h (make_rename_temp): Remove.
* tree-dfa.c (make_rename_temp): Likewise.
* cgraphunit.c (thunk_adjust, assemble_thunk): Use create_tmp_reg
instead of make_rename_temp.
* omp-low.c (expand_omp_for_generic, expand_omp_for_static_nochunk,
expand_omp_atomic_pipeline): Likewise.
* trans-mem.c (tm_log_emit_save_or_restores, build_tm_load,
build_tm_store, expand_call_tm, expand_transaction,
ipa_tm_insert_gettmclone_call): Likewise.
* tree-complex.c (expand_complex_div_wide): Likewise.
* tree-mudflap.c (mf_decl_cache_locals, mf_build_check_statement_for):
Likewise.
* tree-ssa-loop-im.c (execute_sm_if_changed_flag_set, execute_sm):
Likewise.
* tree-ssa-math-opts.c (insert_reciprocals): Likewise.
* value-prof.c (gimple_divmod_fixed_value, gimple_mod_pow2,
gimple_mod_subtract): Likewise.
From-SVN: r190074
2012-08-02 13:41:35 +02:00
|
|
|
recip_def = create_tmp_reg (type, "reciptmp");
|
2008-07-28 16:33:56 +02:00
|
|
|
new_stmt = gimple_build_assign_with_ops (RDIV_EXPR, recip_def,
|
|
|
|
build_one_cst (type), def);
|
2009-11-25 11:55:54 +01:00
|
|
|
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
if (occ->bb_has_division)
|
|
|
|
{
|
|
|
|
/* Case 1: insert before an existing division. */
|
2008-07-28 16:33:56 +02:00
|
|
|
gsi = gsi_after_labels (occ->bb);
|
|
|
|
while (!gsi_end_p (gsi) && !is_division_by (gsi_stmt (gsi), def))
|
|
|
|
gsi_next (&gsi);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
|
2008-07-28 16:33:56 +02:00
|
|
|
gsi_insert_before (&gsi, new_stmt, GSI_SAME_STMT);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
}
|
2008-07-28 16:33:56 +02:00
|
|
|
else if (def_gsi && occ->bb == def_gsi->bb)
|
2005-08-01 10:52:59 +02:00
|
|
|
{
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
/* Case 2: insert right after the definition. Note that this will
|
|
|
|
never happen if the definition statement can throw, because in
|
|
|
|
that case the sole successor of the statement's basic block will
|
|
|
|
dominate all the uses as well. */
|
2008-07-28 16:33:56 +02:00
|
|
|
gsi_insert_after (def_gsi, new_stmt, GSI_NEW_STMT);
|
2005-08-01 10:52:59 +02:00
|
|
|
}
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Case 3: insert in a basic block not containing defs/uses. */
|
2008-07-28 16:33:56 +02:00
|
|
|
gsi = gsi_after_labels (occ->bb);
|
|
|
|
gsi_insert_before (&gsi, new_stmt, GSI_SAME_STMT);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
}
|
|
|
|
|
2011-04-13 21:39:02 +02:00
|
|
|
reciprocal_stats.rdivs_inserted++;
|
|
|
|
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
occ->recip_def_stmt = new_stmt;
|
2005-05-17 14:10:19 +02:00
|
|
|
}
|
|
|
|
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
occ->recip_def = recip_def;
|
|
|
|
for (occ_child = occ->children; occ_child; occ_child = occ_child->next)
|
2008-07-28 16:33:56 +02:00
|
|
|
insert_reciprocals (def_gsi, occ_child, def, recip_def, threshold);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Replace the division at USE_P with a multiplication by the reciprocal, if
|
|
|
|
possible. */
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
replace_reciprocal (use_operand_p use_p)
|
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple use_stmt = USE_STMT (use_p);
|
|
|
|
basic_block bb = gimple_bb (use_stmt);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
struct occurrence *occ = (struct occurrence *) bb->aux;
|
|
|
|
|
loop-unswitch.c (unswitch_single_loop): Use optimize_loop_for_speed_p.
* loop-unswitch.c (unswitch_single_loop): Use optimize_loop_for_speed_p.
* tree-ssa-threadupdate.c (mark_threaded_blocks): Use optimize_function_for_size_p.
* tracer.c (ignore_bb_p): Use optimize_bb_for_size_p.
* postreload-gcse.c (eliminate_partially_redundant_load): Use optimize_bb_for_size_p.
* value-prof.c (gimple_divmod_fixed_value_transform,
gimple_mod_pow2_value_transform, gimple_mod_subtract_transform,
gimple_stringops_transform): Use optimize_bb_for_size_p.
* ipa-cp.c (ipcp_insert_stage): Use optimize_function_for_size_p.
* final.c (compute_alignments): Use optimize_function_for_size_p.
* builtins.c (fold_builtin_cabs): Use optimize_function_for_speed_p.
(fold_builtin_strcpy, fold_builtin_fputs): Use
optimize_function_for_size_p.
* fold-const.c (tree_swap_operands_p): Use optimize_function_for_size_p.
* recog.c (relax_delay_slots): Likewise.
* tree-ssa-math-opts.c (replace_reciprocal): Use optimize_bb_for_speed_p.
(execute_cse_reciprocals): Use optimize_bb_for_size_p.
* ipa-inline.c (cgraph_decide_recursive_inlining): Use
optimize_function_for_size_p.
(cgraph_decide_inlining_of_small_function): Use
optimize_function_for_size_p.
* global.c (find_reg): Use optimize_function_for_size_p.
* opts.c (decode_options): Do not clear flag_tree_ch, flag_inline_functions,
flag_unswitch_loops, flag_unroll_loops, flag_unroll_all_loops and
flag_prefetch_loop_arrays. Those can work it out from profile.
* tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely): Use
optimize_loop_for_speed_p.
* predict.c (optimize_bb_for_size_p, optimize_bb_for_speed_p): Constify
argument.
(optimize_loop_nest_for_size_p, optimize_loop_nest_for_speed_p): New.
* tree-parloops.c (parallelize_loops): Use optimize_loop_for_size_p.
* tree-eh.c (decide_copy_try_finally): Use optimize_function_for_size_p.
* local-alloc.c (block_alloc): Pass BB pointer.
(find_free_reg): Add BB pointer, use optimize_bb_for_size_p.
* gcse.c (gcse_main): Use optimize_function_for_size_p.
* loop-unroll.c (decide_unrolling_and_peeling): Use optimize_loop_for_size_p.
(decide_peel_completely): Likewise.
* tree-vect-analyze.c (vect_mark_for_runtime_alias_test): Use
optimize_loop_for_size_p.
(vect_enhance_data_refs_alignment): Likewise.
* tree-ssa-coalesce.c (coalesce_cost): Add optimize_for_size argument.
(coalesce_cost_bb, coalesce_cost_edge, create_outofssa_var_map): Update call.
* cfgcleanup.c (outgoing_edges_match): Use optimize_bb_for_speed_p.
(try_crossjump_bb): Use optimize_bb_for_size_p.
* tree-ssa-loop-prefetch.c (loop_prefetch_arrays): Use
optimize_loop_for_speed_p.
* bb-reorder.c (find_traces_1_round): Likewise.
(copy_bb): Use optimize_bb_for_speed_p.
(duplicate_computed_gotos): Likewise.
* basic-block.h (optimize_loop_nest_for_size_p,
optimize_loop_nest_for_speed_p): New.
* stmt.c (expand_case): Use optimize_insn_for_size_p.
From-SVN: r139760
2008-08-29 12:35:57 +02:00
|
|
|
if (optimize_bb_for_speed_p (bb)
|
|
|
|
&& occ->recip_def && use_stmt != occ->recip_def_stmt)
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
{
|
2011-09-09 13:52:51 +02:00
|
|
|
gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt);
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple_assign_set_rhs_code (use_stmt, MULT_EXPR);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
SET_USE (use_p, occ->recip_def);
|
2011-09-09 13:52:51 +02:00
|
|
|
fold_stmt_inplace (&gsi);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
update_stmt (use_stmt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Free OCC and return one more "struct occurrence" to be freed. */
|
|
|
|
|
|
|
|
static struct occurrence *
|
|
|
|
free_bb (struct occurrence *occ)
|
|
|
|
{
|
|
|
|
struct occurrence *child, *next;
|
|
|
|
|
|
|
|
/* First get the two pointers hanging off OCC. */
|
|
|
|
next = occ->next;
|
|
|
|
child = occ->children;
|
|
|
|
occ->bb->aux = NULL;
|
|
|
|
pool_free (occ_pool, occ);
|
|
|
|
|
|
|
|
/* Now ensure that we don't recurse unless it is necessary. */
|
|
|
|
if (!child)
|
|
|
|
return next;
|
2005-08-09 05:28:38 +02:00
|
|
|
else
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
{
|
|
|
|
while (next)
|
|
|
|
next = free_bb (next);
|
|
|
|
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Look for floating-point divisions among DEF's uses, and try to
|
|
|
|
replace them by multiplications with the reciprocal. Add
|
|
|
|
as many statements computing the reciprocal as needed.
|
|
|
|
|
|
|
|
DEF must be a GIMPLE register of a floating-point type. */
|
|
|
|
|
|
|
|
static void
|
2008-07-28 16:33:56 +02:00
|
|
|
execute_cse_reciprocals_1 (gimple_stmt_iterator *def_gsi, tree def)
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
{
|
|
|
|
use_operand_p use_p;
|
|
|
|
imm_use_iterator use_iter;
|
|
|
|
struct occurrence *occ;
|
|
|
|
int count = 0, threshold;
|
2005-05-17 14:10:19 +02:00
|
|
|
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
gcc_assert (FLOAT_TYPE_P (TREE_TYPE (def)) && is_gimple_reg (def));
|
|
|
|
|
|
|
|
FOR_EACH_IMM_USE_FAST (use_p, use_iter, def)
|
2005-05-17 14:10:19 +02:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple use_stmt = USE_STMT (use_p);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
if (is_division_by (use_stmt, def))
|
2005-05-17 14:10:19 +02:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
register_division_in (gimple_bb (use_stmt));
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
count++;
|
2005-05-17 14:10:19 +02:00
|
|
|
}
|
|
|
|
}
|
2009-11-25 11:55:54 +01:00
|
|
|
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
/* Do the expensive part only if we can hope to optimize something. */
|
|
|
|
threshold = targetm.min_divisions_for_recip_mul (TYPE_MODE (TREE_TYPE (def)));
|
|
|
|
if (count >= threshold)
|
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple use_stmt;
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
for (occ = occ_head; occ; occ = occ->next)
|
|
|
|
{
|
|
|
|
compute_merit (occ);
|
2008-07-28 16:33:56 +02:00
|
|
|
insert_reciprocals (def_gsi, occ, def, NULL, threshold);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
}
|
|
|
|
|
2006-04-27 22:22:17 +02:00
|
|
|
FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, def)
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
{
|
|
|
|
if (is_division_by (use_stmt, def))
|
2006-04-27 22:22:17 +02:00
|
|
|
{
|
|
|
|
FOR_EACH_IMM_USE_ON_STMT (use_p, use_iter)
|
|
|
|
replace_reciprocal (use_p);
|
|
|
|
}
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (occ = occ_head; occ; )
|
|
|
|
occ = free_bb (occ);
|
|
|
|
|
|
|
|
occ_head = NULL;
|
2005-05-17 14:10:19 +02:00
|
|
|
}
|
|
|
|
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
/* Go through all the floating-point SSA_NAMEs, and call
|
|
|
|
execute_cse_reciprocals_1 on each of them. */
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
const pass_data pass_data_cse_reciprocals =
|
|
|
|
{
|
|
|
|
GIMPLE_PASS, /* type */
|
|
|
|
"recip", /* name */
|
|
|
|
OPTGROUP_NONE, /* optinfo_flags */
|
|
|
|
TV_NONE, /* tv_id */
|
|
|
|
PROP_ssa, /* properties_required */
|
|
|
|
0, /* properties_provided */
|
|
|
|
0, /* properties_destroyed */
|
|
|
|
0, /* todo_flags_start */
|
2014-05-06 15:35:40 +02:00
|
|
|
TODO_update_ssa, /* todo_flags_finish */
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class pass_cse_reciprocals : public gimple_opt_pass
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
pass_cse_reciprocals (gcc::context *ctxt)
|
|
|
|
: gimple_opt_pass (pass_data_cse_reciprocals, ctxt)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/* opt_pass methods: */
|
|
|
|
virtual bool gate (function *) { return optimize && flag_reciprocal_math; }
|
|
|
|
virtual unsigned int execute (function *);
|
|
|
|
|
|
|
|
}; // class pass_cse_reciprocals
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
pass_cse_reciprocals::execute (function *fun)
|
2005-05-17 14:10:19 +02:00
|
|
|
{
|
|
|
|
basic_block bb;
|
2005-08-01 10:58:25 +02:00
|
|
|
tree arg;
|
2005-08-01 10:52:59 +02:00
|
|
|
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
occ_pool = create_alloc_pool ("dominators for recip",
|
|
|
|
sizeof (struct occurrence),
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
n_basic_blocks_for_fn (fun) / 3 + 1);
|
2005-08-01 10:52:59 +02:00
|
|
|
|
2011-04-13 21:39:02 +02:00
|
|
|
memset (&reciprocal_stats, 0, sizeof (reciprocal_stats));
|
2006-07-05 08:47:21 +02:00
|
|
|
calculate_dominance_info (CDI_DOMINATORS);
|
|
|
|
calculate_dominance_info (CDI_POST_DOMINATORS);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
|
|
|
|
#ifdef ENABLE_CHECKING
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
FOR_EACH_BB_FN (bb, fun)
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
gcc_assert (!bb->aux);
|
|
|
|
#endif
|
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
for (arg = DECL_ARGUMENTS (fun->decl); arg; arg = DECL_CHAIN (arg))
|
2012-08-02 13:40:20 +02:00
|
|
|
if (FLOAT_TYPE_P (TREE_TYPE (arg))
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
&& is_gimple_reg (arg))
|
2012-08-02 13:40:20 +02:00
|
|
|
{
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
tree name = ssa_default_def (fun, arg);
|
2012-08-02 13:40:20 +02:00
|
|
|
if (name)
|
|
|
|
execute_cse_reciprocals_1 (NULL, name);
|
|
|
|
}
|
2005-08-01 10:58:25 +02:00
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
FOR_EACH_BB_FN (bb, fun)
|
2005-05-17 14:10:19 +02:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple_stmt_iterator gsi;
|
|
|
|
gimple phi;
|
|
|
|
tree def;
|
2005-05-17 14:10:19 +02:00
|
|
|
|
2008-07-28 16:33:56 +02:00
|
|
|
for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
2005-05-17 14:10:19 +02:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
phi = gsi_stmt (gsi);
|
2005-05-17 14:10:19 +02:00
|
|
|
def = PHI_RESULT (phi);
|
2012-08-14 16:16:18 +02:00
|
|
|
if (! virtual_operand_p (def)
|
|
|
|
&& FLOAT_TYPE_P (TREE_TYPE (def)))
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
execute_cse_reciprocals_1 (NULL, def);
|
2005-05-17 14:10:19 +02:00
|
|
|
}
|
|
|
|
|
2008-07-28 16:33:56 +02:00
|
|
|
for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
2005-05-17 14:10:19 +02:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple stmt = gsi_stmt (gsi);
|
2007-01-22 12:11:00 +01:00
|
|
|
|
2008-07-28 16:33:56 +02:00
|
|
|
if (gimple_has_lhs (stmt)
|
2005-05-17 14:10:19 +02:00
|
|
|
&& (def = SINGLE_SSA_TREE_OPERAND (stmt, SSA_OP_DEF)) != NULL
|
|
|
|
&& FLOAT_TYPE_P (TREE_TYPE (def))
|
2005-08-01 10:58:25 +02:00
|
|
|
&& TREE_CODE (def) == SSA_NAME)
|
2008-07-28 16:33:56 +02:00
|
|
|
execute_cse_reciprocals_1 (&gsi, def);
|
2005-05-17 14:10:19 +02:00
|
|
|
}
|
2007-06-16 11:52:48 +02:00
|
|
|
|
loop-unswitch.c (unswitch_single_loop): Use optimize_loop_for_speed_p.
* loop-unswitch.c (unswitch_single_loop): Use optimize_loop_for_speed_p.
* tree-ssa-threadupdate.c (mark_threaded_blocks): Use optimize_function_for_size_p.
* tracer.c (ignore_bb_p): Use optimize_bb_for_size_p.
* postreload-gcse.c (eliminate_partially_redundant_load): Use optimize_bb_for_size_p.
* value-prof.c (gimple_divmod_fixed_value_transform,
gimple_mod_pow2_value_transform, gimple_mod_subtract_transform,
gimple_stringops_transform): Use optimize_bb_for_size_p.
* ipa-cp.c (ipcp_insert_stage): Use optimize_function_for_size_p.
* final.c (compute_alignments): Use optimize_function_for_size_p.
* builtins.c (fold_builtin_cabs): Use optimize_function_for_speed_p.
(fold_builtin_strcpy, fold_builtin_fputs): Use
optimize_function_for_size_p.
* fold-const.c (tree_swap_operands_p): Use optimize_function_for_size_p.
* recog.c (relax_delay_slots): Likewise.
* tree-ssa-math-opts.c (replace_reciprocal): Use optimize_bb_for_speed_p.
(execute_cse_reciprocals): Use optimize_bb_for_size_p.
* ipa-inline.c (cgraph_decide_recursive_inlining): Use
optimize_function_for_size_p.
(cgraph_decide_inlining_of_small_function): Use
optimize_function_for_size_p.
* global.c (find_reg): Use optimize_function_for_size_p.
* opts.c (decode_options): Do not clear flag_tree_ch, flag_inline_functions,
flag_unswitch_loops, flag_unroll_loops, flag_unroll_all_loops and
flag_prefetch_loop_arrays. Those can work it out from profile.
* tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely): Use
optimize_loop_for_speed_p.
* predict.c (optimize_bb_for_size_p, optimize_bb_for_speed_p): Constify
argument.
(optimize_loop_nest_for_size_p, optimize_loop_nest_for_speed_p): New.
* tree-parloops.c (parallelize_loops): Use optimize_loop_for_size_p.
* tree-eh.c (decide_copy_try_finally): Use optimize_function_for_size_p.
* local-alloc.c (block_alloc): Pass BB pointer.
(find_free_reg): Add BB pointer, use optimize_bb_for_size_p.
* gcse.c (gcse_main): Use optimize_function_for_size_p.
* loop-unroll.c (decide_unrolling_and_peeling): Use optimize_loop_for_size_p.
(decide_peel_completely): Likewise.
* tree-vect-analyze.c (vect_mark_for_runtime_alias_test): Use
optimize_loop_for_size_p.
(vect_enhance_data_refs_alignment): Likewise.
* tree-ssa-coalesce.c (coalesce_cost): Add optimize_for_size argument.
(coalesce_cost_bb, coalesce_cost_edge, create_outofssa_var_map): Update call.
* cfgcleanup.c (outgoing_edges_match): Use optimize_bb_for_speed_p.
(try_crossjump_bb): Use optimize_bb_for_size_p.
* tree-ssa-loop-prefetch.c (loop_prefetch_arrays): Use
optimize_loop_for_speed_p.
* bb-reorder.c (find_traces_1_round): Likewise.
(copy_bb): Use optimize_bb_for_speed_p.
(duplicate_computed_gotos): Likewise.
* basic-block.h (optimize_loop_nest_for_size_p,
optimize_loop_nest_for_speed_p): New.
* stmt.c (expand_case): Use optimize_insn_for_size_p.
From-SVN: r139760
2008-08-29 12:35:57 +02:00
|
|
|
if (optimize_bb_for_size_p (bb))
|
|
|
|
continue;
|
|
|
|
|
2007-06-16 11:52:48 +02:00
|
|
|
/* Scan for a/func(b) and convert it to reciprocal a*rfunc(b). */
|
2008-07-28 16:33:56 +02:00
|
|
|
for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
2007-06-16 11:52:48 +02:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple stmt = gsi_stmt (gsi);
|
2007-06-16 11:52:48 +02:00
|
|
|
tree fndecl;
|
|
|
|
|
2008-07-28 16:33:56 +02:00
|
|
|
if (is_gimple_assign (stmt)
|
|
|
|
&& gimple_assign_rhs_code (stmt) == RDIV_EXPR)
|
2007-06-16 11:52:48 +02:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
tree arg1 = gimple_assign_rhs2 (stmt);
|
|
|
|
gimple stmt1;
|
2007-06-18 10:30:47 +02:00
|
|
|
|
|
|
|
if (TREE_CODE (arg1) != SSA_NAME)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
stmt1 = SSA_NAME_DEF_STMT (arg1);
|
2007-06-16 11:52:48 +02:00
|
|
|
|
2008-07-28 16:33:56 +02:00
|
|
|
if (is_gimple_call (stmt1)
|
|
|
|
&& gimple_call_lhs (stmt1)
|
|
|
|
&& (fndecl = gimple_call_fndecl (stmt1))
|
2007-06-16 11:52:48 +02:00
|
|
|
&& (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
|
|
|
|
|| DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD))
|
|
|
|
{
|
|
|
|
enum built_in_function code;
|
2009-11-06 16:05:20 +01:00
|
|
|
bool md_code, fail;
|
|
|
|
imm_use_iterator ui;
|
|
|
|
use_operand_p use_p;
|
2007-06-16 11:52:48 +02:00
|
|
|
|
|
|
|
code = DECL_FUNCTION_CODE (fndecl);
|
2007-06-18 10:30:47 +02:00
|
|
|
md_code = DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD;
|
|
|
|
|
|
|
|
fndecl = targetm.builtin_reciprocal (code, md_code, false);
|
2007-06-16 11:52:48 +02:00
|
|
|
if (!fndecl)
|
|
|
|
continue;
|
|
|
|
|
2009-11-06 16:05:20 +01:00
|
|
|
/* Check that all uses of the SSA name are divisions,
|
|
|
|
otherwise replacing the defining statement will do
|
|
|
|
the wrong thing. */
|
|
|
|
fail = false;
|
|
|
|
FOR_EACH_IMM_USE_FAST (use_p, ui, arg1)
|
|
|
|
{
|
|
|
|
gimple stmt2 = USE_STMT (use_p);
|
|
|
|
if (is_gimple_debug (stmt2))
|
|
|
|
continue;
|
|
|
|
if (!is_gimple_assign (stmt2)
|
|
|
|
|| gimple_assign_rhs_code (stmt2) != RDIV_EXPR
|
|
|
|
|| gimple_assign_rhs1 (stmt2) == arg1
|
|
|
|
|| gimple_assign_rhs2 (stmt2) != arg1)
|
|
|
|
{
|
|
|
|
fail = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fail)
|
|
|
|
continue;
|
|
|
|
|
2013-09-26 15:23:31 +02:00
|
|
|
gimple_replace_ssa_lhs (stmt1, arg1);
|
2008-08-09 19:28:39 +02:00
|
|
|
gimple_call_set_fndecl (stmt1, fndecl);
|
2007-06-16 11:52:48 +02:00
|
|
|
update_stmt (stmt1);
|
2011-04-13 21:39:02 +02:00
|
|
|
reciprocal_stats.rfuncs_inserted++;
|
2007-06-16 11:52:48 +02:00
|
|
|
|
2009-11-06 16:05:20 +01:00
|
|
|
FOR_EACH_IMM_USE_STMT (stmt, ui, arg1)
|
|
|
|
{
|
2011-09-09 13:52:51 +02:00
|
|
|
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
|
2009-11-06 16:05:20 +01:00
|
|
|
gimple_assign_set_rhs_code (stmt, MULT_EXPR);
|
2011-09-09 13:52:51 +02:00
|
|
|
fold_stmt_inplace (&gsi);
|
2009-11-06 16:05:20 +01:00
|
|
|
update_stmt (stmt);
|
|
|
|
}
|
2007-06-16 11:52:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-05-17 14:10:19 +02:00
|
|
|
}
|
2005-08-01 10:52:59 +02:00
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
statistics_counter_event (fun, "reciprocal divs inserted",
|
2011-04-13 21:39:02 +02:00
|
|
|
reciprocal_stats.rdivs_inserted);
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
statistics_counter_event (fun, "reciprocal functions inserted",
|
2011-04-13 21:39:02 +02:00
|
|
|
reciprocal_stats.rfuncs_inserted);
|
|
|
|
|
2006-07-05 08:47:21 +02:00
|
|
|
free_dominance_info (CDI_DOMINATORS);
|
|
|
|
free_dominance_info (CDI_POST_DOMINATORS);
|
re PR tree-optimization/23109 (compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math))
gcc:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* Makefile.in (tree-ssa-math-opts.o): Adjust dependencies.
* tree-cfg.c (single_noncomplex_succ): New.
* tree-flow.h (single_noncomplex_succ): Declare it.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
* tree-ssa-math-opts.c (enum place_reciprocal): Remove.
(struct occurrence, occ_head, occ_pool, is_divide_by, compute_merit,
insert_bb, register_division_in, insert_reciprocals,
replace_reciprocal, free_bb): New.
(execute_cse_reciprocals_1): Rewritten.
(execute_cse_reciprocals): Adjust calls to execute_cse_reciprocals_1.
Do not commit any edge insertion. Always compute dominators and
create the allocation pool.
* target-def.h (TARGET_MIN_DIVISIONS_FOR_RECIP_MUL): New.
* target.h (struct gcc_target): Add min_divistions_for_recip_mul.
* targhooks.c (default_min_divistions_for_recip_mul): New.
* targhooks.h (default_min_divistions_for_recip_mul): New prototype.
* passes.c (init_optimization_passes): Run recip after tree loop
optimizations.
* doc/tm.texi (Misc): Document TARGET_MIN_DIVISIONS_FOR_RECIP_MUL.
gcc/testsuite:
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/23109
PR tree-optimization/23948
PR tree-optimization/24123
* gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
g++.dg/tree-ssa/pr23948.C: New testcases.
* gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
From-SVN: r109578
2006-01-11 14:02:18 +01:00
|
|
|
free_alloc_pool (occ_pool);
|
2006-03-02 20:00:11 +01:00
|
|
|
return 0;
|
2005-05-17 14:10:19 +02:00
|
|
|
}
|
|
|
|
|
2013-08-05 22:16:05 +02:00
|
|
|
} // anon namespace
|
|
|
|
|
|
|
|
gimple_opt_pass *
|
|
|
|
make_pass_cse_reciprocals (gcc::context *ctxt)
|
|
|
|
{
|
|
|
|
return new pass_cse_reciprocals (ctxt);
|
|
|
|
}
|
|
|
|
|
cgraphunit.c, [...]: Fix comment typos.
* cgraphunit.c, config/arm/arm.c, config/m68k/m68k.c,
ipa-inline.c, tree-profile.c, tree-ssa-live.c,
tree-ssa-math-opts.c, tree-ssanames.c, tree-vect-analyze.c,
value-prof.c: Fix comment typos.
From-SVN: r121374
2007-01-31 04:45:38 +01:00
|
|
|
/* Records an occurrence at statement USE_STMT in the vector of trees
|
2007-01-22 12:11:00 +01:00
|
|
|
STMTS if it is dominated by *TOP_BB or dominates it or this basic block
|
cgraphunit.c, [...]: Fix comment typos.
* cgraphunit.c, config/arm/arm.c, config/m68k/m68k.c,
ipa-inline.c, tree-profile.c, tree-ssa-live.c,
tree-ssa-math-opts.c, tree-ssanames.c, tree-vect-analyze.c,
value-prof.c: Fix comment typos.
From-SVN: r121374
2007-01-31 04:45:38 +01:00
|
|
|
is not yet initialized. Returns true if the occurrence was pushed on
|
2007-01-22 12:11:00 +01:00
|
|
|
the vector. Adjusts *TOP_BB to be the basic block dominating all
|
|
|
|
statements in the vector. */
|
|
|
|
|
|
|
|
static bool
|
This patch rewrites the old VEC macro-based interface into a new one based on the template class 'vec'.
This patch rewrites the old VEC macro-based interface into a new one
based on the template class 'vec'. The user-visible changes are
described in http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec.
I have tested the patch pretty extensively:
- Regular bootstraps on x86_64, ppc, ia64, sparc and hppa.
- Bootstraps with --enable-checking=release
- Bootstraps with --enable-checking=gc,gcac
- Basic builds on all targets (using contrib/config-list.mk).
We no longer access the vectors via VEC_* macros. The pattern is
"VEC_operation (T, A, V, args)" becomes "V.operation (args)".
The only thing I could not do is create proper ctors and dtors for the
vec class. Since these vectors are stored in unions, we
have to keep them as PODs (C++03 does not allow non-PODs in unions).
This means that creation and destruction must be explicit. There is a
new method vec<type, allocation, layout>::create() and another vec<type,
allocation, layout>::destroy() to allocate the internal vector.
For vectors that must be pointers, there is a family of free functions
that implement the operations that need to tolerate NULL vectors.
These functions all start with the prefix 'vec_safe_'. See the wiki
page for details.
The gengtype change removes the special handling for VEC() that used
to exist in gengtype. Additionally, it allows gengtype to recognize
templates of more than one argument and introduces the concept of an
undefined type (useful for template arguments that may or may not be
types).
When a TYPE_UNDEFINED is reached, gengtype will ignore it if it
happens inside a type marked with GTY((user)). Otherwise, it will
emit an error.
Finally, gengtype rejects root types marked GTY((user)) that are not
first class pointers.
2012-11-16 Diego Novillo <dnovillo@google.com>
VEC API overhaul (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* vec.c (register_overhead): Convert it into
member function of vec_prefix.
(release_overhead): Likewise.
(calculate_allocation): Likewise.
(vec_heap_free): Remove.
(vec_gc_o_reserve_1): Remove.
(vec_heap_o_reserve_1): Remove.
(vec_stack_o_reserve_1): Remove.
(vec_stack_o_reserve_exact): Remove.
(register_stack_vec): New.
(stack_vec_register_index): New.
(unregister_stack_vec): New.
(vec_assert_fail): Remove.
* vec.h: Conditionally include ggc.h. Document conditional
hackery.
Update top-level documentation.
(ALONE_VEC_CHECK_INFO): Remove.
(VEC_CHECK_INFO): Remove.
(ALONE_VEC_CHECK_DECL): Remove.
(VEC_CHECK_DECL): Remove.
(ALONE_VEC_CHECK_PASS): Remove.
(VEC_CHECK_PASS): Remove.
(VEC_ASSERT): Remove.
(vec_prefix): Add friends va_gc, va_gc_atomic, va_heap and
va_stack.
Mark fields alloc_ and num_ as protected.
(struct vec_t): Remove. Remove all function members.
(struct vl_embed): Declare.
(struct vl_ptr): Declare.
(free): Remove.
(reserve_exact): Remove.
(reserve): Remove.
(safe_splice): Remove.
(safe_push): Remove.
(safe_grow): Remove.
(safe_grow_cleared): Remove.
(safe_insert): Remove.
(DEF_VEC_I): Remove.
(DEF_VEC_ALLOC_I): Remove.
(DEF_VEC_P): Remove.
(DEF_VEC_ALLOC_P): Remove.
(DEF_VEC_O): Remove.
(DEF_VEC_ALLOC_O): Remove.
(DEF_VEC_ALLOC_P_STACK): Remove.
(DEF_VEC_ALLOC_O_STACK): Remove.
(DEF_VEC_ALLOC_I_STACK): Remove.
(DEF_VEC_A): Remove.
(DEF_VEC_ALLOC_A): Remove.
(vec_stack_p_reserve_exact_1): Remove.
(vec_stack_o_reserve): Remove.
(vec_stack_o_reserve_exact): Remove.
(VEC_length): Remove.
(VEC_empty): Remove.
(VEC_address): Remove.
(vec_address): Remove.
(VEC_last): Remove.
(VEC_index): Remove.
(VEC_iterate): Remove.
(VEC_embedded_size): Remove.
(VEC_embedded_init): Remove.
(VEC_free): Remove.
(VEC_copy): Remove.
(VEC_space): Remove.
(VEC_reserve): Remove.
(VEC_reserve_exact): Remove.
(VEC_splice): Remove.
(VEC_safe_splice): Remove.
(VEC_quick_push): Remove.
(VEC_safe_push): Remove.
(VEC_pop): Remove.
(VEC_truncate): Remove.
(VEC_safe_grow): Remove.
(VEC_replace): Remove.
(VEC_quick_insert): Remove.
(VEC_safe_insert): Remove.
(VEC_ordered_remove): Remove.
(VEC_unordered_remove): Remove.
(VEC_block_remove): Remove.
(VEC_lower_bound): Remove.
(VEC_alloc): Remove.
(VEC_qsort): Remove.
(va_heap): Declare.
(va_heap::default_layout): New typedef to vl_ptr.
(va_heap::reserve): New.
(va_heap::release): New.
(va_gc): Declare.
(va_gc::default_layout): New typedef to vl_embed.
(va_gc::reserve): New.
(va_gc::release): New.
(va_gc_atomic): Declare. Inherit from va_gc.
(va_stack): Declare.
(va_stack::default_layout): New typedef to vl_ptr.
(va_stack::alloc): New.
(va_stack::reserve): New.
(va_stack::release): New.
(register_stack_vec): Declare.
(stack_vec_register_index): Declare.
(unregister_stack_vec): Declare.
(vec<T, A = va_heap, L = typename A::default_layout>): Declare
empty vec template.
(vec<T, A, vl_embed>): Partial specialization for embedded
layout.
(vec<T, A, vl_embed>::allocated): New.
(vec<T, A, vl_embed>::length): New.
(vec<T, A, vl_embed>::is_empty): New.
(vec<T, A, vl_embed>::address): New.
(vec<T, A, vl_embed>::operator[]): New.
(vec<T, A, vl_embed>::last New.
(vec<T, A, vl_embed>::space): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::copy): New.
(vec<T, A, vl_embed>::splice): New.
(vec<T, A, vl_embed>::quick_push New.
(vec<T, A, vl_embed>::pop New.
(vec<T, A, vl_embed>::truncate): New.
(vec<T, A, vl_embed>::quick_insert): New.
(vec<T, A, vl_embed>::ordered_remove): New.
(vec<T, A, vl_embed>::unordered_remove): New.
(vec<T, A, vl_embed>::block_remove): New.
(vec<T, A, vl_embed>::qsort): New.
(vec<T, A, vl_embed>::lower_bound): New.
(vec<T, A, vl_embed>::embedded_size): New.
(vec<T, A, vl_embed>::embedded_init): New.
(vec<T, A, vl_embed>::quick_grow): New.
(vec<T, A, vl_embed>::quick_grow_cleared): New.
(vec_safe_space): New.
(vec_safe_length): New.
(vec_safe_address): New.
(vec_safe_is_empty): New.
(vec_safe_reserve): New.
(vec_safe_reserve_exact): New.
(vec_alloc): New.
(vec_free): New.
(vec_safe_grow): New.
(vec_safe_grow_cleared): New.
(vec_safe_iterate): New.
(vec_safe_push): New.
(vec_safe_insert): New.
(vec_safe_truncate): New.
(vec_safe_copy): New.
(vec_safe_splice): New.
(vec<T, A, vl_ptr>): New partial specialization for the space
efficient layout.
(vec<T, A, vl_ptr>::exists): New.
(vec<T, A, vl_ptr>::is_empty): New.
(vec<T, A, vl_ptr>::length): New.
(vec<T, A, vl_ptr>::address): New.
(vec<T, A, vl_ptr>::operator[]): New.
(vec<T, A, vl_ptr>::operator!=): New.
(vec<T, A, vl_ptr>::operator==): New.
(vec<T, A, vl_ptr>::last): New.
(vec<T, A, vl_ptr>::space): New.
(vec<T, A, vl_ptr>::iterate): New.
(vec<T, A, vl_ptr>::copy): New.
(vec<T, A, vl_ptr>::reserve): New.
(vec<T, A, vl_ptr>::reserve_exact): New.
(vec<T, A, vl_ptr>::splice): New.
(vec<T, A, vl_ptr>::safe_splice): New.
(vec<T, A, vl_ptr>::quick_push): New.
(vec<T, A, vl_ptr>::safe_push): New.
(vec<T, A, vl_ptr>::pop): New.
(vec<T, A, vl_ptr>::truncate): New.
(vec<T, A, vl_ptr>::safe_grow): New.
(vec<T, A, vl_ptr>::safe_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_grow): New.
(vec<T, A, vl_ptr>::quick_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_insert): New.
(vec<T, A, vl_ptr>::safe_insert): New.
(vec<T, A, vl_ptr>::ordered_remove): New.
(vec<T, A, vl_ptr>::unordered_remove): New.
(vec<T, A, vl_ptr>::block_remove): New.
(vec<T, A, vl_ptr>::qsort): New.
(vec<T, A, vl_ptr>::lower_bound): New.
(vec_stack_alloc): Define.
(FOR_EACH_VEC_SAFE_ELT): Define.
* vecir.h: Remove. Update all users.
* vecprim.h: Remove. Update all users.
Move uchar to coretypes.h.
* Makefile.in (VEC_H): Add $(GGC_H).
Remove vecir.h and vecprim.h dependencies everywhere.
2012-11-16 Diego Novillo <dnovillo@google.com>
* gengtype-lex.l (VEC): Remove.
Add characters in the set [\!\>\.-].
* gengtype-parse.c (token_names): Remove "VEC".
(require_template_declaration): Remove handling of VEC_TOKEN.
(type): Likewise.
Call create_user_defined_type when parsing GTY((user)).
* gengtype-state.c (type_lineloc): handle TYPE_UNDEFINED.
(write_state_undefined_type): New.
(write_state_type): Call write_state_undefined_type for
TYPE_UNDEFINED.
(read_state_type): Call read_state_undefined_type for
TYPE_UNDEFINED.
* gengtype.c (dbgprint_count_type_at): Handle TYPE_UNDEFINED.
(create_user_defined_type): Make extern.
(type_for_name): Factor out of resolve_typedef.
(create_undefined_type): New
(resolve_typedef): Call it when we cannot find a previous
typedef and the type is not a template.
(find_structure): Accept TYPE_UNDEFINED.
(set_gc_used_type): Add argument ALLOWED_UNDEFINED_TYPES,
default to false.
Emit an error for TYPE_UNDEFINED unless LEVEL is GC_UNUSED or
ALLOWED_UNDEFINED_TYPES is set.
Set ALLOWED_UNDEFINED_TYPES to true for TYPE_USER_STRUCT.
(filter_type_name): Accept templates with more than one
argument.
(output_mangled_typename): Handle TYPE_UNDEFINED
(walk_type): Likewise.
(write_types_process_field): Likewise.
(write_func_for_structure): If CHAIN_NEXT is set, ORIG_S
should not be a user-defined type.
(write_types_local_user_process_field): Handle TYPE_ARRAY,
TYPE_NONE and TYPE_UNDEFINED.
(write_types_local_process_field): Likewise.
(contains_scalar_p): Return 0 for TYPE_USER_STRUCT.
(write_root): Reject user-defined types that are not pointers.
Handle TYPE_NONE, TYPE_UNDEFINED, TYPE_UNION, TYPE_LANG_STRUCT
and TYPE_PARAM_STRUCT.
(output_typename): Handle TYPE_NONE, TYPE_UNDEFINED, and
TYPE_ARRAY.
(dump_typekind): Handle TYPE_UNDEFINED.
* gengtype.h (enum typekind): Add TYPE_UNDEFINED.
(create_user_defined_type): Declare.
(enum gty_token): Remove VEC_TOKEN.
2012-11-16 Diego Novillo <dnovillo@google.com>
Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* coretypes.h (uchar): Define.
* alias.c: Use new vec API in vec.h.
* asan.c: Likewise.
* attribs.c: Likewise.
* basic-block.h: Likewise.
* bb-reorder.c: Likewise.
* builtins.c: Likewise.
* calls.c: Likewise.
* cfg.c: Likewise.
* cfganal.c: Likewise.
* cfgcleanup.c: Likewise.
* cfgexpand.c: Likewise.
* cfghooks.c: Likewise.
* cfghooks.h: Likewise.
* cfgloop.c: Likewise.
* cfgloop.h: Likewise.
* cfgloopanal.c: Likewise.
* cfgloopmanip.c: Likewise.
* cfgrtl.c: Likewise.
* cgraph.c: Likewise.
* cgraph.h: Likewise.
* cgraphclones.c: Likewise.
* cgraphunit.c: Likewise.
* combine.c: Likewise.
* compare-elim.c: Likewise.
* coverage.c: Likewise.
* cprop.c: Likewise.
* data-streamer.h: Likewise.
* dbxout.c: Likewise.
* dce.c: Likewise.
* df-core.c: Likewise.
* df-problems.c: Likewise.
* df-scan.c: Likewise.
* dominance.c: Likewise.
* domwalk.c: Likewise.
* domwalk.h: Likewise.
* dse.c: Likewise.
* dwarf2cfi.c: Likewise.
* dwarf2out.c: Likewise.
* dwarf2out.h: Likewise.
* emit-rtl.c: Likewise.
* except.c: Likewise.
* except.h: Likewise.
* expr.c: Likewise.
* expr.h: Likewise.
* final.c: Likewise.
* fold-const.c: Likewise.
* function.c: Likewise.
* function.h: Likewise.
* fwprop.c: Likewise.
* gcc.c: Likewise.
* gcse.c: Likewise.
* genattr.c: Likewise.
* genattrtab.c: Likewise.
* genautomata.c: Likewise.
* genextract.c: Likewise.
* genopinit.c: Likewise
* ggc-common.c: Likewise.
* ggc.h: Likewise.
* gimple-low.c: Likewise.
* gimple-ssa-strength-reduction.c: Likewise.
* gimple-streamer-in.c: Likewise.
* gimple.c: Likewise.
* gimple.h: Likewise.
* gimplify.c: Likewise.
* graph.c: Likewise.
* graphds.c: Likewise.
* graphds.h: Likewise.
* graphite-blocking.c: Likewise.
* graphite-clast-to-gimple.c: Likewise.
* graphite-dependences.c: Likewise.
* graphite-interchange.c: Likewise.
* graphite-optimize-isl.c: Likewise.
* graphite-poly.c: Likewise.
* graphite-poly.h: Likewise.
* graphite-scop-detection.c: Likewise.
* graphite-scop-detection.h: Likewise.
* graphite-sese-to-poly.c: Likewise.
* graphite.c: Likewise.
* godump.c: Likewise.
* haifa-sched.c: Likewise.
* hw-doloop.c: Likewise.
* hw-doloop.h: Likewise.
* ifcvt.c: Likewise.
* insn-addr.h: Likewise.
* ipa-cp.c: Likewise.
* ipa-inline-analysis.c: Likewise.
* ipa-inline-transform.c: Likewise.
* ipa-inline.c: Likewise.
* ipa-inline.h: Likewise.
* ipa-prop.c: Likewise.
* ipa-prop.h: Likewise.
* ipa-pure-const.c: Likewise.
* ipa-ref-inline.h: Likewise.
* ipa-ref.c: Likewise.
* ipa-ref.h: Likewise.
* ipa-reference.c: Likewise.
* ipa-split.c: Likewise.
* ipa-utils.c: Likewise.
* ipa-utils.h: Likewise.
* ipa.c: Likewise.
* ira-build.c: Likewise.
* ira-color.c: Likewise.
* ira-emit.c: Likewise.
* ira-int.h: Likewise.
* ira.c: Likewise.
* loop-invariant.c: Likewise.
* loop-unroll.c: Likewise.
* lower-subreg.c: Likewise.
* lra-lives.c: Likewise.
* lra.c: Likewise.
* lto-cgraph.c: Likewise.
* lto-section-out.c: Likewise.
* lto-streamer-in.c: Likewise.
* lto-streamer-out.c: Likewise.
* lto-streamer.h: Likewise.
* lto-symtab.c: Likewise.
* mcf.c: Likewise.
* modulo-sched.c: Likewise.
* omp-low.c: Likewise.
* opts-common.c: Likewise.
* opts-global.c: Likewise.
* opts.c: Likewise.
* opts.h: Likewise.
* passes.c: Likewise.
* predict.c: Likewise.
* print-tree.c: Likewise.
* profile.c: Likewise.
* profile.h: Likewise.
* read-rtl.c: Likewise.
* ree.c: Likewise.
* reg-stack.c: Likewise.
* regrename.c: Likewise.
* regrename.h: Likewise.
* reload.c: Likewise.
* reload.h: Likewise.
* reload1.c: Likewise.
* rtl.h: Likewise.
* sched-deps.c: Likewise.
* sched-int.h: Likewise.
* sdbout.c: Likewise.
* sel-sched-dump.c: Likewise.
* sel-sched-ir.c: Likewise.
* sel-sched-ir.h: Likewise.
* sel-sched.c: Likewise.
* sese.c: Likewise.
* sese.h: Likewise.
* statistics.h: Likewise.
* stmt.c: Likewise.
* stor-layout.c: Likewise.
* store-motion.c: Likewise.
* tlink.c: Likewise.
* toplev.c: Likewise.
* trans-mem.c: Likewise.
* tree-browser.c: Likewise.
* tree-call-cdce.c: Likewise.
* tree-cfg.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-chrec.c: Likewise.
* tree-chrec.h: Likewise.
* tree-complex.c: Likewise.
* tree-data-ref.c: Likewise.
* tree-data-ref.h: Likewise.
* tree-dfa.c: Likewise.
* tree-diagnostic.c: Likewise.
* tree-dump.c: Likewise.
* tree-eh.c: Likewise.
* tree-emutls.c: Likewise.
* tree-flow.h: Likewise.
* tree-if-conv.c: Likewise.
* tree-inline.c: Likewise.
* tree-inline.h: Likewise.
* tree-into-ssa.c: Likewise.
* tree-iterator.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-mudflap.c: Likewise.
* tree-optimize.c: Likewise.
* tree-outof-ssa.c: Likewise.
* tree-parloops.c: Likewise.
* tree-phinodes.c: Likewise.
* tree-predcom.c: Likewise.
* tree-pretty-print.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-address.c: Likewise.
* tree-ssa-alias.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-coalesce.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-ssa-dom.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-live.c: Likewise.
* tree-ssa-live.h: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-operands.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-sccvn.h: Likewise.
* tree-ssa-strlen.c: Likewise.
* tree-ssa-structalias.c: Likewise.
* tree-ssa-tail-merge.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* tree-ssa-threadupdate.c: Likewise.
* tree-ssa-uncprop.c: Likewise.
* tree-ssa-uninit.c: Likewise.
* tree-ssa.c: Likewise.
* tree-ssanames.c: Likewise.
* tree-stdarg.c: Likewise.
* tree-streamer-in.c: Likewise.
* tree-streamer-out.c: Likewise.
* tree-streamer.c: Likewise.
* tree-streamer.h: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-generic.c: Likewise.
* tree-vect-loop-manip.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-slp.c: Likewise.
* tree-vect-stmts.c: Likewise.
* tree-vectorizer.c: Likewise.
* tree-vectorizer.h: Likewise.
* tree-vrp.c: Likewise.
* tree.c: Likewise.
* tree.h: Likewise.
* value-prof.c: Likewise.
* value-prof.h: Likewise.
* var-tracking.c: Likewise.
* varasm.c: Likewise.
* varpool.c: Likewise.
* vmsdbgout.c: Likewise.
* config/bfin/bfin.c: Likewise.
* config/c6x/c6x.c: Likewise.
* config/darwin.c: Likewise.
* config/i386/i386.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/mep/mep.c: Likewise.
* config/mips/mips.c: Likewise.
* config/pa/pa.c: Likewise.
* config/rs6000/rs6000-c.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/rx/rx.c: Likewise.
* config/spu/spu-c.c: Likewise.
* config/vms/vms.c: Likewise.
* config/vxworks.c: Likewise.
* config/epiphany/resolve-sw-modes.c: Likewise.
From-SVN: r193595
2012-11-18 03:54:30 +01:00
|
|
|
maybe_record_sincos (vec<gimple> *stmts,
|
2008-07-28 16:33:56 +02:00
|
|
|
basic_block *top_bb, gimple use_stmt)
|
2007-01-22 12:11:00 +01:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
basic_block use_bb = gimple_bb (use_stmt);
|
2007-01-22 12:11:00 +01:00
|
|
|
if (*top_bb
|
|
|
|
&& (*top_bb == use_bb
|
|
|
|
|| dominated_by_p (CDI_DOMINATORS, use_bb, *top_bb)))
|
This patch rewrites the old VEC macro-based interface into a new one based on the template class 'vec'.
This patch rewrites the old VEC macro-based interface into a new one
based on the template class 'vec'. The user-visible changes are
described in http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec.
I have tested the patch pretty extensively:
- Regular bootstraps on x86_64, ppc, ia64, sparc and hppa.
- Bootstraps with --enable-checking=release
- Bootstraps with --enable-checking=gc,gcac
- Basic builds on all targets (using contrib/config-list.mk).
We no longer access the vectors via VEC_* macros. The pattern is
"VEC_operation (T, A, V, args)" becomes "V.operation (args)".
The only thing I could not do is create proper ctors and dtors for the
vec class. Since these vectors are stored in unions, we
have to keep them as PODs (C++03 does not allow non-PODs in unions).
This means that creation and destruction must be explicit. There is a
new method vec<type, allocation, layout>::create() and another vec<type,
allocation, layout>::destroy() to allocate the internal vector.
For vectors that must be pointers, there is a family of free functions
that implement the operations that need to tolerate NULL vectors.
These functions all start with the prefix 'vec_safe_'. See the wiki
page for details.
The gengtype change removes the special handling for VEC() that used
to exist in gengtype. Additionally, it allows gengtype to recognize
templates of more than one argument and introduces the concept of an
undefined type (useful for template arguments that may or may not be
types).
When a TYPE_UNDEFINED is reached, gengtype will ignore it if it
happens inside a type marked with GTY((user)). Otherwise, it will
emit an error.
Finally, gengtype rejects root types marked GTY((user)) that are not
first class pointers.
2012-11-16 Diego Novillo <dnovillo@google.com>
VEC API overhaul (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* vec.c (register_overhead): Convert it into
member function of vec_prefix.
(release_overhead): Likewise.
(calculate_allocation): Likewise.
(vec_heap_free): Remove.
(vec_gc_o_reserve_1): Remove.
(vec_heap_o_reserve_1): Remove.
(vec_stack_o_reserve_1): Remove.
(vec_stack_o_reserve_exact): Remove.
(register_stack_vec): New.
(stack_vec_register_index): New.
(unregister_stack_vec): New.
(vec_assert_fail): Remove.
* vec.h: Conditionally include ggc.h. Document conditional
hackery.
Update top-level documentation.
(ALONE_VEC_CHECK_INFO): Remove.
(VEC_CHECK_INFO): Remove.
(ALONE_VEC_CHECK_DECL): Remove.
(VEC_CHECK_DECL): Remove.
(ALONE_VEC_CHECK_PASS): Remove.
(VEC_CHECK_PASS): Remove.
(VEC_ASSERT): Remove.
(vec_prefix): Add friends va_gc, va_gc_atomic, va_heap and
va_stack.
Mark fields alloc_ and num_ as protected.
(struct vec_t): Remove. Remove all function members.
(struct vl_embed): Declare.
(struct vl_ptr): Declare.
(free): Remove.
(reserve_exact): Remove.
(reserve): Remove.
(safe_splice): Remove.
(safe_push): Remove.
(safe_grow): Remove.
(safe_grow_cleared): Remove.
(safe_insert): Remove.
(DEF_VEC_I): Remove.
(DEF_VEC_ALLOC_I): Remove.
(DEF_VEC_P): Remove.
(DEF_VEC_ALLOC_P): Remove.
(DEF_VEC_O): Remove.
(DEF_VEC_ALLOC_O): Remove.
(DEF_VEC_ALLOC_P_STACK): Remove.
(DEF_VEC_ALLOC_O_STACK): Remove.
(DEF_VEC_ALLOC_I_STACK): Remove.
(DEF_VEC_A): Remove.
(DEF_VEC_ALLOC_A): Remove.
(vec_stack_p_reserve_exact_1): Remove.
(vec_stack_o_reserve): Remove.
(vec_stack_o_reserve_exact): Remove.
(VEC_length): Remove.
(VEC_empty): Remove.
(VEC_address): Remove.
(vec_address): Remove.
(VEC_last): Remove.
(VEC_index): Remove.
(VEC_iterate): Remove.
(VEC_embedded_size): Remove.
(VEC_embedded_init): Remove.
(VEC_free): Remove.
(VEC_copy): Remove.
(VEC_space): Remove.
(VEC_reserve): Remove.
(VEC_reserve_exact): Remove.
(VEC_splice): Remove.
(VEC_safe_splice): Remove.
(VEC_quick_push): Remove.
(VEC_safe_push): Remove.
(VEC_pop): Remove.
(VEC_truncate): Remove.
(VEC_safe_grow): Remove.
(VEC_replace): Remove.
(VEC_quick_insert): Remove.
(VEC_safe_insert): Remove.
(VEC_ordered_remove): Remove.
(VEC_unordered_remove): Remove.
(VEC_block_remove): Remove.
(VEC_lower_bound): Remove.
(VEC_alloc): Remove.
(VEC_qsort): Remove.
(va_heap): Declare.
(va_heap::default_layout): New typedef to vl_ptr.
(va_heap::reserve): New.
(va_heap::release): New.
(va_gc): Declare.
(va_gc::default_layout): New typedef to vl_embed.
(va_gc::reserve): New.
(va_gc::release): New.
(va_gc_atomic): Declare. Inherit from va_gc.
(va_stack): Declare.
(va_stack::default_layout): New typedef to vl_ptr.
(va_stack::alloc): New.
(va_stack::reserve): New.
(va_stack::release): New.
(register_stack_vec): Declare.
(stack_vec_register_index): Declare.
(unregister_stack_vec): Declare.
(vec<T, A = va_heap, L = typename A::default_layout>): Declare
empty vec template.
(vec<T, A, vl_embed>): Partial specialization for embedded
layout.
(vec<T, A, vl_embed>::allocated): New.
(vec<T, A, vl_embed>::length): New.
(vec<T, A, vl_embed>::is_empty): New.
(vec<T, A, vl_embed>::address): New.
(vec<T, A, vl_embed>::operator[]): New.
(vec<T, A, vl_embed>::last New.
(vec<T, A, vl_embed>::space): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::copy): New.
(vec<T, A, vl_embed>::splice): New.
(vec<T, A, vl_embed>::quick_push New.
(vec<T, A, vl_embed>::pop New.
(vec<T, A, vl_embed>::truncate): New.
(vec<T, A, vl_embed>::quick_insert): New.
(vec<T, A, vl_embed>::ordered_remove): New.
(vec<T, A, vl_embed>::unordered_remove): New.
(vec<T, A, vl_embed>::block_remove): New.
(vec<T, A, vl_embed>::qsort): New.
(vec<T, A, vl_embed>::lower_bound): New.
(vec<T, A, vl_embed>::embedded_size): New.
(vec<T, A, vl_embed>::embedded_init): New.
(vec<T, A, vl_embed>::quick_grow): New.
(vec<T, A, vl_embed>::quick_grow_cleared): New.
(vec_safe_space): New.
(vec_safe_length): New.
(vec_safe_address): New.
(vec_safe_is_empty): New.
(vec_safe_reserve): New.
(vec_safe_reserve_exact): New.
(vec_alloc): New.
(vec_free): New.
(vec_safe_grow): New.
(vec_safe_grow_cleared): New.
(vec_safe_iterate): New.
(vec_safe_push): New.
(vec_safe_insert): New.
(vec_safe_truncate): New.
(vec_safe_copy): New.
(vec_safe_splice): New.
(vec<T, A, vl_ptr>): New partial specialization for the space
efficient layout.
(vec<T, A, vl_ptr>::exists): New.
(vec<T, A, vl_ptr>::is_empty): New.
(vec<T, A, vl_ptr>::length): New.
(vec<T, A, vl_ptr>::address): New.
(vec<T, A, vl_ptr>::operator[]): New.
(vec<T, A, vl_ptr>::operator!=): New.
(vec<T, A, vl_ptr>::operator==): New.
(vec<T, A, vl_ptr>::last): New.
(vec<T, A, vl_ptr>::space): New.
(vec<T, A, vl_ptr>::iterate): New.
(vec<T, A, vl_ptr>::copy): New.
(vec<T, A, vl_ptr>::reserve): New.
(vec<T, A, vl_ptr>::reserve_exact): New.
(vec<T, A, vl_ptr>::splice): New.
(vec<T, A, vl_ptr>::safe_splice): New.
(vec<T, A, vl_ptr>::quick_push): New.
(vec<T, A, vl_ptr>::safe_push): New.
(vec<T, A, vl_ptr>::pop): New.
(vec<T, A, vl_ptr>::truncate): New.
(vec<T, A, vl_ptr>::safe_grow): New.
(vec<T, A, vl_ptr>::safe_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_grow): New.
(vec<T, A, vl_ptr>::quick_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_insert): New.
(vec<T, A, vl_ptr>::safe_insert): New.
(vec<T, A, vl_ptr>::ordered_remove): New.
(vec<T, A, vl_ptr>::unordered_remove): New.
(vec<T, A, vl_ptr>::block_remove): New.
(vec<T, A, vl_ptr>::qsort): New.
(vec<T, A, vl_ptr>::lower_bound): New.
(vec_stack_alloc): Define.
(FOR_EACH_VEC_SAFE_ELT): Define.
* vecir.h: Remove. Update all users.
* vecprim.h: Remove. Update all users.
Move uchar to coretypes.h.
* Makefile.in (VEC_H): Add $(GGC_H).
Remove vecir.h and vecprim.h dependencies everywhere.
2012-11-16 Diego Novillo <dnovillo@google.com>
* gengtype-lex.l (VEC): Remove.
Add characters in the set [\!\>\.-].
* gengtype-parse.c (token_names): Remove "VEC".
(require_template_declaration): Remove handling of VEC_TOKEN.
(type): Likewise.
Call create_user_defined_type when parsing GTY((user)).
* gengtype-state.c (type_lineloc): handle TYPE_UNDEFINED.
(write_state_undefined_type): New.
(write_state_type): Call write_state_undefined_type for
TYPE_UNDEFINED.
(read_state_type): Call read_state_undefined_type for
TYPE_UNDEFINED.
* gengtype.c (dbgprint_count_type_at): Handle TYPE_UNDEFINED.
(create_user_defined_type): Make extern.
(type_for_name): Factor out of resolve_typedef.
(create_undefined_type): New
(resolve_typedef): Call it when we cannot find a previous
typedef and the type is not a template.
(find_structure): Accept TYPE_UNDEFINED.
(set_gc_used_type): Add argument ALLOWED_UNDEFINED_TYPES,
default to false.
Emit an error for TYPE_UNDEFINED unless LEVEL is GC_UNUSED or
ALLOWED_UNDEFINED_TYPES is set.
Set ALLOWED_UNDEFINED_TYPES to true for TYPE_USER_STRUCT.
(filter_type_name): Accept templates with more than one
argument.
(output_mangled_typename): Handle TYPE_UNDEFINED
(walk_type): Likewise.
(write_types_process_field): Likewise.
(write_func_for_structure): If CHAIN_NEXT is set, ORIG_S
should not be a user-defined type.
(write_types_local_user_process_field): Handle TYPE_ARRAY,
TYPE_NONE and TYPE_UNDEFINED.
(write_types_local_process_field): Likewise.
(contains_scalar_p): Return 0 for TYPE_USER_STRUCT.
(write_root): Reject user-defined types that are not pointers.
Handle TYPE_NONE, TYPE_UNDEFINED, TYPE_UNION, TYPE_LANG_STRUCT
and TYPE_PARAM_STRUCT.
(output_typename): Handle TYPE_NONE, TYPE_UNDEFINED, and
TYPE_ARRAY.
(dump_typekind): Handle TYPE_UNDEFINED.
* gengtype.h (enum typekind): Add TYPE_UNDEFINED.
(create_user_defined_type): Declare.
(enum gty_token): Remove VEC_TOKEN.
2012-11-16 Diego Novillo <dnovillo@google.com>
Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* coretypes.h (uchar): Define.
* alias.c: Use new vec API in vec.h.
* asan.c: Likewise.
* attribs.c: Likewise.
* basic-block.h: Likewise.
* bb-reorder.c: Likewise.
* builtins.c: Likewise.
* calls.c: Likewise.
* cfg.c: Likewise.
* cfganal.c: Likewise.
* cfgcleanup.c: Likewise.
* cfgexpand.c: Likewise.
* cfghooks.c: Likewise.
* cfghooks.h: Likewise.
* cfgloop.c: Likewise.
* cfgloop.h: Likewise.
* cfgloopanal.c: Likewise.
* cfgloopmanip.c: Likewise.
* cfgrtl.c: Likewise.
* cgraph.c: Likewise.
* cgraph.h: Likewise.
* cgraphclones.c: Likewise.
* cgraphunit.c: Likewise.
* combine.c: Likewise.
* compare-elim.c: Likewise.
* coverage.c: Likewise.
* cprop.c: Likewise.
* data-streamer.h: Likewise.
* dbxout.c: Likewise.
* dce.c: Likewise.
* df-core.c: Likewise.
* df-problems.c: Likewise.
* df-scan.c: Likewise.
* dominance.c: Likewise.
* domwalk.c: Likewise.
* domwalk.h: Likewise.
* dse.c: Likewise.
* dwarf2cfi.c: Likewise.
* dwarf2out.c: Likewise.
* dwarf2out.h: Likewise.
* emit-rtl.c: Likewise.
* except.c: Likewise.
* except.h: Likewise.
* expr.c: Likewise.
* expr.h: Likewise.
* final.c: Likewise.
* fold-const.c: Likewise.
* function.c: Likewise.
* function.h: Likewise.
* fwprop.c: Likewise.
* gcc.c: Likewise.
* gcse.c: Likewise.
* genattr.c: Likewise.
* genattrtab.c: Likewise.
* genautomata.c: Likewise.
* genextract.c: Likewise.
* genopinit.c: Likewise
* ggc-common.c: Likewise.
* ggc.h: Likewise.
* gimple-low.c: Likewise.
* gimple-ssa-strength-reduction.c: Likewise.
* gimple-streamer-in.c: Likewise.
* gimple.c: Likewise.
* gimple.h: Likewise.
* gimplify.c: Likewise.
* graph.c: Likewise.
* graphds.c: Likewise.
* graphds.h: Likewise.
* graphite-blocking.c: Likewise.
* graphite-clast-to-gimple.c: Likewise.
* graphite-dependences.c: Likewise.
* graphite-interchange.c: Likewise.
* graphite-optimize-isl.c: Likewise.
* graphite-poly.c: Likewise.
* graphite-poly.h: Likewise.
* graphite-scop-detection.c: Likewise.
* graphite-scop-detection.h: Likewise.
* graphite-sese-to-poly.c: Likewise.
* graphite.c: Likewise.
* godump.c: Likewise.
* haifa-sched.c: Likewise.
* hw-doloop.c: Likewise.
* hw-doloop.h: Likewise.
* ifcvt.c: Likewise.
* insn-addr.h: Likewise.
* ipa-cp.c: Likewise.
* ipa-inline-analysis.c: Likewise.
* ipa-inline-transform.c: Likewise.
* ipa-inline.c: Likewise.
* ipa-inline.h: Likewise.
* ipa-prop.c: Likewise.
* ipa-prop.h: Likewise.
* ipa-pure-const.c: Likewise.
* ipa-ref-inline.h: Likewise.
* ipa-ref.c: Likewise.
* ipa-ref.h: Likewise.
* ipa-reference.c: Likewise.
* ipa-split.c: Likewise.
* ipa-utils.c: Likewise.
* ipa-utils.h: Likewise.
* ipa.c: Likewise.
* ira-build.c: Likewise.
* ira-color.c: Likewise.
* ira-emit.c: Likewise.
* ira-int.h: Likewise.
* ira.c: Likewise.
* loop-invariant.c: Likewise.
* loop-unroll.c: Likewise.
* lower-subreg.c: Likewise.
* lra-lives.c: Likewise.
* lra.c: Likewise.
* lto-cgraph.c: Likewise.
* lto-section-out.c: Likewise.
* lto-streamer-in.c: Likewise.
* lto-streamer-out.c: Likewise.
* lto-streamer.h: Likewise.
* lto-symtab.c: Likewise.
* mcf.c: Likewise.
* modulo-sched.c: Likewise.
* omp-low.c: Likewise.
* opts-common.c: Likewise.
* opts-global.c: Likewise.
* opts.c: Likewise.
* opts.h: Likewise.
* passes.c: Likewise.
* predict.c: Likewise.
* print-tree.c: Likewise.
* profile.c: Likewise.
* profile.h: Likewise.
* read-rtl.c: Likewise.
* ree.c: Likewise.
* reg-stack.c: Likewise.
* regrename.c: Likewise.
* regrename.h: Likewise.
* reload.c: Likewise.
* reload.h: Likewise.
* reload1.c: Likewise.
* rtl.h: Likewise.
* sched-deps.c: Likewise.
* sched-int.h: Likewise.
* sdbout.c: Likewise.
* sel-sched-dump.c: Likewise.
* sel-sched-ir.c: Likewise.
* sel-sched-ir.h: Likewise.
* sel-sched.c: Likewise.
* sese.c: Likewise.
* sese.h: Likewise.
* statistics.h: Likewise.
* stmt.c: Likewise.
* stor-layout.c: Likewise.
* store-motion.c: Likewise.
* tlink.c: Likewise.
* toplev.c: Likewise.
* trans-mem.c: Likewise.
* tree-browser.c: Likewise.
* tree-call-cdce.c: Likewise.
* tree-cfg.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-chrec.c: Likewise.
* tree-chrec.h: Likewise.
* tree-complex.c: Likewise.
* tree-data-ref.c: Likewise.
* tree-data-ref.h: Likewise.
* tree-dfa.c: Likewise.
* tree-diagnostic.c: Likewise.
* tree-dump.c: Likewise.
* tree-eh.c: Likewise.
* tree-emutls.c: Likewise.
* tree-flow.h: Likewise.
* tree-if-conv.c: Likewise.
* tree-inline.c: Likewise.
* tree-inline.h: Likewise.
* tree-into-ssa.c: Likewise.
* tree-iterator.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-mudflap.c: Likewise.
* tree-optimize.c: Likewise.
* tree-outof-ssa.c: Likewise.
* tree-parloops.c: Likewise.
* tree-phinodes.c: Likewise.
* tree-predcom.c: Likewise.
* tree-pretty-print.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-address.c: Likewise.
* tree-ssa-alias.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-coalesce.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-ssa-dom.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-live.c: Likewise.
* tree-ssa-live.h: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-operands.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-sccvn.h: Likewise.
* tree-ssa-strlen.c: Likewise.
* tree-ssa-structalias.c: Likewise.
* tree-ssa-tail-merge.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* tree-ssa-threadupdate.c: Likewise.
* tree-ssa-uncprop.c: Likewise.
* tree-ssa-uninit.c: Likewise.
* tree-ssa.c: Likewise.
* tree-ssanames.c: Likewise.
* tree-stdarg.c: Likewise.
* tree-streamer-in.c: Likewise.
* tree-streamer-out.c: Likewise.
* tree-streamer.c: Likewise.
* tree-streamer.h: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-generic.c: Likewise.
* tree-vect-loop-manip.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-slp.c: Likewise.
* tree-vect-stmts.c: Likewise.
* tree-vectorizer.c: Likewise.
* tree-vectorizer.h: Likewise.
* tree-vrp.c: Likewise.
* tree.c: Likewise.
* tree.h: Likewise.
* value-prof.c: Likewise.
* value-prof.h: Likewise.
* var-tracking.c: Likewise.
* varasm.c: Likewise.
* varpool.c: Likewise.
* vmsdbgout.c: Likewise.
* config/bfin/bfin.c: Likewise.
* config/c6x/c6x.c: Likewise.
* config/darwin.c: Likewise.
* config/i386/i386.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/mep/mep.c: Likewise.
* config/mips/mips.c: Likewise.
* config/pa/pa.c: Likewise.
* config/rs6000/rs6000-c.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/rx/rx.c: Likewise.
* config/spu/spu-c.c: Likewise.
* config/vms/vms.c: Likewise.
* config/vxworks.c: Likewise.
* config/epiphany/resolve-sw-modes.c: Likewise.
From-SVN: r193595
2012-11-18 03:54:30 +01:00
|
|
|
stmts->safe_push (use_stmt);
|
2007-01-22 12:11:00 +01:00
|
|
|
else if (!*top_bb
|
|
|
|
|| dominated_by_p (CDI_DOMINATORS, *top_bb, use_bb))
|
|
|
|
{
|
This patch rewrites the old VEC macro-based interface into a new one based on the template class 'vec'.
This patch rewrites the old VEC macro-based interface into a new one
based on the template class 'vec'. The user-visible changes are
described in http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec.
I have tested the patch pretty extensively:
- Regular bootstraps on x86_64, ppc, ia64, sparc and hppa.
- Bootstraps with --enable-checking=release
- Bootstraps with --enable-checking=gc,gcac
- Basic builds on all targets (using contrib/config-list.mk).
We no longer access the vectors via VEC_* macros. The pattern is
"VEC_operation (T, A, V, args)" becomes "V.operation (args)".
The only thing I could not do is create proper ctors and dtors for the
vec class. Since these vectors are stored in unions, we
have to keep them as PODs (C++03 does not allow non-PODs in unions).
This means that creation and destruction must be explicit. There is a
new method vec<type, allocation, layout>::create() and another vec<type,
allocation, layout>::destroy() to allocate the internal vector.
For vectors that must be pointers, there is a family of free functions
that implement the operations that need to tolerate NULL vectors.
These functions all start with the prefix 'vec_safe_'. See the wiki
page for details.
The gengtype change removes the special handling for VEC() that used
to exist in gengtype. Additionally, it allows gengtype to recognize
templates of more than one argument and introduces the concept of an
undefined type (useful for template arguments that may or may not be
types).
When a TYPE_UNDEFINED is reached, gengtype will ignore it if it
happens inside a type marked with GTY((user)). Otherwise, it will
emit an error.
Finally, gengtype rejects root types marked GTY((user)) that are not
first class pointers.
2012-11-16 Diego Novillo <dnovillo@google.com>
VEC API overhaul (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* vec.c (register_overhead): Convert it into
member function of vec_prefix.
(release_overhead): Likewise.
(calculate_allocation): Likewise.
(vec_heap_free): Remove.
(vec_gc_o_reserve_1): Remove.
(vec_heap_o_reserve_1): Remove.
(vec_stack_o_reserve_1): Remove.
(vec_stack_o_reserve_exact): Remove.
(register_stack_vec): New.
(stack_vec_register_index): New.
(unregister_stack_vec): New.
(vec_assert_fail): Remove.
* vec.h: Conditionally include ggc.h. Document conditional
hackery.
Update top-level documentation.
(ALONE_VEC_CHECK_INFO): Remove.
(VEC_CHECK_INFO): Remove.
(ALONE_VEC_CHECK_DECL): Remove.
(VEC_CHECK_DECL): Remove.
(ALONE_VEC_CHECK_PASS): Remove.
(VEC_CHECK_PASS): Remove.
(VEC_ASSERT): Remove.
(vec_prefix): Add friends va_gc, va_gc_atomic, va_heap and
va_stack.
Mark fields alloc_ and num_ as protected.
(struct vec_t): Remove. Remove all function members.
(struct vl_embed): Declare.
(struct vl_ptr): Declare.
(free): Remove.
(reserve_exact): Remove.
(reserve): Remove.
(safe_splice): Remove.
(safe_push): Remove.
(safe_grow): Remove.
(safe_grow_cleared): Remove.
(safe_insert): Remove.
(DEF_VEC_I): Remove.
(DEF_VEC_ALLOC_I): Remove.
(DEF_VEC_P): Remove.
(DEF_VEC_ALLOC_P): Remove.
(DEF_VEC_O): Remove.
(DEF_VEC_ALLOC_O): Remove.
(DEF_VEC_ALLOC_P_STACK): Remove.
(DEF_VEC_ALLOC_O_STACK): Remove.
(DEF_VEC_ALLOC_I_STACK): Remove.
(DEF_VEC_A): Remove.
(DEF_VEC_ALLOC_A): Remove.
(vec_stack_p_reserve_exact_1): Remove.
(vec_stack_o_reserve): Remove.
(vec_stack_o_reserve_exact): Remove.
(VEC_length): Remove.
(VEC_empty): Remove.
(VEC_address): Remove.
(vec_address): Remove.
(VEC_last): Remove.
(VEC_index): Remove.
(VEC_iterate): Remove.
(VEC_embedded_size): Remove.
(VEC_embedded_init): Remove.
(VEC_free): Remove.
(VEC_copy): Remove.
(VEC_space): Remove.
(VEC_reserve): Remove.
(VEC_reserve_exact): Remove.
(VEC_splice): Remove.
(VEC_safe_splice): Remove.
(VEC_quick_push): Remove.
(VEC_safe_push): Remove.
(VEC_pop): Remove.
(VEC_truncate): Remove.
(VEC_safe_grow): Remove.
(VEC_replace): Remove.
(VEC_quick_insert): Remove.
(VEC_safe_insert): Remove.
(VEC_ordered_remove): Remove.
(VEC_unordered_remove): Remove.
(VEC_block_remove): Remove.
(VEC_lower_bound): Remove.
(VEC_alloc): Remove.
(VEC_qsort): Remove.
(va_heap): Declare.
(va_heap::default_layout): New typedef to vl_ptr.
(va_heap::reserve): New.
(va_heap::release): New.
(va_gc): Declare.
(va_gc::default_layout): New typedef to vl_embed.
(va_gc::reserve): New.
(va_gc::release): New.
(va_gc_atomic): Declare. Inherit from va_gc.
(va_stack): Declare.
(va_stack::default_layout): New typedef to vl_ptr.
(va_stack::alloc): New.
(va_stack::reserve): New.
(va_stack::release): New.
(register_stack_vec): Declare.
(stack_vec_register_index): Declare.
(unregister_stack_vec): Declare.
(vec<T, A = va_heap, L = typename A::default_layout>): Declare
empty vec template.
(vec<T, A, vl_embed>): Partial specialization for embedded
layout.
(vec<T, A, vl_embed>::allocated): New.
(vec<T, A, vl_embed>::length): New.
(vec<T, A, vl_embed>::is_empty): New.
(vec<T, A, vl_embed>::address): New.
(vec<T, A, vl_embed>::operator[]): New.
(vec<T, A, vl_embed>::last New.
(vec<T, A, vl_embed>::space): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::copy): New.
(vec<T, A, vl_embed>::splice): New.
(vec<T, A, vl_embed>::quick_push New.
(vec<T, A, vl_embed>::pop New.
(vec<T, A, vl_embed>::truncate): New.
(vec<T, A, vl_embed>::quick_insert): New.
(vec<T, A, vl_embed>::ordered_remove): New.
(vec<T, A, vl_embed>::unordered_remove): New.
(vec<T, A, vl_embed>::block_remove): New.
(vec<T, A, vl_embed>::qsort): New.
(vec<T, A, vl_embed>::lower_bound): New.
(vec<T, A, vl_embed>::embedded_size): New.
(vec<T, A, vl_embed>::embedded_init): New.
(vec<T, A, vl_embed>::quick_grow): New.
(vec<T, A, vl_embed>::quick_grow_cleared): New.
(vec_safe_space): New.
(vec_safe_length): New.
(vec_safe_address): New.
(vec_safe_is_empty): New.
(vec_safe_reserve): New.
(vec_safe_reserve_exact): New.
(vec_alloc): New.
(vec_free): New.
(vec_safe_grow): New.
(vec_safe_grow_cleared): New.
(vec_safe_iterate): New.
(vec_safe_push): New.
(vec_safe_insert): New.
(vec_safe_truncate): New.
(vec_safe_copy): New.
(vec_safe_splice): New.
(vec<T, A, vl_ptr>): New partial specialization for the space
efficient layout.
(vec<T, A, vl_ptr>::exists): New.
(vec<T, A, vl_ptr>::is_empty): New.
(vec<T, A, vl_ptr>::length): New.
(vec<T, A, vl_ptr>::address): New.
(vec<T, A, vl_ptr>::operator[]): New.
(vec<T, A, vl_ptr>::operator!=): New.
(vec<T, A, vl_ptr>::operator==): New.
(vec<T, A, vl_ptr>::last): New.
(vec<T, A, vl_ptr>::space): New.
(vec<T, A, vl_ptr>::iterate): New.
(vec<T, A, vl_ptr>::copy): New.
(vec<T, A, vl_ptr>::reserve): New.
(vec<T, A, vl_ptr>::reserve_exact): New.
(vec<T, A, vl_ptr>::splice): New.
(vec<T, A, vl_ptr>::safe_splice): New.
(vec<T, A, vl_ptr>::quick_push): New.
(vec<T, A, vl_ptr>::safe_push): New.
(vec<T, A, vl_ptr>::pop): New.
(vec<T, A, vl_ptr>::truncate): New.
(vec<T, A, vl_ptr>::safe_grow): New.
(vec<T, A, vl_ptr>::safe_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_grow): New.
(vec<T, A, vl_ptr>::quick_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_insert): New.
(vec<T, A, vl_ptr>::safe_insert): New.
(vec<T, A, vl_ptr>::ordered_remove): New.
(vec<T, A, vl_ptr>::unordered_remove): New.
(vec<T, A, vl_ptr>::block_remove): New.
(vec<T, A, vl_ptr>::qsort): New.
(vec<T, A, vl_ptr>::lower_bound): New.
(vec_stack_alloc): Define.
(FOR_EACH_VEC_SAFE_ELT): Define.
* vecir.h: Remove. Update all users.
* vecprim.h: Remove. Update all users.
Move uchar to coretypes.h.
* Makefile.in (VEC_H): Add $(GGC_H).
Remove vecir.h and vecprim.h dependencies everywhere.
2012-11-16 Diego Novillo <dnovillo@google.com>
* gengtype-lex.l (VEC): Remove.
Add characters in the set [\!\>\.-].
* gengtype-parse.c (token_names): Remove "VEC".
(require_template_declaration): Remove handling of VEC_TOKEN.
(type): Likewise.
Call create_user_defined_type when parsing GTY((user)).
* gengtype-state.c (type_lineloc): handle TYPE_UNDEFINED.
(write_state_undefined_type): New.
(write_state_type): Call write_state_undefined_type for
TYPE_UNDEFINED.
(read_state_type): Call read_state_undefined_type for
TYPE_UNDEFINED.
* gengtype.c (dbgprint_count_type_at): Handle TYPE_UNDEFINED.
(create_user_defined_type): Make extern.
(type_for_name): Factor out of resolve_typedef.
(create_undefined_type): New
(resolve_typedef): Call it when we cannot find a previous
typedef and the type is not a template.
(find_structure): Accept TYPE_UNDEFINED.
(set_gc_used_type): Add argument ALLOWED_UNDEFINED_TYPES,
default to false.
Emit an error for TYPE_UNDEFINED unless LEVEL is GC_UNUSED or
ALLOWED_UNDEFINED_TYPES is set.
Set ALLOWED_UNDEFINED_TYPES to true for TYPE_USER_STRUCT.
(filter_type_name): Accept templates with more than one
argument.
(output_mangled_typename): Handle TYPE_UNDEFINED
(walk_type): Likewise.
(write_types_process_field): Likewise.
(write_func_for_structure): If CHAIN_NEXT is set, ORIG_S
should not be a user-defined type.
(write_types_local_user_process_field): Handle TYPE_ARRAY,
TYPE_NONE and TYPE_UNDEFINED.
(write_types_local_process_field): Likewise.
(contains_scalar_p): Return 0 for TYPE_USER_STRUCT.
(write_root): Reject user-defined types that are not pointers.
Handle TYPE_NONE, TYPE_UNDEFINED, TYPE_UNION, TYPE_LANG_STRUCT
and TYPE_PARAM_STRUCT.
(output_typename): Handle TYPE_NONE, TYPE_UNDEFINED, and
TYPE_ARRAY.
(dump_typekind): Handle TYPE_UNDEFINED.
* gengtype.h (enum typekind): Add TYPE_UNDEFINED.
(create_user_defined_type): Declare.
(enum gty_token): Remove VEC_TOKEN.
2012-11-16 Diego Novillo <dnovillo@google.com>
Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* coretypes.h (uchar): Define.
* alias.c: Use new vec API in vec.h.
* asan.c: Likewise.
* attribs.c: Likewise.
* basic-block.h: Likewise.
* bb-reorder.c: Likewise.
* builtins.c: Likewise.
* calls.c: Likewise.
* cfg.c: Likewise.
* cfganal.c: Likewise.
* cfgcleanup.c: Likewise.
* cfgexpand.c: Likewise.
* cfghooks.c: Likewise.
* cfghooks.h: Likewise.
* cfgloop.c: Likewise.
* cfgloop.h: Likewise.
* cfgloopanal.c: Likewise.
* cfgloopmanip.c: Likewise.
* cfgrtl.c: Likewise.
* cgraph.c: Likewise.
* cgraph.h: Likewise.
* cgraphclones.c: Likewise.
* cgraphunit.c: Likewise.
* combine.c: Likewise.
* compare-elim.c: Likewise.
* coverage.c: Likewise.
* cprop.c: Likewise.
* data-streamer.h: Likewise.
* dbxout.c: Likewise.
* dce.c: Likewise.
* df-core.c: Likewise.
* df-problems.c: Likewise.
* df-scan.c: Likewise.
* dominance.c: Likewise.
* domwalk.c: Likewise.
* domwalk.h: Likewise.
* dse.c: Likewise.
* dwarf2cfi.c: Likewise.
* dwarf2out.c: Likewise.
* dwarf2out.h: Likewise.
* emit-rtl.c: Likewise.
* except.c: Likewise.
* except.h: Likewise.
* expr.c: Likewise.
* expr.h: Likewise.
* final.c: Likewise.
* fold-const.c: Likewise.
* function.c: Likewise.
* function.h: Likewise.
* fwprop.c: Likewise.
* gcc.c: Likewise.
* gcse.c: Likewise.
* genattr.c: Likewise.
* genattrtab.c: Likewise.
* genautomata.c: Likewise.
* genextract.c: Likewise.
* genopinit.c: Likewise
* ggc-common.c: Likewise.
* ggc.h: Likewise.
* gimple-low.c: Likewise.
* gimple-ssa-strength-reduction.c: Likewise.
* gimple-streamer-in.c: Likewise.
* gimple.c: Likewise.
* gimple.h: Likewise.
* gimplify.c: Likewise.
* graph.c: Likewise.
* graphds.c: Likewise.
* graphds.h: Likewise.
* graphite-blocking.c: Likewise.
* graphite-clast-to-gimple.c: Likewise.
* graphite-dependences.c: Likewise.
* graphite-interchange.c: Likewise.
* graphite-optimize-isl.c: Likewise.
* graphite-poly.c: Likewise.
* graphite-poly.h: Likewise.
* graphite-scop-detection.c: Likewise.
* graphite-scop-detection.h: Likewise.
* graphite-sese-to-poly.c: Likewise.
* graphite.c: Likewise.
* godump.c: Likewise.
* haifa-sched.c: Likewise.
* hw-doloop.c: Likewise.
* hw-doloop.h: Likewise.
* ifcvt.c: Likewise.
* insn-addr.h: Likewise.
* ipa-cp.c: Likewise.
* ipa-inline-analysis.c: Likewise.
* ipa-inline-transform.c: Likewise.
* ipa-inline.c: Likewise.
* ipa-inline.h: Likewise.
* ipa-prop.c: Likewise.
* ipa-prop.h: Likewise.
* ipa-pure-const.c: Likewise.
* ipa-ref-inline.h: Likewise.
* ipa-ref.c: Likewise.
* ipa-ref.h: Likewise.
* ipa-reference.c: Likewise.
* ipa-split.c: Likewise.
* ipa-utils.c: Likewise.
* ipa-utils.h: Likewise.
* ipa.c: Likewise.
* ira-build.c: Likewise.
* ira-color.c: Likewise.
* ira-emit.c: Likewise.
* ira-int.h: Likewise.
* ira.c: Likewise.
* loop-invariant.c: Likewise.
* loop-unroll.c: Likewise.
* lower-subreg.c: Likewise.
* lra-lives.c: Likewise.
* lra.c: Likewise.
* lto-cgraph.c: Likewise.
* lto-section-out.c: Likewise.
* lto-streamer-in.c: Likewise.
* lto-streamer-out.c: Likewise.
* lto-streamer.h: Likewise.
* lto-symtab.c: Likewise.
* mcf.c: Likewise.
* modulo-sched.c: Likewise.
* omp-low.c: Likewise.
* opts-common.c: Likewise.
* opts-global.c: Likewise.
* opts.c: Likewise.
* opts.h: Likewise.
* passes.c: Likewise.
* predict.c: Likewise.
* print-tree.c: Likewise.
* profile.c: Likewise.
* profile.h: Likewise.
* read-rtl.c: Likewise.
* ree.c: Likewise.
* reg-stack.c: Likewise.
* regrename.c: Likewise.
* regrename.h: Likewise.
* reload.c: Likewise.
* reload.h: Likewise.
* reload1.c: Likewise.
* rtl.h: Likewise.
* sched-deps.c: Likewise.
* sched-int.h: Likewise.
* sdbout.c: Likewise.
* sel-sched-dump.c: Likewise.
* sel-sched-ir.c: Likewise.
* sel-sched-ir.h: Likewise.
* sel-sched.c: Likewise.
* sese.c: Likewise.
* sese.h: Likewise.
* statistics.h: Likewise.
* stmt.c: Likewise.
* stor-layout.c: Likewise.
* store-motion.c: Likewise.
* tlink.c: Likewise.
* toplev.c: Likewise.
* trans-mem.c: Likewise.
* tree-browser.c: Likewise.
* tree-call-cdce.c: Likewise.
* tree-cfg.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-chrec.c: Likewise.
* tree-chrec.h: Likewise.
* tree-complex.c: Likewise.
* tree-data-ref.c: Likewise.
* tree-data-ref.h: Likewise.
* tree-dfa.c: Likewise.
* tree-diagnostic.c: Likewise.
* tree-dump.c: Likewise.
* tree-eh.c: Likewise.
* tree-emutls.c: Likewise.
* tree-flow.h: Likewise.
* tree-if-conv.c: Likewise.
* tree-inline.c: Likewise.
* tree-inline.h: Likewise.
* tree-into-ssa.c: Likewise.
* tree-iterator.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-mudflap.c: Likewise.
* tree-optimize.c: Likewise.
* tree-outof-ssa.c: Likewise.
* tree-parloops.c: Likewise.
* tree-phinodes.c: Likewise.
* tree-predcom.c: Likewise.
* tree-pretty-print.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-address.c: Likewise.
* tree-ssa-alias.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-coalesce.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-ssa-dom.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-live.c: Likewise.
* tree-ssa-live.h: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-operands.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-sccvn.h: Likewise.
* tree-ssa-strlen.c: Likewise.
* tree-ssa-structalias.c: Likewise.
* tree-ssa-tail-merge.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* tree-ssa-threadupdate.c: Likewise.
* tree-ssa-uncprop.c: Likewise.
* tree-ssa-uninit.c: Likewise.
* tree-ssa.c: Likewise.
* tree-ssanames.c: Likewise.
* tree-stdarg.c: Likewise.
* tree-streamer-in.c: Likewise.
* tree-streamer-out.c: Likewise.
* tree-streamer.c: Likewise.
* tree-streamer.h: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-generic.c: Likewise.
* tree-vect-loop-manip.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-slp.c: Likewise.
* tree-vect-stmts.c: Likewise.
* tree-vectorizer.c: Likewise.
* tree-vectorizer.h: Likewise.
* tree-vrp.c: Likewise.
* tree.c: Likewise.
* tree.h: Likewise.
* value-prof.c: Likewise.
* value-prof.h: Likewise.
* var-tracking.c: Likewise.
* varasm.c: Likewise.
* varpool.c: Likewise.
* vmsdbgout.c: Likewise.
* config/bfin/bfin.c: Likewise.
* config/c6x/c6x.c: Likewise.
* config/darwin.c: Likewise.
* config/i386/i386.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/mep/mep.c: Likewise.
* config/mips/mips.c: Likewise.
* config/pa/pa.c: Likewise.
* config/rs6000/rs6000-c.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/rx/rx.c: Likewise.
* config/spu/spu-c.c: Likewise.
* config/vms/vms.c: Likewise.
* config/vxworks.c: Likewise.
* config/epiphany/resolve-sw-modes.c: Likewise.
From-SVN: r193595
2012-11-18 03:54:30 +01:00
|
|
|
stmts->safe_push (use_stmt);
|
2007-01-22 12:11:00 +01:00
|
|
|
*top_bb = use_bb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for sin, cos and cexpi calls with the same argument NAME and
|
|
|
|
create a single call to cexpi CSEing the result in this case.
|
|
|
|
We first walk over all immediate uses of the argument collecting
|
|
|
|
statements that we can CSE in a vector and in a second pass replace
|
|
|
|
the statement rhs with a REALPART or IMAGPART expression on the
|
|
|
|
result of the cexpi call we insert before the use statement that
|
|
|
|
dominates all other candidates. */
|
|
|
|
|
2010-08-25 12:47:50 +02:00
|
|
|
static bool
|
2007-01-22 12:11:00 +01:00
|
|
|
execute_cse_sincos_1 (tree name)
|
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple_stmt_iterator gsi;
|
2007-01-22 12:11:00 +01:00
|
|
|
imm_use_iterator use_iter;
|
2008-07-28 16:33:56 +02:00
|
|
|
tree fndecl, res, type;
|
|
|
|
gimple def_stmt, use_stmt, stmt;
|
2007-01-22 12:11:00 +01:00
|
|
|
int seen_cos = 0, seen_sin = 0, seen_cexpi = 0;
|
2012-11-20 22:21:30 +01:00
|
|
|
vec<gimple> stmts = vNULL;
|
2007-01-22 12:11:00 +01:00
|
|
|
basic_block top_bb = NULL;
|
|
|
|
int i;
|
2010-08-25 12:47:50 +02:00
|
|
|
bool cfg_changed = false;
|
2007-01-22 12:11:00 +01:00
|
|
|
|
|
|
|
type = TREE_TYPE (name);
|
|
|
|
FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, name)
|
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
if (gimple_code (use_stmt) != GIMPLE_CALL
|
|
|
|
|| !gimple_call_lhs (use_stmt)
|
|
|
|
|| !(fndecl = gimple_call_fndecl (use_stmt))
|
2007-01-22 12:11:00 +01:00
|
|
|
|| DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (DECL_FUNCTION_CODE (fndecl))
|
|
|
|
{
|
|
|
|
CASE_FLT_FN (BUILT_IN_COS):
|
|
|
|
seen_cos |= maybe_record_sincos (&stmts, &top_bb, use_stmt) ? 1 : 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_FLT_FN (BUILT_IN_SIN):
|
|
|
|
seen_sin |= maybe_record_sincos (&stmts, &top_bb, use_stmt) ? 1 : 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_FLT_FN (BUILT_IN_CEXPI):
|
|
|
|
seen_cexpi |= maybe_record_sincos (&stmts, &top_bb, use_stmt) ? 1 : 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seen_cos + seen_sin + seen_cexpi <= 1)
|
|
|
|
{
|
This patch rewrites the old VEC macro-based interface into a new one based on the template class 'vec'.
This patch rewrites the old VEC macro-based interface into a new one
based on the template class 'vec'. The user-visible changes are
described in http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec.
I have tested the patch pretty extensively:
- Regular bootstraps on x86_64, ppc, ia64, sparc and hppa.
- Bootstraps with --enable-checking=release
- Bootstraps with --enable-checking=gc,gcac
- Basic builds on all targets (using contrib/config-list.mk).
We no longer access the vectors via VEC_* macros. The pattern is
"VEC_operation (T, A, V, args)" becomes "V.operation (args)".
The only thing I could not do is create proper ctors and dtors for the
vec class. Since these vectors are stored in unions, we
have to keep them as PODs (C++03 does not allow non-PODs in unions).
This means that creation and destruction must be explicit. There is a
new method vec<type, allocation, layout>::create() and another vec<type,
allocation, layout>::destroy() to allocate the internal vector.
For vectors that must be pointers, there is a family of free functions
that implement the operations that need to tolerate NULL vectors.
These functions all start with the prefix 'vec_safe_'. See the wiki
page for details.
The gengtype change removes the special handling for VEC() that used
to exist in gengtype. Additionally, it allows gengtype to recognize
templates of more than one argument and introduces the concept of an
undefined type (useful for template arguments that may or may not be
types).
When a TYPE_UNDEFINED is reached, gengtype will ignore it if it
happens inside a type marked with GTY((user)). Otherwise, it will
emit an error.
Finally, gengtype rejects root types marked GTY((user)) that are not
first class pointers.
2012-11-16 Diego Novillo <dnovillo@google.com>
VEC API overhaul (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* vec.c (register_overhead): Convert it into
member function of vec_prefix.
(release_overhead): Likewise.
(calculate_allocation): Likewise.
(vec_heap_free): Remove.
(vec_gc_o_reserve_1): Remove.
(vec_heap_o_reserve_1): Remove.
(vec_stack_o_reserve_1): Remove.
(vec_stack_o_reserve_exact): Remove.
(register_stack_vec): New.
(stack_vec_register_index): New.
(unregister_stack_vec): New.
(vec_assert_fail): Remove.
* vec.h: Conditionally include ggc.h. Document conditional
hackery.
Update top-level documentation.
(ALONE_VEC_CHECK_INFO): Remove.
(VEC_CHECK_INFO): Remove.
(ALONE_VEC_CHECK_DECL): Remove.
(VEC_CHECK_DECL): Remove.
(ALONE_VEC_CHECK_PASS): Remove.
(VEC_CHECK_PASS): Remove.
(VEC_ASSERT): Remove.
(vec_prefix): Add friends va_gc, va_gc_atomic, va_heap and
va_stack.
Mark fields alloc_ and num_ as protected.
(struct vec_t): Remove. Remove all function members.
(struct vl_embed): Declare.
(struct vl_ptr): Declare.
(free): Remove.
(reserve_exact): Remove.
(reserve): Remove.
(safe_splice): Remove.
(safe_push): Remove.
(safe_grow): Remove.
(safe_grow_cleared): Remove.
(safe_insert): Remove.
(DEF_VEC_I): Remove.
(DEF_VEC_ALLOC_I): Remove.
(DEF_VEC_P): Remove.
(DEF_VEC_ALLOC_P): Remove.
(DEF_VEC_O): Remove.
(DEF_VEC_ALLOC_O): Remove.
(DEF_VEC_ALLOC_P_STACK): Remove.
(DEF_VEC_ALLOC_O_STACK): Remove.
(DEF_VEC_ALLOC_I_STACK): Remove.
(DEF_VEC_A): Remove.
(DEF_VEC_ALLOC_A): Remove.
(vec_stack_p_reserve_exact_1): Remove.
(vec_stack_o_reserve): Remove.
(vec_stack_o_reserve_exact): Remove.
(VEC_length): Remove.
(VEC_empty): Remove.
(VEC_address): Remove.
(vec_address): Remove.
(VEC_last): Remove.
(VEC_index): Remove.
(VEC_iterate): Remove.
(VEC_embedded_size): Remove.
(VEC_embedded_init): Remove.
(VEC_free): Remove.
(VEC_copy): Remove.
(VEC_space): Remove.
(VEC_reserve): Remove.
(VEC_reserve_exact): Remove.
(VEC_splice): Remove.
(VEC_safe_splice): Remove.
(VEC_quick_push): Remove.
(VEC_safe_push): Remove.
(VEC_pop): Remove.
(VEC_truncate): Remove.
(VEC_safe_grow): Remove.
(VEC_replace): Remove.
(VEC_quick_insert): Remove.
(VEC_safe_insert): Remove.
(VEC_ordered_remove): Remove.
(VEC_unordered_remove): Remove.
(VEC_block_remove): Remove.
(VEC_lower_bound): Remove.
(VEC_alloc): Remove.
(VEC_qsort): Remove.
(va_heap): Declare.
(va_heap::default_layout): New typedef to vl_ptr.
(va_heap::reserve): New.
(va_heap::release): New.
(va_gc): Declare.
(va_gc::default_layout): New typedef to vl_embed.
(va_gc::reserve): New.
(va_gc::release): New.
(va_gc_atomic): Declare. Inherit from va_gc.
(va_stack): Declare.
(va_stack::default_layout): New typedef to vl_ptr.
(va_stack::alloc): New.
(va_stack::reserve): New.
(va_stack::release): New.
(register_stack_vec): Declare.
(stack_vec_register_index): Declare.
(unregister_stack_vec): Declare.
(vec<T, A = va_heap, L = typename A::default_layout>): Declare
empty vec template.
(vec<T, A, vl_embed>): Partial specialization for embedded
layout.
(vec<T, A, vl_embed>::allocated): New.
(vec<T, A, vl_embed>::length): New.
(vec<T, A, vl_embed>::is_empty): New.
(vec<T, A, vl_embed>::address): New.
(vec<T, A, vl_embed>::operator[]): New.
(vec<T, A, vl_embed>::last New.
(vec<T, A, vl_embed>::space): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::copy): New.
(vec<T, A, vl_embed>::splice): New.
(vec<T, A, vl_embed>::quick_push New.
(vec<T, A, vl_embed>::pop New.
(vec<T, A, vl_embed>::truncate): New.
(vec<T, A, vl_embed>::quick_insert): New.
(vec<T, A, vl_embed>::ordered_remove): New.
(vec<T, A, vl_embed>::unordered_remove): New.
(vec<T, A, vl_embed>::block_remove): New.
(vec<T, A, vl_embed>::qsort): New.
(vec<T, A, vl_embed>::lower_bound): New.
(vec<T, A, vl_embed>::embedded_size): New.
(vec<T, A, vl_embed>::embedded_init): New.
(vec<T, A, vl_embed>::quick_grow): New.
(vec<T, A, vl_embed>::quick_grow_cleared): New.
(vec_safe_space): New.
(vec_safe_length): New.
(vec_safe_address): New.
(vec_safe_is_empty): New.
(vec_safe_reserve): New.
(vec_safe_reserve_exact): New.
(vec_alloc): New.
(vec_free): New.
(vec_safe_grow): New.
(vec_safe_grow_cleared): New.
(vec_safe_iterate): New.
(vec_safe_push): New.
(vec_safe_insert): New.
(vec_safe_truncate): New.
(vec_safe_copy): New.
(vec_safe_splice): New.
(vec<T, A, vl_ptr>): New partial specialization for the space
efficient layout.
(vec<T, A, vl_ptr>::exists): New.
(vec<T, A, vl_ptr>::is_empty): New.
(vec<T, A, vl_ptr>::length): New.
(vec<T, A, vl_ptr>::address): New.
(vec<T, A, vl_ptr>::operator[]): New.
(vec<T, A, vl_ptr>::operator!=): New.
(vec<T, A, vl_ptr>::operator==): New.
(vec<T, A, vl_ptr>::last): New.
(vec<T, A, vl_ptr>::space): New.
(vec<T, A, vl_ptr>::iterate): New.
(vec<T, A, vl_ptr>::copy): New.
(vec<T, A, vl_ptr>::reserve): New.
(vec<T, A, vl_ptr>::reserve_exact): New.
(vec<T, A, vl_ptr>::splice): New.
(vec<T, A, vl_ptr>::safe_splice): New.
(vec<T, A, vl_ptr>::quick_push): New.
(vec<T, A, vl_ptr>::safe_push): New.
(vec<T, A, vl_ptr>::pop): New.
(vec<T, A, vl_ptr>::truncate): New.
(vec<T, A, vl_ptr>::safe_grow): New.
(vec<T, A, vl_ptr>::safe_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_grow): New.
(vec<T, A, vl_ptr>::quick_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_insert): New.
(vec<T, A, vl_ptr>::safe_insert): New.
(vec<T, A, vl_ptr>::ordered_remove): New.
(vec<T, A, vl_ptr>::unordered_remove): New.
(vec<T, A, vl_ptr>::block_remove): New.
(vec<T, A, vl_ptr>::qsort): New.
(vec<T, A, vl_ptr>::lower_bound): New.
(vec_stack_alloc): Define.
(FOR_EACH_VEC_SAFE_ELT): Define.
* vecir.h: Remove. Update all users.
* vecprim.h: Remove. Update all users.
Move uchar to coretypes.h.
* Makefile.in (VEC_H): Add $(GGC_H).
Remove vecir.h and vecprim.h dependencies everywhere.
2012-11-16 Diego Novillo <dnovillo@google.com>
* gengtype-lex.l (VEC): Remove.
Add characters in the set [\!\>\.-].
* gengtype-parse.c (token_names): Remove "VEC".
(require_template_declaration): Remove handling of VEC_TOKEN.
(type): Likewise.
Call create_user_defined_type when parsing GTY((user)).
* gengtype-state.c (type_lineloc): handle TYPE_UNDEFINED.
(write_state_undefined_type): New.
(write_state_type): Call write_state_undefined_type for
TYPE_UNDEFINED.
(read_state_type): Call read_state_undefined_type for
TYPE_UNDEFINED.
* gengtype.c (dbgprint_count_type_at): Handle TYPE_UNDEFINED.
(create_user_defined_type): Make extern.
(type_for_name): Factor out of resolve_typedef.
(create_undefined_type): New
(resolve_typedef): Call it when we cannot find a previous
typedef and the type is not a template.
(find_structure): Accept TYPE_UNDEFINED.
(set_gc_used_type): Add argument ALLOWED_UNDEFINED_TYPES,
default to false.
Emit an error for TYPE_UNDEFINED unless LEVEL is GC_UNUSED or
ALLOWED_UNDEFINED_TYPES is set.
Set ALLOWED_UNDEFINED_TYPES to true for TYPE_USER_STRUCT.
(filter_type_name): Accept templates with more than one
argument.
(output_mangled_typename): Handle TYPE_UNDEFINED
(walk_type): Likewise.
(write_types_process_field): Likewise.
(write_func_for_structure): If CHAIN_NEXT is set, ORIG_S
should not be a user-defined type.
(write_types_local_user_process_field): Handle TYPE_ARRAY,
TYPE_NONE and TYPE_UNDEFINED.
(write_types_local_process_field): Likewise.
(contains_scalar_p): Return 0 for TYPE_USER_STRUCT.
(write_root): Reject user-defined types that are not pointers.
Handle TYPE_NONE, TYPE_UNDEFINED, TYPE_UNION, TYPE_LANG_STRUCT
and TYPE_PARAM_STRUCT.
(output_typename): Handle TYPE_NONE, TYPE_UNDEFINED, and
TYPE_ARRAY.
(dump_typekind): Handle TYPE_UNDEFINED.
* gengtype.h (enum typekind): Add TYPE_UNDEFINED.
(create_user_defined_type): Declare.
(enum gty_token): Remove VEC_TOKEN.
2012-11-16 Diego Novillo <dnovillo@google.com>
Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* coretypes.h (uchar): Define.
* alias.c: Use new vec API in vec.h.
* asan.c: Likewise.
* attribs.c: Likewise.
* basic-block.h: Likewise.
* bb-reorder.c: Likewise.
* builtins.c: Likewise.
* calls.c: Likewise.
* cfg.c: Likewise.
* cfganal.c: Likewise.
* cfgcleanup.c: Likewise.
* cfgexpand.c: Likewise.
* cfghooks.c: Likewise.
* cfghooks.h: Likewise.
* cfgloop.c: Likewise.
* cfgloop.h: Likewise.
* cfgloopanal.c: Likewise.
* cfgloopmanip.c: Likewise.
* cfgrtl.c: Likewise.
* cgraph.c: Likewise.
* cgraph.h: Likewise.
* cgraphclones.c: Likewise.
* cgraphunit.c: Likewise.
* combine.c: Likewise.
* compare-elim.c: Likewise.
* coverage.c: Likewise.
* cprop.c: Likewise.
* data-streamer.h: Likewise.
* dbxout.c: Likewise.
* dce.c: Likewise.
* df-core.c: Likewise.
* df-problems.c: Likewise.
* df-scan.c: Likewise.
* dominance.c: Likewise.
* domwalk.c: Likewise.
* domwalk.h: Likewise.
* dse.c: Likewise.
* dwarf2cfi.c: Likewise.
* dwarf2out.c: Likewise.
* dwarf2out.h: Likewise.
* emit-rtl.c: Likewise.
* except.c: Likewise.
* except.h: Likewise.
* expr.c: Likewise.
* expr.h: Likewise.
* final.c: Likewise.
* fold-const.c: Likewise.
* function.c: Likewise.
* function.h: Likewise.
* fwprop.c: Likewise.
* gcc.c: Likewise.
* gcse.c: Likewise.
* genattr.c: Likewise.
* genattrtab.c: Likewise.
* genautomata.c: Likewise.
* genextract.c: Likewise.
* genopinit.c: Likewise
* ggc-common.c: Likewise.
* ggc.h: Likewise.
* gimple-low.c: Likewise.
* gimple-ssa-strength-reduction.c: Likewise.
* gimple-streamer-in.c: Likewise.
* gimple.c: Likewise.
* gimple.h: Likewise.
* gimplify.c: Likewise.
* graph.c: Likewise.
* graphds.c: Likewise.
* graphds.h: Likewise.
* graphite-blocking.c: Likewise.
* graphite-clast-to-gimple.c: Likewise.
* graphite-dependences.c: Likewise.
* graphite-interchange.c: Likewise.
* graphite-optimize-isl.c: Likewise.
* graphite-poly.c: Likewise.
* graphite-poly.h: Likewise.
* graphite-scop-detection.c: Likewise.
* graphite-scop-detection.h: Likewise.
* graphite-sese-to-poly.c: Likewise.
* graphite.c: Likewise.
* godump.c: Likewise.
* haifa-sched.c: Likewise.
* hw-doloop.c: Likewise.
* hw-doloop.h: Likewise.
* ifcvt.c: Likewise.
* insn-addr.h: Likewise.
* ipa-cp.c: Likewise.
* ipa-inline-analysis.c: Likewise.
* ipa-inline-transform.c: Likewise.
* ipa-inline.c: Likewise.
* ipa-inline.h: Likewise.
* ipa-prop.c: Likewise.
* ipa-prop.h: Likewise.
* ipa-pure-const.c: Likewise.
* ipa-ref-inline.h: Likewise.
* ipa-ref.c: Likewise.
* ipa-ref.h: Likewise.
* ipa-reference.c: Likewise.
* ipa-split.c: Likewise.
* ipa-utils.c: Likewise.
* ipa-utils.h: Likewise.
* ipa.c: Likewise.
* ira-build.c: Likewise.
* ira-color.c: Likewise.
* ira-emit.c: Likewise.
* ira-int.h: Likewise.
* ira.c: Likewise.
* loop-invariant.c: Likewise.
* loop-unroll.c: Likewise.
* lower-subreg.c: Likewise.
* lra-lives.c: Likewise.
* lra.c: Likewise.
* lto-cgraph.c: Likewise.
* lto-section-out.c: Likewise.
* lto-streamer-in.c: Likewise.
* lto-streamer-out.c: Likewise.
* lto-streamer.h: Likewise.
* lto-symtab.c: Likewise.
* mcf.c: Likewise.
* modulo-sched.c: Likewise.
* omp-low.c: Likewise.
* opts-common.c: Likewise.
* opts-global.c: Likewise.
* opts.c: Likewise.
* opts.h: Likewise.
* passes.c: Likewise.
* predict.c: Likewise.
* print-tree.c: Likewise.
* profile.c: Likewise.
* profile.h: Likewise.
* read-rtl.c: Likewise.
* ree.c: Likewise.
* reg-stack.c: Likewise.
* regrename.c: Likewise.
* regrename.h: Likewise.
* reload.c: Likewise.
* reload.h: Likewise.
* reload1.c: Likewise.
* rtl.h: Likewise.
* sched-deps.c: Likewise.
* sched-int.h: Likewise.
* sdbout.c: Likewise.
* sel-sched-dump.c: Likewise.
* sel-sched-ir.c: Likewise.
* sel-sched-ir.h: Likewise.
* sel-sched.c: Likewise.
* sese.c: Likewise.
* sese.h: Likewise.
* statistics.h: Likewise.
* stmt.c: Likewise.
* stor-layout.c: Likewise.
* store-motion.c: Likewise.
* tlink.c: Likewise.
* toplev.c: Likewise.
* trans-mem.c: Likewise.
* tree-browser.c: Likewise.
* tree-call-cdce.c: Likewise.
* tree-cfg.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-chrec.c: Likewise.
* tree-chrec.h: Likewise.
* tree-complex.c: Likewise.
* tree-data-ref.c: Likewise.
* tree-data-ref.h: Likewise.
* tree-dfa.c: Likewise.
* tree-diagnostic.c: Likewise.
* tree-dump.c: Likewise.
* tree-eh.c: Likewise.
* tree-emutls.c: Likewise.
* tree-flow.h: Likewise.
* tree-if-conv.c: Likewise.
* tree-inline.c: Likewise.
* tree-inline.h: Likewise.
* tree-into-ssa.c: Likewise.
* tree-iterator.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-mudflap.c: Likewise.
* tree-optimize.c: Likewise.
* tree-outof-ssa.c: Likewise.
* tree-parloops.c: Likewise.
* tree-phinodes.c: Likewise.
* tree-predcom.c: Likewise.
* tree-pretty-print.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-address.c: Likewise.
* tree-ssa-alias.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-coalesce.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-ssa-dom.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-live.c: Likewise.
* tree-ssa-live.h: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-operands.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-sccvn.h: Likewise.
* tree-ssa-strlen.c: Likewise.
* tree-ssa-structalias.c: Likewise.
* tree-ssa-tail-merge.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* tree-ssa-threadupdate.c: Likewise.
* tree-ssa-uncprop.c: Likewise.
* tree-ssa-uninit.c: Likewise.
* tree-ssa.c: Likewise.
* tree-ssanames.c: Likewise.
* tree-stdarg.c: Likewise.
* tree-streamer-in.c: Likewise.
* tree-streamer-out.c: Likewise.
* tree-streamer.c: Likewise.
* tree-streamer.h: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-generic.c: Likewise.
* tree-vect-loop-manip.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-slp.c: Likewise.
* tree-vect-stmts.c: Likewise.
* tree-vectorizer.c: Likewise.
* tree-vectorizer.h: Likewise.
* tree-vrp.c: Likewise.
* tree.c: Likewise.
* tree.h: Likewise.
* value-prof.c: Likewise.
* value-prof.h: Likewise.
* var-tracking.c: Likewise.
* varasm.c: Likewise.
* varpool.c: Likewise.
* vmsdbgout.c: Likewise.
* config/bfin/bfin.c: Likewise.
* config/c6x/c6x.c: Likewise.
* config/darwin.c: Likewise.
* config/i386/i386.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/mep/mep.c: Likewise.
* config/mips/mips.c: Likewise.
* config/pa/pa.c: Likewise.
* config/rs6000/rs6000-c.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/rx/rx.c: Likewise.
* config/spu/spu-c.c: Likewise.
* config/vms/vms.c: Likewise.
* config/vxworks.c: Likewise.
* config/epiphany/resolve-sw-modes.c: Likewise.
From-SVN: r193595
2012-11-18 03:54:30 +01:00
|
|
|
stmts.release ();
|
2010-08-25 12:47:50 +02:00
|
|
|
return false;
|
2007-01-22 12:11:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Simply insert cexpi at the beginning of top_bb but not earlier than
|
|
|
|
the name def statement. */
|
|
|
|
fndecl = mathfn_built_in (type, BUILT_IN_CEXPI);
|
|
|
|
if (!fndecl)
|
2010-08-25 12:47:50 +02:00
|
|
|
return false;
|
2008-07-28 16:33:56 +02:00
|
|
|
stmt = gimple_build_call (fndecl, 1, name);
|
2012-08-10 11:20:29 +02:00
|
|
|
res = make_temp_ssa_name (TREE_TYPE (TREE_TYPE (fndecl)), stmt, "sincostmp");
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple_call_set_lhs (stmt, res);
|
|
|
|
|
2007-01-22 12:11:00 +01:00
|
|
|
def_stmt = SSA_NAME_DEF_STMT (name);
|
2008-01-25 13:08:52 +01:00
|
|
|
if (!SSA_NAME_IS_DEFAULT_DEF (name)
|
2008-07-28 16:33:56 +02:00
|
|
|
&& gimple_code (def_stmt) != GIMPLE_PHI
|
|
|
|
&& gimple_bb (def_stmt) == top_bb)
|
2007-01-22 12:11:00 +01:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
gsi = gsi_for_stmt (def_stmt);
|
|
|
|
gsi_insert_after (&gsi, stmt, GSI_SAME_STMT);
|
2007-01-22 12:11:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
gsi = gsi_after_labels (top_bb);
|
|
|
|
gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
|
2007-01-22 12:11:00 +01:00
|
|
|
}
|
2011-04-13 21:39:02 +02:00
|
|
|
sincos_stats.inserted++;
|
2007-01-22 12:11:00 +01:00
|
|
|
|
|
|
|
/* And adjust the recorded old call sites. */
|
This patch rewrites the old VEC macro-based interface into a new one based on the template class 'vec'.
This patch rewrites the old VEC macro-based interface into a new one
based on the template class 'vec'. The user-visible changes are
described in http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec.
I have tested the patch pretty extensively:
- Regular bootstraps on x86_64, ppc, ia64, sparc and hppa.
- Bootstraps with --enable-checking=release
- Bootstraps with --enable-checking=gc,gcac
- Basic builds on all targets (using contrib/config-list.mk).
We no longer access the vectors via VEC_* macros. The pattern is
"VEC_operation (T, A, V, args)" becomes "V.operation (args)".
The only thing I could not do is create proper ctors and dtors for the
vec class. Since these vectors are stored in unions, we
have to keep them as PODs (C++03 does not allow non-PODs in unions).
This means that creation and destruction must be explicit. There is a
new method vec<type, allocation, layout>::create() and another vec<type,
allocation, layout>::destroy() to allocate the internal vector.
For vectors that must be pointers, there is a family of free functions
that implement the operations that need to tolerate NULL vectors.
These functions all start with the prefix 'vec_safe_'. See the wiki
page for details.
The gengtype change removes the special handling for VEC() that used
to exist in gengtype. Additionally, it allows gengtype to recognize
templates of more than one argument and introduces the concept of an
undefined type (useful for template arguments that may or may not be
types).
When a TYPE_UNDEFINED is reached, gengtype will ignore it if it
happens inside a type marked with GTY((user)). Otherwise, it will
emit an error.
Finally, gengtype rejects root types marked GTY((user)) that are not
first class pointers.
2012-11-16 Diego Novillo <dnovillo@google.com>
VEC API overhaul (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* vec.c (register_overhead): Convert it into
member function of vec_prefix.
(release_overhead): Likewise.
(calculate_allocation): Likewise.
(vec_heap_free): Remove.
(vec_gc_o_reserve_1): Remove.
(vec_heap_o_reserve_1): Remove.
(vec_stack_o_reserve_1): Remove.
(vec_stack_o_reserve_exact): Remove.
(register_stack_vec): New.
(stack_vec_register_index): New.
(unregister_stack_vec): New.
(vec_assert_fail): Remove.
* vec.h: Conditionally include ggc.h. Document conditional
hackery.
Update top-level documentation.
(ALONE_VEC_CHECK_INFO): Remove.
(VEC_CHECK_INFO): Remove.
(ALONE_VEC_CHECK_DECL): Remove.
(VEC_CHECK_DECL): Remove.
(ALONE_VEC_CHECK_PASS): Remove.
(VEC_CHECK_PASS): Remove.
(VEC_ASSERT): Remove.
(vec_prefix): Add friends va_gc, va_gc_atomic, va_heap and
va_stack.
Mark fields alloc_ and num_ as protected.
(struct vec_t): Remove. Remove all function members.
(struct vl_embed): Declare.
(struct vl_ptr): Declare.
(free): Remove.
(reserve_exact): Remove.
(reserve): Remove.
(safe_splice): Remove.
(safe_push): Remove.
(safe_grow): Remove.
(safe_grow_cleared): Remove.
(safe_insert): Remove.
(DEF_VEC_I): Remove.
(DEF_VEC_ALLOC_I): Remove.
(DEF_VEC_P): Remove.
(DEF_VEC_ALLOC_P): Remove.
(DEF_VEC_O): Remove.
(DEF_VEC_ALLOC_O): Remove.
(DEF_VEC_ALLOC_P_STACK): Remove.
(DEF_VEC_ALLOC_O_STACK): Remove.
(DEF_VEC_ALLOC_I_STACK): Remove.
(DEF_VEC_A): Remove.
(DEF_VEC_ALLOC_A): Remove.
(vec_stack_p_reserve_exact_1): Remove.
(vec_stack_o_reserve): Remove.
(vec_stack_o_reserve_exact): Remove.
(VEC_length): Remove.
(VEC_empty): Remove.
(VEC_address): Remove.
(vec_address): Remove.
(VEC_last): Remove.
(VEC_index): Remove.
(VEC_iterate): Remove.
(VEC_embedded_size): Remove.
(VEC_embedded_init): Remove.
(VEC_free): Remove.
(VEC_copy): Remove.
(VEC_space): Remove.
(VEC_reserve): Remove.
(VEC_reserve_exact): Remove.
(VEC_splice): Remove.
(VEC_safe_splice): Remove.
(VEC_quick_push): Remove.
(VEC_safe_push): Remove.
(VEC_pop): Remove.
(VEC_truncate): Remove.
(VEC_safe_grow): Remove.
(VEC_replace): Remove.
(VEC_quick_insert): Remove.
(VEC_safe_insert): Remove.
(VEC_ordered_remove): Remove.
(VEC_unordered_remove): Remove.
(VEC_block_remove): Remove.
(VEC_lower_bound): Remove.
(VEC_alloc): Remove.
(VEC_qsort): Remove.
(va_heap): Declare.
(va_heap::default_layout): New typedef to vl_ptr.
(va_heap::reserve): New.
(va_heap::release): New.
(va_gc): Declare.
(va_gc::default_layout): New typedef to vl_embed.
(va_gc::reserve): New.
(va_gc::release): New.
(va_gc_atomic): Declare. Inherit from va_gc.
(va_stack): Declare.
(va_stack::default_layout): New typedef to vl_ptr.
(va_stack::alloc): New.
(va_stack::reserve): New.
(va_stack::release): New.
(register_stack_vec): Declare.
(stack_vec_register_index): Declare.
(unregister_stack_vec): Declare.
(vec<T, A = va_heap, L = typename A::default_layout>): Declare
empty vec template.
(vec<T, A, vl_embed>): Partial specialization for embedded
layout.
(vec<T, A, vl_embed>::allocated): New.
(vec<T, A, vl_embed>::length): New.
(vec<T, A, vl_embed>::is_empty): New.
(vec<T, A, vl_embed>::address): New.
(vec<T, A, vl_embed>::operator[]): New.
(vec<T, A, vl_embed>::last New.
(vec<T, A, vl_embed>::space): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::copy): New.
(vec<T, A, vl_embed>::splice): New.
(vec<T, A, vl_embed>::quick_push New.
(vec<T, A, vl_embed>::pop New.
(vec<T, A, vl_embed>::truncate): New.
(vec<T, A, vl_embed>::quick_insert): New.
(vec<T, A, vl_embed>::ordered_remove): New.
(vec<T, A, vl_embed>::unordered_remove): New.
(vec<T, A, vl_embed>::block_remove): New.
(vec<T, A, vl_embed>::qsort): New.
(vec<T, A, vl_embed>::lower_bound): New.
(vec<T, A, vl_embed>::embedded_size): New.
(vec<T, A, vl_embed>::embedded_init): New.
(vec<T, A, vl_embed>::quick_grow): New.
(vec<T, A, vl_embed>::quick_grow_cleared): New.
(vec_safe_space): New.
(vec_safe_length): New.
(vec_safe_address): New.
(vec_safe_is_empty): New.
(vec_safe_reserve): New.
(vec_safe_reserve_exact): New.
(vec_alloc): New.
(vec_free): New.
(vec_safe_grow): New.
(vec_safe_grow_cleared): New.
(vec_safe_iterate): New.
(vec_safe_push): New.
(vec_safe_insert): New.
(vec_safe_truncate): New.
(vec_safe_copy): New.
(vec_safe_splice): New.
(vec<T, A, vl_ptr>): New partial specialization for the space
efficient layout.
(vec<T, A, vl_ptr>::exists): New.
(vec<T, A, vl_ptr>::is_empty): New.
(vec<T, A, vl_ptr>::length): New.
(vec<T, A, vl_ptr>::address): New.
(vec<T, A, vl_ptr>::operator[]): New.
(vec<T, A, vl_ptr>::operator!=): New.
(vec<T, A, vl_ptr>::operator==): New.
(vec<T, A, vl_ptr>::last): New.
(vec<T, A, vl_ptr>::space): New.
(vec<T, A, vl_ptr>::iterate): New.
(vec<T, A, vl_ptr>::copy): New.
(vec<T, A, vl_ptr>::reserve): New.
(vec<T, A, vl_ptr>::reserve_exact): New.
(vec<T, A, vl_ptr>::splice): New.
(vec<T, A, vl_ptr>::safe_splice): New.
(vec<T, A, vl_ptr>::quick_push): New.
(vec<T, A, vl_ptr>::safe_push): New.
(vec<T, A, vl_ptr>::pop): New.
(vec<T, A, vl_ptr>::truncate): New.
(vec<T, A, vl_ptr>::safe_grow): New.
(vec<T, A, vl_ptr>::safe_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_grow): New.
(vec<T, A, vl_ptr>::quick_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_insert): New.
(vec<T, A, vl_ptr>::safe_insert): New.
(vec<T, A, vl_ptr>::ordered_remove): New.
(vec<T, A, vl_ptr>::unordered_remove): New.
(vec<T, A, vl_ptr>::block_remove): New.
(vec<T, A, vl_ptr>::qsort): New.
(vec<T, A, vl_ptr>::lower_bound): New.
(vec_stack_alloc): Define.
(FOR_EACH_VEC_SAFE_ELT): Define.
* vecir.h: Remove. Update all users.
* vecprim.h: Remove. Update all users.
Move uchar to coretypes.h.
* Makefile.in (VEC_H): Add $(GGC_H).
Remove vecir.h and vecprim.h dependencies everywhere.
2012-11-16 Diego Novillo <dnovillo@google.com>
* gengtype-lex.l (VEC): Remove.
Add characters in the set [\!\>\.-].
* gengtype-parse.c (token_names): Remove "VEC".
(require_template_declaration): Remove handling of VEC_TOKEN.
(type): Likewise.
Call create_user_defined_type when parsing GTY((user)).
* gengtype-state.c (type_lineloc): handle TYPE_UNDEFINED.
(write_state_undefined_type): New.
(write_state_type): Call write_state_undefined_type for
TYPE_UNDEFINED.
(read_state_type): Call read_state_undefined_type for
TYPE_UNDEFINED.
* gengtype.c (dbgprint_count_type_at): Handle TYPE_UNDEFINED.
(create_user_defined_type): Make extern.
(type_for_name): Factor out of resolve_typedef.
(create_undefined_type): New
(resolve_typedef): Call it when we cannot find a previous
typedef and the type is not a template.
(find_structure): Accept TYPE_UNDEFINED.
(set_gc_used_type): Add argument ALLOWED_UNDEFINED_TYPES,
default to false.
Emit an error for TYPE_UNDEFINED unless LEVEL is GC_UNUSED or
ALLOWED_UNDEFINED_TYPES is set.
Set ALLOWED_UNDEFINED_TYPES to true for TYPE_USER_STRUCT.
(filter_type_name): Accept templates with more than one
argument.
(output_mangled_typename): Handle TYPE_UNDEFINED
(walk_type): Likewise.
(write_types_process_field): Likewise.
(write_func_for_structure): If CHAIN_NEXT is set, ORIG_S
should not be a user-defined type.
(write_types_local_user_process_field): Handle TYPE_ARRAY,
TYPE_NONE and TYPE_UNDEFINED.
(write_types_local_process_field): Likewise.
(contains_scalar_p): Return 0 for TYPE_USER_STRUCT.
(write_root): Reject user-defined types that are not pointers.
Handle TYPE_NONE, TYPE_UNDEFINED, TYPE_UNION, TYPE_LANG_STRUCT
and TYPE_PARAM_STRUCT.
(output_typename): Handle TYPE_NONE, TYPE_UNDEFINED, and
TYPE_ARRAY.
(dump_typekind): Handle TYPE_UNDEFINED.
* gengtype.h (enum typekind): Add TYPE_UNDEFINED.
(create_user_defined_type): Declare.
(enum gty_token): Remove VEC_TOKEN.
2012-11-16 Diego Novillo <dnovillo@google.com>
Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* coretypes.h (uchar): Define.
* alias.c: Use new vec API in vec.h.
* asan.c: Likewise.
* attribs.c: Likewise.
* basic-block.h: Likewise.
* bb-reorder.c: Likewise.
* builtins.c: Likewise.
* calls.c: Likewise.
* cfg.c: Likewise.
* cfganal.c: Likewise.
* cfgcleanup.c: Likewise.
* cfgexpand.c: Likewise.
* cfghooks.c: Likewise.
* cfghooks.h: Likewise.
* cfgloop.c: Likewise.
* cfgloop.h: Likewise.
* cfgloopanal.c: Likewise.
* cfgloopmanip.c: Likewise.
* cfgrtl.c: Likewise.
* cgraph.c: Likewise.
* cgraph.h: Likewise.
* cgraphclones.c: Likewise.
* cgraphunit.c: Likewise.
* combine.c: Likewise.
* compare-elim.c: Likewise.
* coverage.c: Likewise.
* cprop.c: Likewise.
* data-streamer.h: Likewise.
* dbxout.c: Likewise.
* dce.c: Likewise.
* df-core.c: Likewise.
* df-problems.c: Likewise.
* df-scan.c: Likewise.
* dominance.c: Likewise.
* domwalk.c: Likewise.
* domwalk.h: Likewise.
* dse.c: Likewise.
* dwarf2cfi.c: Likewise.
* dwarf2out.c: Likewise.
* dwarf2out.h: Likewise.
* emit-rtl.c: Likewise.
* except.c: Likewise.
* except.h: Likewise.
* expr.c: Likewise.
* expr.h: Likewise.
* final.c: Likewise.
* fold-const.c: Likewise.
* function.c: Likewise.
* function.h: Likewise.
* fwprop.c: Likewise.
* gcc.c: Likewise.
* gcse.c: Likewise.
* genattr.c: Likewise.
* genattrtab.c: Likewise.
* genautomata.c: Likewise.
* genextract.c: Likewise.
* genopinit.c: Likewise
* ggc-common.c: Likewise.
* ggc.h: Likewise.
* gimple-low.c: Likewise.
* gimple-ssa-strength-reduction.c: Likewise.
* gimple-streamer-in.c: Likewise.
* gimple.c: Likewise.
* gimple.h: Likewise.
* gimplify.c: Likewise.
* graph.c: Likewise.
* graphds.c: Likewise.
* graphds.h: Likewise.
* graphite-blocking.c: Likewise.
* graphite-clast-to-gimple.c: Likewise.
* graphite-dependences.c: Likewise.
* graphite-interchange.c: Likewise.
* graphite-optimize-isl.c: Likewise.
* graphite-poly.c: Likewise.
* graphite-poly.h: Likewise.
* graphite-scop-detection.c: Likewise.
* graphite-scop-detection.h: Likewise.
* graphite-sese-to-poly.c: Likewise.
* graphite.c: Likewise.
* godump.c: Likewise.
* haifa-sched.c: Likewise.
* hw-doloop.c: Likewise.
* hw-doloop.h: Likewise.
* ifcvt.c: Likewise.
* insn-addr.h: Likewise.
* ipa-cp.c: Likewise.
* ipa-inline-analysis.c: Likewise.
* ipa-inline-transform.c: Likewise.
* ipa-inline.c: Likewise.
* ipa-inline.h: Likewise.
* ipa-prop.c: Likewise.
* ipa-prop.h: Likewise.
* ipa-pure-const.c: Likewise.
* ipa-ref-inline.h: Likewise.
* ipa-ref.c: Likewise.
* ipa-ref.h: Likewise.
* ipa-reference.c: Likewise.
* ipa-split.c: Likewise.
* ipa-utils.c: Likewise.
* ipa-utils.h: Likewise.
* ipa.c: Likewise.
* ira-build.c: Likewise.
* ira-color.c: Likewise.
* ira-emit.c: Likewise.
* ira-int.h: Likewise.
* ira.c: Likewise.
* loop-invariant.c: Likewise.
* loop-unroll.c: Likewise.
* lower-subreg.c: Likewise.
* lra-lives.c: Likewise.
* lra.c: Likewise.
* lto-cgraph.c: Likewise.
* lto-section-out.c: Likewise.
* lto-streamer-in.c: Likewise.
* lto-streamer-out.c: Likewise.
* lto-streamer.h: Likewise.
* lto-symtab.c: Likewise.
* mcf.c: Likewise.
* modulo-sched.c: Likewise.
* omp-low.c: Likewise.
* opts-common.c: Likewise.
* opts-global.c: Likewise.
* opts.c: Likewise.
* opts.h: Likewise.
* passes.c: Likewise.
* predict.c: Likewise.
* print-tree.c: Likewise.
* profile.c: Likewise.
* profile.h: Likewise.
* read-rtl.c: Likewise.
* ree.c: Likewise.
* reg-stack.c: Likewise.
* regrename.c: Likewise.
* regrename.h: Likewise.
* reload.c: Likewise.
* reload.h: Likewise.
* reload1.c: Likewise.
* rtl.h: Likewise.
* sched-deps.c: Likewise.
* sched-int.h: Likewise.
* sdbout.c: Likewise.
* sel-sched-dump.c: Likewise.
* sel-sched-ir.c: Likewise.
* sel-sched-ir.h: Likewise.
* sel-sched.c: Likewise.
* sese.c: Likewise.
* sese.h: Likewise.
* statistics.h: Likewise.
* stmt.c: Likewise.
* stor-layout.c: Likewise.
* store-motion.c: Likewise.
* tlink.c: Likewise.
* toplev.c: Likewise.
* trans-mem.c: Likewise.
* tree-browser.c: Likewise.
* tree-call-cdce.c: Likewise.
* tree-cfg.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-chrec.c: Likewise.
* tree-chrec.h: Likewise.
* tree-complex.c: Likewise.
* tree-data-ref.c: Likewise.
* tree-data-ref.h: Likewise.
* tree-dfa.c: Likewise.
* tree-diagnostic.c: Likewise.
* tree-dump.c: Likewise.
* tree-eh.c: Likewise.
* tree-emutls.c: Likewise.
* tree-flow.h: Likewise.
* tree-if-conv.c: Likewise.
* tree-inline.c: Likewise.
* tree-inline.h: Likewise.
* tree-into-ssa.c: Likewise.
* tree-iterator.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-mudflap.c: Likewise.
* tree-optimize.c: Likewise.
* tree-outof-ssa.c: Likewise.
* tree-parloops.c: Likewise.
* tree-phinodes.c: Likewise.
* tree-predcom.c: Likewise.
* tree-pretty-print.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-address.c: Likewise.
* tree-ssa-alias.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-coalesce.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-ssa-dom.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-live.c: Likewise.
* tree-ssa-live.h: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-operands.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-sccvn.h: Likewise.
* tree-ssa-strlen.c: Likewise.
* tree-ssa-structalias.c: Likewise.
* tree-ssa-tail-merge.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* tree-ssa-threadupdate.c: Likewise.
* tree-ssa-uncprop.c: Likewise.
* tree-ssa-uninit.c: Likewise.
* tree-ssa.c: Likewise.
* tree-ssanames.c: Likewise.
* tree-stdarg.c: Likewise.
* tree-streamer-in.c: Likewise.
* tree-streamer-out.c: Likewise.
* tree-streamer.c: Likewise.
* tree-streamer.h: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-generic.c: Likewise.
* tree-vect-loop-manip.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-slp.c: Likewise.
* tree-vect-stmts.c: Likewise.
* tree-vectorizer.c: Likewise.
* tree-vectorizer.h: Likewise.
* tree-vrp.c: Likewise.
* tree.c: Likewise.
* tree.h: Likewise.
* value-prof.c: Likewise.
* value-prof.h: Likewise.
* var-tracking.c: Likewise.
* varasm.c: Likewise.
* varpool.c: Likewise.
* vmsdbgout.c: Likewise.
* config/bfin/bfin.c: Likewise.
* config/c6x/c6x.c: Likewise.
* config/darwin.c: Likewise.
* config/i386/i386.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/mep/mep.c: Likewise.
* config/mips/mips.c: Likewise.
* config/pa/pa.c: Likewise.
* config/rs6000/rs6000-c.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/rx/rx.c: Likewise.
* config/spu/spu-c.c: Likewise.
* config/vms/vms.c: Likewise.
* config/vxworks.c: Likewise.
* config/epiphany/resolve-sw-modes.c: Likewise.
From-SVN: r193595
2012-11-18 03:54:30 +01:00
|
|
|
for (i = 0; stmts.iterate (i, &use_stmt); ++i)
|
2007-01-22 12:11:00 +01:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
tree rhs = NULL;
|
|
|
|
fndecl = gimple_call_fndecl (use_stmt);
|
|
|
|
|
2007-01-22 12:11:00 +01:00
|
|
|
switch (DECL_FUNCTION_CODE (fndecl))
|
|
|
|
{
|
|
|
|
CASE_FLT_FN (BUILT_IN_COS):
|
2008-07-28 16:33:56 +02:00
|
|
|
rhs = fold_build1 (REALPART_EXPR, type, res);
|
2007-01-22 12:11:00 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_FLT_FN (BUILT_IN_SIN):
|
2008-07-28 16:33:56 +02:00
|
|
|
rhs = fold_build1 (IMAGPART_EXPR, type, res);
|
2007-01-22 12:11:00 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_FLT_FN (BUILT_IN_CEXPI):
|
2008-07-28 16:33:56 +02:00
|
|
|
rhs = res;
|
2007-01-22 12:11:00 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:;
|
|
|
|
gcc_unreachable ();
|
|
|
|
}
|
|
|
|
|
2008-07-28 16:33:56 +02:00
|
|
|
/* Replace call with a copy. */
|
|
|
|
stmt = gimple_build_assign (gimple_call_lhs (use_stmt), rhs);
|
|
|
|
|
|
|
|
gsi = gsi_for_stmt (use_stmt);
|
2010-08-25 12:47:50 +02:00
|
|
|
gsi_replace (&gsi, stmt, true);
|
|
|
|
if (gimple_purge_dead_eh_edges (gimple_bb (stmt)))
|
|
|
|
cfg_changed = true;
|
2007-01-22 12:11:00 +01:00
|
|
|
}
|
|
|
|
|
This patch rewrites the old VEC macro-based interface into a new one based on the template class 'vec'.
This patch rewrites the old VEC macro-based interface into a new one
based on the template class 'vec'. The user-visible changes are
described in http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec.
I have tested the patch pretty extensively:
- Regular bootstraps on x86_64, ppc, ia64, sparc and hppa.
- Bootstraps with --enable-checking=release
- Bootstraps with --enable-checking=gc,gcac
- Basic builds on all targets (using contrib/config-list.mk).
We no longer access the vectors via VEC_* macros. The pattern is
"VEC_operation (T, A, V, args)" becomes "V.operation (args)".
The only thing I could not do is create proper ctors and dtors for the
vec class. Since these vectors are stored in unions, we
have to keep them as PODs (C++03 does not allow non-PODs in unions).
This means that creation and destruction must be explicit. There is a
new method vec<type, allocation, layout>::create() and another vec<type,
allocation, layout>::destroy() to allocate the internal vector.
For vectors that must be pointers, there is a family of free functions
that implement the operations that need to tolerate NULL vectors.
These functions all start with the prefix 'vec_safe_'. See the wiki
page for details.
The gengtype change removes the special handling for VEC() that used
to exist in gengtype. Additionally, it allows gengtype to recognize
templates of more than one argument and introduces the concept of an
undefined type (useful for template arguments that may or may not be
types).
When a TYPE_UNDEFINED is reached, gengtype will ignore it if it
happens inside a type marked with GTY((user)). Otherwise, it will
emit an error.
Finally, gengtype rejects root types marked GTY((user)) that are not
first class pointers.
2012-11-16 Diego Novillo <dnovillo@google.com>
VEC API overhaul (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* vec.c (register_overhead): Convert it into
member function of vec_prefix.
(release_overhead): Likewise.
(calculate_allocation): Likewise.
(vec_heap_free): Remove.
(vec_gc_o_reserve_1): Remove.
(vec_heap_o_reserve_1): Remove.
(vec_stack_o_reserve_1): Remove.
(vec_stack_o_reserve_exact): Remove.
(register_stack_vec): New.
(stack_vec_register_index): New.
(unregister_stack_vec): New.
(vec_assert_fail): Remove.
* vec.h: Conditionally include ggc.h. Document conditional
hackery.
Update top-level documentation.
(ALONE_VEC_CHECK_INFO): Remove.
(VEC_CHECK_INFO): Remove.
(ALONE_VEC_CHECK_DECL): Remove.
(VEC_CHECK_DECL): Remove.
(ALONE_VEC_CHECK_PASS): Remove.
(VEC_CHECK_PASS): Remove.
(VEC_ASSERT): Remove.
(vec_prefix): Add friends va_gc, va_gc_atomic, va_heap and
va_stack.
Mark fields alloc_ and num_ as protected.
(struct vec_t): Remove. Remove all function members.
(struct vl_embed): Declare.
(struct vl_ptr): Declare.
(free): Remove.
(reserve_exact): Remove.
(reserve): Remove.
(safe_splice): Remove.
(safe_push): Remove.
(safe_grow): Remove.
(safe_grow_cleared): Remove.
(safe_insert): Remove.
(DEF_VEC_I): Remove.
(DEF_VEC_ALLOC_I): Remove.
(DEF_VEC_P): Remove.
(DEF_VEC_ALLOC_P): Remove.
(DEF_VEC_O): Remove.
(DEF_VEC_ALLOC_O): Remove.
(DEF_VEC_ALLOC_P_STACK): Remove.
(DEF_VEC_ALLOC_O_STACK): Remove.
(DEF_VEC_ALLOC_I_STACK): Remove.
(DEF_VEC_A): Remove.
(DEF_VEC_ALLOC_A): Remove.
(vec_stack_p_reserve_exact_1): Remove.
(vec_stack_o_reserve): Remove.
(vec_stack_o_reserve_exact): Remove.
(VEC_length): Remove.
(VEC_empty): Remove.
(VEC_address): Remove.
(vec_address): Remove.
(VEC_last): Remove.
(VEC_index): Remove.
(VEC_iterate): Remove.
(VEC_embedded_size): Remove.
(VEC_embedded_init): Remove.
(VEC_free): Remove.
(VEC_copy): Remove.
(VEC_space): Remove.
(VEC_reserve): Remove.
(VEC_reserve_exact): Remove.
(VEC_splice): Remove.
(VEC_safe_splice): Remove.
(VEC_quick_push): Remove.
(VEC_safe_push): Remove.
(VEC_pop): Remove.
(VEC_truncate): Remove.
(VEC_safe_grow): Remove.
(VEC_replace): Remove.
(VEC_quick_insert): Remove.
(VEC_safe_insert): Remove.
(VEC_ordered_remove): Remove.
(VEC_unordered_remove): Remove.
(VEC_block_remove): Remove.
(VEC_lower_bound): Remove.
(VEC_alloc): Remove.
(VEC_qsort): Remove.
(va_heap): Declare.
(va_heap::default_layout): New typedef to vl_ptr.
(va_heap::reserve): New.
(va_heap::release): New.
(va_gc): Declare.
(va_gc::default_layout): New typedef to vl_embed.
(va_gc::reserve): New.
(va_gc::release): New.
(va_gc_atomic): Declare. Inherit from va_gc.
(va_stack): Declare.
(va_stack::default_layout): New typedef to vl_ptr.
(va_stack::alloc): New.
(va_stack::reserve): New.
(va_stack::release): New.
(register_stack_vec): Declare.
(stack_vec_register_index): Declare.
(unregister_stack_vec): Declare.
(vec<T, A = va_heap, L = typename A::default_layout>): Declare
empty vec template.
(vec<T, A, vl_embed>): Partial specialization for embedded
layout.
(vec<T, A, vl_embed>::allocated): New.
(vec<T, A, vl_embed>::length): New.
(vec<T, A, vl_embed>::is_empty): New.
(vec<T, A, vl_embed>::address): New.
(vec<T, A, vl_embed>::operator[]): New.
(vec<T, A, vl_embed>::last New.
(vec<T, A, vl_embed>::space): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::iterate): New.
(vec<T, A, vl_embed>::copy): New.
(vec<T, A, vl_embed>::splice): New.
(vec<T, A, vl_embed>::quick_push New.
(vec<T, A, vl_embed>::pop New.
(vec<T, A, vl_embed>::truncate): New.
(vec<T, A, vl_embed>::quick_insert): New.
(vec<T, A, vl_embed>::ordered_remove): New.
(vec<T, A, vl_embed>::unordered_remove): New.
(vec<T, A, vl_embed>::block_remove): New.
(vec<T, A, vl_embed>::qsort): New.
(vec<T, A, vl_embed>::lower_bound): New.
(vec<T, A, vl_embed>::embedded_size): New.
(vec<T, A, vl_embed>::embedded_init): New.
(vec<T, A, vl_embed>::quick_grow): New.
(vec<T, A, vl_embed>::quick_grow_cleared): New.
(vec_safe_space): New.
(vec_safe_length): New.
(vec_safe_address): New.
(vec_safe_is_empty): New.
(vec_safe_reserve): New.
(vec_safe_reserve_exact): New.
(vec_alloc): New.
(vec_free): New.
(vec_safe_grow): New.
(vec_safe_grow_cleared): New.
(vec_safe_iterate): New.
(vec_safe_push): New.
(vec_safe_insert): New.
(vec_safe_truncate): New.
(vec_safe_copy): New.
(vec_safe_splice): New.
(vec<T, A, vl_ptr>): New partial specialization for the space
efficient layout.
(vec<T, A, vl_ptr>::exists): New.
(vec<T, A, vl_ptr>::is_empty): New.
(vec<T, A, vl_ptr>::length): New.
(vec<T, A, vl_ptr>::address): New.
(vec<T, A, vl_ptr>::operator[]): New.
(vec<T, A, vl_ptr>::operator!=): New.
(vec<T, A, vl_ptr>::operator==): New.
(vec<T, A, vl_ptr>::last): New.
(vec<T, A, vl_ptr>::space): New.
(vec<T, A, vl_ptr>::iterate): New.
(vec<T, A, vl_ptr>::copy): New.
(vec<T, A, vl_ptr>::reserve): New.
(vec<T, A, vl_ptr>::reserve_exact): New.
(vec<T, A, vl_ptr>::splice): New.
(vec<T, A, vl_ptr>::safe_splice): New.
(vec<T, A, vl_ptr>::quick_push): New.
(vec<T, A, vl_ptr>::safe_push): New.
(vec<T, A, vl_ptr>::pop): New.
(vec<T, A, vl_ptr>::truncate): New.
(vec<T, A, vl_ptr>::safe_grow): New.
(vec<T, A, vl_ptr>::safe_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_grow): New.
(vec<T, A, vl_ptr>::quick_grow_cleared): New.
(vec<T, A, vl_ptr>::quick_insert): New.
(vec<T, A, vl_ptr>::safe_insert): New.
(vec<T, A, vl_ptr>::ordered_remove): New.
(vec<T, A, vl_ptr>::unordered_remove): New.
(vec<T, A, vl_ptr>::block_remove): New.
(vec<T, A, vl_ptr>::qsort): New.
(vec<T, A, vl_ptr>::lower_bound): New.
(vec_stack_alloc): Define.
(FOR_EACH_VEC_SAFE_ELT): Define.
* vecir.h: Remove. Update all users.
* vecprim.h: Remove. Update all users.
Move uchar to coretypes.h.
* Makefile.in (VEC_H): Add $(GGC_H).
Remove vecir.h and vecprim.h dependencies everywhere.
2012-11-16 Diego Novillo <dnovillo@google.com>
* gengtype-lex.l (VEC): Remove.
Add characters in the set [\!\>\.-].
* gengtype-parse.c (token_names): Remove "VEC".
(require_template_declaration): Remove handling of VEC_TOKEN.
(type): Likewise.
Call create_user_defined_type when parsing GTY((user)).
* gengtype-state.c (type_lineloc): handle TYPE_UNDEFINED.
(write_state_undefined_type): New.
(write_state_type): Call write_state_undefined_type for
TYPE_UNDEFINED.
(read_state_type): Call read_state_undefined_type for
TYPE_UNDEFINED.
* gengtype.c (dbgprint_count_type_at): Handle TYPE_UNDEFINED.
(create_user_defined_type): Make extern.
(type_for_name): Factor out of resolve_typedef.
(create_undefined_type): New
(resolve_typedef): Call it when we cannot find a previous
typedef and the type is not a template.
(find_structure): Accept TYPE_UNDEFINED.
(set_gc_used_type): Add argument ALLOWED_UNDEFINED_TYPES,
default to false.
Emit an error for TYPE_UNDEFINED unless LEVEL is GC_UNUSED or
ALLOWED_UNDEFINED_TYPES is set.
Set ALLOWED_UNDEFINED_TYPES to true for TYPE_USER_STRUCT.
(filter_type_name): Accept templates with more than one
argument.
(output_mangled_typename): Handle TYPE_UNDEFINED
(walk_type): Likewise.
(write_types_process_field): Likewise.
(write_func_for_structure): If CHAIN_NEXT is set, ORIG_S
should not be a user-defined type.
(write_types_local_user_process_field): Handle TYPE_ARRAY,
TYPE_NONE and TYPE_UNDEFINED.
(write_types_local_process_field): Likewise.
(contains_scalar_p): Return 0 for TYPE_USER_STRUCT.
(write_root): Reject user-defined types that are not pointers.
Handle TYPE_NONE, TYPE_UNDEFINED, TYPE_UNION, TYPE_LANG_STRUCT
and TYPE_PARAM_STRUCT.
(output_typename): Handle TYPE_NONE, TYPE_UNDEFINED, and
TYPE_ARRAY.
(dump_typekind): Handle TYPE_UNDEFINED.
* gengtype.h (enum typekind): Add TYPE_UNDEFINED.
(create_user_defined_type): Declare.
(enum gty_token): Remove VEC_TOKEN.
2012-11-16 Diego Novillo <dnovillo@google.com>
Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
* coretypes.h (uchar): Define.
* alias.c: Use new vec API in vec.h.
* asan.c: Likewise.
* attribs.c: Likewise.
* basic-block.h: Likewise.
* bb-reorder.c: Likewise.
* builtins.c: Likewise.
* calls.c: Likewise.
* cfg.c: Likewise.
* cfganal.c: Likewise.
* cfgcleanup.c: Likewise.
* cfgexpand.c: Likewise.
* cfghooks.c: Likewise.
* cfghooks.h: Likewise.
* cfgloop.c: Likewise.
* cfgloop.h: Likewise.
* cfgloopanal.c: Likewise.
* cfgloopmanip.c: Likewise.
* cfgrtl.c: Likewise.
* cgraph.c: Likewise.
* cgraph.h: Likewise.
* cgraphclones.c: Likewise.
* cgraphunit.c: Likewise.
* combine.c: Likewise.
* compare-elim.c: Likewise.
* coverage.c: Likewise.
* cprop.c: Likewise.
* data-streamer.h: Likewise.
* dbxout.c: Likewise.
* dce.c: Likewise.
* df-core.c: Likewise.
* df-problems.c: Likewise.
* df-scan.c: Likewise.
* dominance.c: Likewise.
* domwalk.c: Likewise.
* domwalk.h: Likewise.
* dse.c: Likewise.
* dwarf2cfi.c: Likewise.
* dwarf2out.c: Likewise.
* dwarf2out.h: Likewise.
* emit-rtl.c: Likewise.
* except.c: Likewise.
* except.h: Likewise.
* expr.c: Likewise.
* expr.h: Likewise.
* final.c: Likewise.
* fold-const.c: Likewise.
* function.c: Likewise.
* function.h: Likewise.
* fwprop.c: Likewise.
* gcc.c: Likewise.
* gcse.c: Likewise.
* genattr.c: Likewise.
* genattrtab.c: Likewise.
* genautomata.c: Likewise.
* genextract.c: Likewise.
* genopinit.c: Likewise
* ggc-common.c: Likewise.
* ggc.h: Likewise.
* gimple-low.c: Likewise.
* gimple-ssa-strength-reduction.c: Likewise.
* gimple-streamer-in.c: Likewise.
* gimple.c: Likewise.
* gimple.h: Likewise.
* gimplify.c: Likewise.
* graph.c: Likewise.
* graphds.c: Likewise.
* graphds.h: Likewise.
* graphite-blocking.c: Likewise.
* graphite-clast-to-gimple.c: Likewise.
* graphite-dependences.c: Likewise.
* graphite-interchange.c: Likewise.
* graphite-optimize-isl.c: Likewise.
* graphite-poly.c: Likewise.
* graphite-poly.h: Likewise.
* graphite-scop-detection.c: Likewise.
* graphite-scop-detection.h: Likewise.
* graphite-sese-to-poly.c: Likewise.
* graphite.c: Likewise.
* godump.c: Likewise.
* haifa-sched.c: Likewise.
* hw-doloop.c: Likewise.
* hw-doloop.h: Likewise.
* ifcvt.c: Likewise.
* insn-addr.h: Likewise.
* ipa-cp.c: Likewise.
* ipa-inline-analysis.c: Likewise.
* ipa-inline-transform.c: Likewise.
* ipa-inline.c: Likewise.
* ipa-inline.h: Likewise.
* ipa-prop.c: Likewise.
* ipa-prop.h: Likewise.
* ipa-pure-const.c: Likewise.
* ipa-ref-inline.h: Likewise.
* ipa-ref.c: Likewise.
* ipa-ref.h: Likewise.
* ipa-reference.c: Likewise.
* ipa-split.c: Likewise.
* ipa-utils.c: Likewise.
* ipa-utils.h: Likewise.
* ipa.c: Likewise.
* ira-build.c: Likewise.
* ira-color.c: Likewise.
* ira-emit.c: Likewise.
* ira-int.h: Likewise.
* ira.c: Likewise.
* loop-invariant.c: Likewise.
* loop-unroll.c: Likewise.
* lower-subreg.c: Likewise.
* lra-lives.c: Likewise.
* lra.c: Likewise.
* lto-cgraph.c: Likewise.
* lto-section-out.c: Likewise.
* lto-streamer-in.c: Likewise.
* lto-streamer-out.c: Likewise.
* lto-streamer.h: Likewise.
* lto-symtab.c: Likewise.
* mcf.c: Likewise.
* modulo-sched.c: Likewise.
* omp-low.c: Likewise.
* opts-common.c: Likewise.
* opts-global.c: Likewise.
* opts.c: Likewise.
* opts.h: Likewise.
* passes.c: Likewise.
* predict.c: Likewise.
* print-tree.c: Likewise.
* profile.c: Likewise.
* profile.h: Likewise.
* read-rtl.c: Likewise.
* ree.c: Likewise.
* reg-stack.c: Likewise.
* regrename.c: Likewise.
* regrename.h: Likewise.
* reload.c: Likewise.
* reload.h: Likewise.
* reload1.c: Likewise.
* rtl.h: Likewise.
* sched-deps.c: Likewise.
* sched-int.h: Likewise.
* sdbout.c: Likewise.
* sel-sched-dump.c: Likewise.
* sel-sched-ir.c: Likewise.
* sel-sched-ir.h: Likewise.
* sel-sched.c: Likewise.
* sese.c: Likewise.
* sese.h: Likewise.
* statistics.h: Likewise.
* stmt.c: Likewise.
* stor-layout.c: Likewise.
* store-motion.c: Likewise.
* tlink.c: Likewise.
* toplev.c: Likewise.
* trans-mem.c: Likewise.
* tree-browser.c: Likewise.
* tree-call-cdce.c: Likewise.
* tree-cfg.c: Likewise.
* tree-cfgcleanup.c: Likewise.
* tree-chrec.c: Likewise.
* tree-chrec.h: Likewise.
* tree-complex.c: Likewise.
* tree-data-ref.c: Likewise.
* tree-data-ref.h: Likewise.
* tree-dfa.c: Likewise.
* tree-diagnostic.c: Likewise.
* tree-dump.c: Likewise.
* tree-eh.c: Likewise.
* tree-emutls.c: Likewise.
* tree-flow.h: Likewise.
* tree-if-conv.c: Likewise.
* tree-inline.c: Likewise.
* tree-inline.h: Likewise.
* tree-into-ssa.c: Likewise.
* tree-iterator.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-mudflap.c: Likewise.
* tree-optimize.c: Likewise.
* tree-outof-ssa.c: Likewise.
* tree-parloops.c: Likewise.
* tree-phinodes.c: Likewise.
* tree-predcom.c: Likewise.
* tree-pretty-print.c: Likewise.
* tree-scalar-evolution.c: Likewise.
* tree-sra.c: Likewise.
* tree-ssa-address.c: Likewise.
* tree-ssa-alias.c: Likewise.
* tree-ssa-ccp.c: Likewise.
* tree-ssa-coalesce.c: Likewise.
* tree-ssa-dce.c: Likewise.
* tree-ssa-dom.c: Likewise.
* tree-ssa-forwprop.c: Likewise.
* tree-ssa-live.c: Likewise.
* tree-ssa-live.h: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-operands.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-sccvn.h: Likewise.
* tree-ssa-strlen.c: Likewise.
* tree-ssa-structalias.c: Likewise.
* tree-ssa-tail-merge.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* tree-ssa-threadupdate.c: Likewise.
* tree-ssa-uncprop.c: Likewise.
* tree-ssa-uninit.c: Likewise.
* tree-ssa.c: Likewise.
* tree-ssanames.c: Likewise.
* tree-stdarg.c: Likewise.
* tree-streamer-in.c: Likewise.
* tree-streamer-out.c: Likewise.
* tree-streamer.c: Likewise.
* tree-streamer.h: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-generic.c: Likewise.
* tree-vect-loop-manip.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-patterns.c: Likewise.
* tree-vect-slp.c: Likewise.
* tree-vect-stmts.c: Likewise.
* tree-vectorizer.c: Likewise.
* tree-vectorizer.h: Likewise.
* tree-vrp.c: Likewise.
* tree.c: Likewise.
* tree.h: Likewise.
* value-prof.c: Likewise.
* value-prof.h: Likewise.
* var-tracking.c: Likewise.
* varasm.c: Likewise.
* varpool.c: Likewise.
* vmsdbgout.c: Likewise.
* config/bfin/bfin.c: Likewise.
* config/c6x/c6x.c: Likewise.
* config/darwin.c: Likewise.
* config/i386/i386.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/mep/mep.c: Likewise.
* config/mips/mips.c: Likewise.
* config/pa/pa.c: Likewise.
* config/rs6000/rs6000-c.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/rx/rx.c: Likewise.
* config/spu/spu-c.c: Likewise.
* config/vms/vms.c: Likewise.
* config/vxworks.c: Likewise.
* config/epiphany/resolve-sw-modes.c: Likewise.
From-SVN: r193595
2012-11-18 03:54:30 +01:00
|
|
|
stmts.release ();
|
2010-08-25 12:47:50 +02:00
|
|
|
|
|
|
|
return cfg_changed;
|
2007-01-22 12:11:00 +01:00
|
|
|
}
|
|
|
|
|
2011-05-24 20:02:22 +02:00
|
|
|
/* To evaluate powi(x,n), the floating point value x raised to the
|
|
|
|
constant integer exponent n, we use a hybrid algorithm that
|
|
|
|
combines the "window method" with look-up tables. For an
|
|
|
|
introduction to exponentiation algorithms and "addition chains",
|
|
|
|
see section 4.6.3, "Evaluation of Powers" of Donald E. Knuth,
|
|
|
|
"Seminumerical Algorithms", Vol. 2, "The Art of Computer Programming",
|
|
|
|
3rd Edition, 1998, and Daniel M. Gordon, "A Survey of Fast Exponentiation
|
|
|
|
Methods", Journal of Algorithms, Vol. 27, pp. 129-146, 1998. */
|
|
|
|
|
|
|
|
/* Provide a default value for POWI_MAX_MULTS, the maximum number of
|
|
|
|
multiplications to inline before calling the system library's pow
|
|
|
|
function. powi(x,n) requires at worst 2*bits(n)-2 multiplications,
|
|
|
|
so this default never requires calling pow, powf or powl. */
|
|
|
|
|
|
|
|
#ifndef POWI_MAX_MULTS
|
|
|
|
#define POWI_MAX_MULTS (2*HOST_BITS_PER_WIDE_INT-2)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The size of the "optimal power tree" lookup table. All
|
|
|
|
exponents less than this value are simply looked up in the
|
|
|
|
powi_table below. This threshold is also used to size the
|
|
|
|
cache of pseudo registers that hold intermediate results. */
|
|
|
|
#define POWI_TABLE_SIZE 256
|
|
|
|
|
|
|
|
/* The size, in bits of the window, used in the "window method"
|
|
|
|
exponentiation algorithm. This is equivalent to a radix of
|
|
|
|
(1<<POWI_WINDOW_SIZE) in the corresponding "m-ary method". */
|
|
|
|
#define POWI_WINDOW_SIZE 3
|
|
|
|
|
|
|
|
/* The following table is an efficient representation of an
|
|
|
|
"optimal power tree". For each value, i, the corresponding
|
|
|
|
value, j, in the table states than an optimal evaluation
|
|
|
|
sequence for calculating pow(x,i) can be found by evaluating
|
|
|
|
pow(x,j)*pow(x,i-j). An optimal power tree for the first
|
|
|
|
100 integers is given in Knuth's "Seminumerical algorithms". */
|
|
|
|
|
|
|
|
static const unsigned char powi_table[POWI_TABLE_SIZE] =
|
|
|
|
{
|
|
|
|
0, 1, 1, 2, 2, 3, 3, 4, /* 0 - 7 */
|
|
|
|
4, 6, 5, 6, 6, 10, 7, 9, /* 8 - 15 */
|
|
|
|
8, 16, 9, 16, 10, 12, 11, 13, /* 16 - 23 */
|
|
|
|
12, 17, 13, 18, 14, 24, 15, 26, /* 24 - 31 */
|
|
|
|
16, 17, 17, 19, 18, 33, 19, 26, /* 32 - 39 */
|
|
|
|
20, 25, 21, 40, 22, 27, 23, 44, /* 40 - 47 */
|
|
|
|
24, 32, 25, 34, 26, 29, 27, 44, /* 48 - 55 */
|
|
|
|
28, 31, 29, 34, 30, 60, 31, 36, /* 56 - 63 */
|
|
|
|
32, 64, 33, 34, 34, 46, 35, 37, /* 64 - 71 */
|
|
|
|
36, 65, 37, 50, 38, 48, 39, 69, /* 72 - 79 */
|
|
|
|
40, 49, 41, 43, 42, 51, 43, 58, /* 80 - 87 */
|
|
|
|
44, 64, 45, 47, 46, 59, 47, 76, /* 88 - 95 */
|
|
|
|
48, 65, 49, 66, 50, 67, 51, 66, /* 96 - 103 */
|
|
|
|
52, 70, 53, 74, 54, 104, 55, 74, /* 104 - 111 */
|
|
|
|
56, 64, 57, 69, 58, 78, 59, 68, /* 112 - 119 */
|
|
|
|
60, 61, 61, 80, 62, 75, 63, 68, /* 120 - 127 */
|
|
|
|
64, 65, 65, 128, 66, 129, 67, 90, /* 128 - 135 */
|
|
|
|
68, 73, 69, 131, 70, 94, 71, 88, /* 136 - 143 */
|
|
|
|
72, 128, 73, 98, 74, 132, 75, 121, /* 144 - 151 */
|
|
|
|
76, 102, 77, 124, 78, 132, 79, 106, /* 152 - 159 */
|
|
|
|
80, 97, 81, 160, 82, 99, 83, 134, /* 160 - 167 */
|
|
|
|
84, 86, 85, 95, 86, 160, 87, 100, /* 168 - 175 */
|
|
|
|
88, 113, 89, 98, 90, 107, 91, 122, /* 176 - 183 */
|
|
|
|
92, 111, 93, 102, 94, 126, 95, 150, /* 184 - 191 */
|
|
|
|
96, 128, 97, 130, 98, 133, 99, 195, /* 192 - 199 */
|
|
|
|
100, 128, 101, 123, 102, 164, 103, 138, /* 200 - 207 */
|
|
|
|
104, 145, 105, 146, 106, 109, 107, 149, /* 208 - 215 */
|
|
|
|
108, 200, 109, 146, 110, 170, 111, 157, /* 216 - 223 */
|
|
|
|
112, 128, 113, 130, 114, 182, 115, 132, /* 224 - 231 */
|
|
|
|
116, 200, 117, 132, 118, 158, 119, 206, /* 232 - 239 */
|
|
|
|
120, 240, 121, 162, 122, 147, 123, 152, /* 240 - 247 */
|
|
|
|
124, 166, 125, 214, 126, 138, 127, 153, /* 248 - 255 */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the number of multiplications required to calculate
|
|
|
|
powi(x,n) where n is less than POWI_TABLE_SIZE. This is a
|
|
|
|
subroutine of powi_cost. CACHE is an array indicating
|
|
|
|
which exponents have already been calculated. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
powi_lookup_cost (unsigned HOST_WIDE_INT n, bool *cache)
|
|
|
|
{
|
|
|
|
/* If we've already calculated this exponent, then this evaluation
|
|
|
|
doesn't require any additional multiplications. */
|
|
|
|
if (cache[n])
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
cache[n] = true;
|
|
|
|
return powi_lookup_cost (n - powi_table[n], cache)
|
|
|
|
+ powi_lookup_cost (powi_table[n], cache) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the number of multiplications required to calculate
|
|
|
|
powi(x,n) for an arbitrary x, given the exponent N. This
|
|
|
|
function needs to be kept in sync with powi_as_mults below. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
powi_cost (HOST_WIDE_INT n)
|
|
|
|
{
|
|
|
|
bool cache[POWI_TABLE_SIZE];
|
|
|
|
unsigned HOST_WIDE_INT digit;
|
|
|
|
unsigned HOST_WIDE_INT val;
|
|
|
|
int result;
|
|
|
|
|
|
|
|
if (n == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Ignore the reciprocal when calculating the cost. */
|
|
|
|
val = (n < 0) ? -n : n;
|
|
|
|
|
|
|
|
/* Initialize the exponent cache. */
|
|
|
|
memset (cache, 0, POWI_TABLE_SIZE * sizeof (bool));
|
|
|
|
cache[1] = true;
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
|
|
|
|
while (val >= POWI_TABLE_SIZE)
|
|
|
|
{
|
|
|
|
if (val & 1)
|
|
|
|
{
|
|
|
|
digit = val & ((1 << POWI_WINDOW_SIZE) - 1);
|
|
|
|
result += powi_lookup_cost (digit, cache)
|
|
|
|
+ POWI_WINDOW_SIZE + 1;
|
|
|
|
val >>= POWI_WINDOW_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
val >>= 1;
|
|
|
|
result++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result + powi_lookup_cost (val, cache);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Recursive subroutine of powi_as_mults. This function takes the
|
|
|
|
array, CACHE, of already calculated exponents and an exponent N and
|
|
|
|
returns a tree that corresponds to CACHE[1]**N, with type TYPE. */
|
|
|
|
|
|
|
|
static tree
|
|
|
|
powi_as_mults_1 (gimple_stmt_iterator *gsi, location_t loc, tree type,
|
2012-08-10 11:20:29 +02:00
|
|
|
HOST_WIDE_INT n, tree *cache)
|
2011-05-24 20:02:22 +02:00
|
|
|
{
|
|
|
|
tree op0, op1, ssa_target;
|
|
|
|
unsigned HOST_WIDE_INT digit;
|
|
|
|
gimple mult_stmt;
|
|
|
|
|
|
|
|
if (n < POWI_TABLE_SIZE && cache[n])
|
|
|
|
return cache[n];
|
|
|
|
|
2012-08-10 11:20:29 +02:00
|
|
|
ssa_target = make_temp_ssa_name (type, NULL, "powmult");
|
2011-05-24 20:02:22 +02:00
|
|
|
|
|
|
|
if (n < POWI_TABLE_SIZE)
|
|
|
|
{
|
|
|
|
cache[n] = ssa_target;
|
2012-08-10 11:20:29 +02:00
|
|
|
op0 = powi_as_mults_1 (gsi, loc, type, n - powi_table[n], cache);
|
|
|
|
op1 = powi_as_mults_1 (gsi, loc, type, powi_table[n], cache);
|
2011-05-24 20:02:22 +02:00
|
|
|
}
|
|
|
|
else if (n & 1)
|
|
|
|
{
|
|
|
|
digit = n & ((1 << POWI_WINDOW_SIZE) - 1);
|
2012-08-10 11:20:29 +02:00
|
|
|
op0 = powi_as_mults_1 (gsi, loc, type, n - digit, cache);
|
|
|
|
op1 = powi_as_mults_1 (gsi, loc, type, digit, cache);
|
2011-05-24 20:02:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-10 11:20:29 +02:00
|
|
|
op0 = powi_as_mults_1 (gsi, loc, type, n >> 1, cache);
|
2011-05-24 20:02:22 +02:00
|
|
|
op1 = op0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mult_stmt = gimple_build_assign_with_ops (MULT_EXPR, ssa_target, op0, op1);
|
2011-05-27 21:11:19 +02:00
|
|
|
gimple_set_location (mult_stmt, loc);
|
2011-05-24 20:02:22 +02:00
|
|
|
gsi_insert_before (gsi, mult_stmt, GSI_SAME_STMT);
|
|
|
|
|
|
|
|
return ssa_target;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert ARG0**N to a tree of multiplications of ARG0 with itself.
|
|
|
|
This function needs to be kept in sync with powi_cost above. */
|
|
|
|
|
|
|
|
static tree
|
|
|
|
powi_as_mults (gimple_stmt_iterator *gsi, location_t loc,
|
|
|
|
tree arg0, HOST_WIDE_INT n)
|
|
|
|
{
|
2012-08-10 11:20:29 +02:00
|
|
|
tree cache[POWI_TABLE_SIZE], result, type = TREE_TYPE (arg0);
|
2011-05-24 20:02:22 +02:00
|
|
|
gimple div_stmt;
|
2012-08-10 11:20:29 +02:00
|
|
|
tree target;
|
2011-05-24 20:02:22 +02:00
|
|
|
|
|
|
|
if (n == 0)
|
|
|
|
return build_real (type, dconst1);
|
|
|
|
|
|
|
|
memset (cache, 0, sizeof (cache));
|
|
|
|
cache[1] = arg0;
|
|
|
|
|
2012-08-10 11:20:29 +02:00
|
|
|
result = powi_as_mults_1 (gsi, loc, type, (n < 0) ? -n : n, cache);
|
2011-05-24 20:02:22 +02:00
|
|
|
if (n >= 0)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
/* If the original exponent was negative, reciprocate the result. */
|
2012-08-10 11:20:29 +02:00
|
|
|
target = make_temp_ssa_name (type, NULL, "powmult");
|
2011-05-24 20:02:22 +02:00
|
|
|
div_stmt = gimple_build_assign_with_ops (RDIV_EXPR, target,
|
|
|
|
build_real (type, dconst1),
|
|
|
|
result);
|
2011-05-27 21:11:19 +02:00
|
|
|
gimple_set_location (div_stmt, loc);
|
2011-05-24 20:02:22 +02:00
|
|
|
gsi_insert_before (gsi, div_stmt, GSI_SAME_STMT);
|
|
|
|
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ARG0 and N are the two arguments to a powi builtin in GSI with
|
|
|
|
location info LOC. If the arguments are appropriate, create an
|
|
|
|
equivalent sequence of statements prior to GSI using an optimal
|
|
|
|
number of multiplications, and return an expession holding the
|
|
|
|
result. */
|
|
|
|
|
|
|
|
static tree
|
|
|
|
gimple_expand_builtin_powi (gimple_stmt_iterator *gsi, location_t loc,
|
|
|
|
tree arg0, HOST_WIDE_INT n)
|
|
|
|
{
|
|
|
|
/* Avoid largest negative number. */
|
|
|
|
if (n != -n
|
|
|
|
&& ((n >= -1 && n <= 2)
|
|
|
|
|| (optimize_function_for_speed_p (cfun)
|
|
|
|
&& powi_cost (n) <= POWI_MAX_MULTS)))
|
|
|
|
return powi_as_mults (gsi, loc, arg0, n);
|
|
|
|
|
|
|
|
return NULL_TREE;
|
|
|
|
}
|
|
|
|
|
2011-05-27 21:11:19 +02:00
|
|
|
/* Build a gimple call statement that calls FN with argument ARG.
|
2012-08-10 11:20:29 +02:00
|
|
|
Set the lhs of the call statement to a fresh SSA name. Insert the
|
2011-05-27 21:11:19 +02:00
|
|
|
statement prior to GSI's current position, and return the fresh
|
|
|
|
SSA name. */
|
|
|
|
|
|
|
|
static tree
|
2011-05-30 19:12:53 +02:00
|
|
|
build_and_insert_call (gimple_stmt_iterator *gsi, location_t loc,
|
2012-08-10 11:20:29 +02:00
|
|
|
tree fn, tree arg)
|
2011-05-27 21:11:19 +02:00
|
|
|
{
|
|
|
|
gimple call_stmt;
|
|
|
|
tree ssa_target;
|
|
|
|
|
|
|
|
call_stmt = gimple_build_call (fn, 1, arg);
|
2012-08-10 11:20:29 +02:00
|
|
|
ssa_target = make_temp_ssa_name (TREE_TYPE (arg), NULL, "powroot");
|
2011-05-27 21:11:19 +02:00
|
|
|
gimple_set_lhs (call_stmt, ssa_target);
|
|
|
|
gimple_set_location (call_stmt, loc);
|
|
|
|
gsi_insert_before (gsi, call_stmt, GSI_SAME_STMT);
|
|
|
|
|
|
|
|
return ssa_target;
|
|
|
|
}
|
|
|
|
|
2011-05-30 19:12:53 +02:00
|
|
|
/* Build a gimple binary operation with the given CODE and arguments
|
|
|
|
ARG0, ARG1, assigning the result to a new SSA name for variable
|
|
|
|
TARGET. Insert the statement prior to GSI's current position, and
|
|
|
|
return the fresh SSA name.*/
|
|
|
|
|
|
|
|
static tree
|
|
|
|
build_and_insert_binop (gimple_stmt_iterator *gsi, location_t loc,
|
2012-08-10 11:20:29 +02:00
|
|
|
const char *name, enum tree_code code,
|
|
|
|
tree arg0, tree arg1)
|
2011-05-30 19:12:53 +02:00
|
|
|
{
|
2012-08-10 11:20:29 +02:00
|
|
|
tree result = make_temp_ssa_name (TREE_TYPE (arg0), NULL, name);
|
2011-05-30 19:12:53 +02:00
|
|
|
gimple stmt = gimple_build_assign_with_ops (code, result, arg0, arg1);
|
|
|
|
gimple_set_location (stmt, loc);
|
|
|
|
gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-06-10 17:28:46 +02:00
|
|
|
/* Build a gimple reference operation with the given CODE and argument
|
2012-08-10 11:20:29 +02:00
|
|
|
ARG, assigning the result to a new SSA name of TYPE with NAME.
|
2011-06-10 17:28:46 +02:00
|
|
|
Insert the statement prior to GSI's current position, and return
|
|
|
|
the fresh SSA name. */
|
|
|
|
|
|
|
|
static inline tree
|
|
|
|
build_and_insert_ref (gimple_stmt_iterator *gsi, location_t loc, tree type,
|
2012-08-10 11:20:29 +02:00
|
|
|
const char *name, enum tree_code code, tree arg0)
|
2011-06-10 17:28:46 +02:00
|
|
|
{
|
2012-08-10 11:20:29 +02:00
|
|
|
tree result = make_temp_ssa_name (type, NULL, name);
|
2011-06-10 17:28:46 +02:00
|
|
|
gimple stmt = gimple_build_assign (result, build1 (code, type, arg0));
|
|
|
|
gimple_set_location (stmt, loc);
|
|
|
|
gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-10 11:20:29 +02:00
|
|
|
/* Build a gimple assignment to cast VAL to TYPE. Insert the statement
|
2011-08-19 16:21:48 +02:00
|
|
|
prior to GSI's current position, and return the fresh SSA name. */
|
|
|
|
|
|
|
|
static tree
|
|
|
|
build_and_insert_cast (gimple_stmt_iterator *gsi, location_t loc,
|
2012-08-10 11:20:29 +02:00
|
|
|
tree type, tree val)
|
2011-08-19 16:21:48 +02:00
|
|
|
{
|
2012-08-10 11:20:29 +02:00
|
|
|
tree result = make_ssa_name (type, NULL);
|
|
|
|
gimple stmt = gimple_build_assign_with_ops (NOP_EXPR, result, val, NULL_TREE);
|
|
|
|
gimple_set_location (stmt, loc);
|
|
|
|
gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
|
|
|
|
return result;
|
2011-08-19 16:21:48 +02:00
|
|
|
}
|
|
|
|
|
2011-05-25 15:35:53 +02:00
|
|
|
/* ARG0 and ARG1 are the two arguments to a pow builtin call in GSI
|
|
|
|
with location info LOC. If possible, create an equivalent and
|
|
|
|
less expensive sequence of statements prior to GSI, and return an
|
|
|
|
expession holding the result. */
|
|
|
|
|
|
|
|
static tree
|
|
|
|
gimple_expand_builtin_pow (gimple_stmt_iterator *gsi, location_t loc,
|
|
|
|
tree arg0, tree arg1)
|
|
|
|
{
|
2011-05-27 21:11:19 +02:00
|
|
|
REAL_VALUE_TYPE c, cint, dconst1_4, dconst3_4, dconst1_3, dconst1_6;
|
2011-05-30 19:12:53 +02:00
|
|
|
REAL_VALUE_TYPE c2, dconst3;
|
2011-05-25 15:35:53 +02:00
|
|
|
HOST_WIDE_INT n;
|
2011-05-30 19:12:53 +02:00
|
|
|
tree type, sqrtfn, cbrtfn, sqrt_arg0, sqrt_sqrt, result, cbrt_x, powi_cbrt_x;
|
2011-05-27 21:11:19 +02:00
|
|
|
enum machine_mode mode;
|
2013-01-28 15:43:03 +01:00
|
|
|
bool hw_sqrt_exists, c_is_int, c2_is_int;
|
2011-05-25 15:35:53 +02:00
|
|
|
|
|
|
|
/* If the exponent isn't a constant, there's nothing of interest
|
|
|
|
to be done. */
|
|
|
|
if (TREE_CODE (arg1) != REAL_CST)
|
|
|
|
return NULL_TREE;
|
|
|
|
|
2011-05-27 21:11:19 +02:00
|
|
|
/* If the exponent is equivalent to an integer, expand to an optimal
|
|
|
|
multiplication sequence when profitable. */
|
2011-05-25 15:35:53 +02:00
|
|
|
c = TREE_REAL_CST (arg1);
|
|
|
|
n = real_to_integer (&c);
|
2014-05-06 18:25:05 +02:00
|
|
|
real_from_integer (&cint, VOIDmode, n, SIGNED);
|
2013-01-28 15:43:03 +01:00
|
|
|
c_is_int = real_identical (&c, &cint);
|
2011-05-25 15:35:53 +02:00
|
|
|
|
2013-01-28 15:43:03 +01:00
|
|
|
if (c_is_int
|
2011-05-25 15:35:53 +02:00
|
|
|
&& ((n >= -1 && n <= 2)
|
|
|
|
|| (flag_unsafe_math_optimizations
|
2014-04-14 13:48:22 +02:00
|
|
|
&& optimize_bb_for_speed_p (gsi_bb (*gsi))
|
2011-05-25 15:35:53 +02:00
|
|
|
&& powi_cost (n) <= POWI_MAX_MULTS)))
|
|
|
|
return gimple_expand_builtin_powi (gsi, loc, arg0, n);
|
|
|
|
|
2011-05-27 21:11:19 +02:00
|
|
|
/* Attempt various optimizations using sqrt and cbrt. */
|
|
|
|
type = TREE_TYPE (arg0);
|
|
|
|
mode = TYPE_MODE (type);
|
|
|
|
sqrtfn = mathfn_built_in (type, BUILT_IN_SQRT);
|
|
|
|
|
|
|
|
/* Optimize pow(x,0.5) = sqrt(x). This replacement is always safe
|
|
|
|
unless signed zeros must be maintained. pow(-0,0.5) = +0, while
|
|
|
|
sqrt(-0) = -0. */
|
|
|
|
if (sqrtfn
|
|
|
|
&& REAL_VALUES_EQUAL (c, dconsthalf)
|
|
|
|
&& !HONOR_SIGNED_ZEROS (mode))
|
2012-08-10 11:20:29 +02:00
|
|
|
return build_and_insert_call (gsi, loc, sqrtfn, arg0);
|
2011-05-27 21:11:19 +02:00
|
|
|
|
|
|
|
/* Optimize pow(x,0.25) = sqrt(sqrt(x)). Assume on most machines that
|
|
|
|
a builtin sqrt instruction is smaller than a call to pow with 0.25,
|
|
|
|
so do this optimization even if -Os. Don't do this optimization
|
|
|
|
if we don't have a hardware sqrt insn. */
|
|
|
|
dconst1_4 = dconst1;
|
|
|
|
SET_REAL_EXP (&dconst1_4, REAL_EXP (&dconst1_4) - 2);
|
2011-06-10 17:28:46 +02:00
|
|
|
hw_sqrt_exists = optab_handler (sqrt_optab, mode) != CODE_FOR_nothing;
|
2011-05-27 21:11:19 +02:00
|
|
|
|
|
|
|
if (flag_unsafe_math_optimizations
|
|
|
|
&& sqrtfn
|
|
|
|
&& REAL_VALUES_EQUAL (c, dconst1_4)
|
|
|
|
&& hw_sqrt_exists)
|
|
|
|
{
|
|
|
|
/* sqrt(x) */
|
2012-08-10 11:20:29 +02:00
|
|
|
sqrt_arg0 = build_and_insert_call (gsi, loc, sqrtfn, arg0);
|
2011-05-27 21:11:19 +02:00
|
|
|
|
|
|
|
/* sqrt(sqrt(x)) */
|
2012-08-10 11:20:29 +02:00
|
|
|
return build_and_insert_call (gsi, loc, sqrtfn, sqrt_arg0);
|
2011-05-27 21:11:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Optimize pow(x,0.75) = sqrt(x) * sqrt(sqrt(x)) unless we are
|
|
|
|
optimizing for space. Don't do this optimization if we don't have
|
|
|
|
a hardware sqrt insn. */
|
2014-05-06 18:25:05 +02:00
|
|
|
real_from_integer (&dconst3_4, VOIDmode, 3, SIGNED);
|
2011-05-27 21:11:19 +02:00
|
|
|
SET_REAL_EXP (&dconst3_4, REAL_EXP (&dconst3_4) - 2);
|
|
|
|
|
|
|
|
if (flag_unsafe_math_optimizations
|
|
|
|
&& sqrtfn
|
|
|
|
&& optimize_function_for_speed_p (cfun)
|
|
|
|
&& REAL_VALUES_EQUAL (c, dconst3_4)
|
|
|
|
&& hw_sqrt_exists)
|
|
|
|
{
|
|
|
|
/* sqrt(x) */
|
2012-08-10 11:20:29 +02:00
|
|
|
sqrt_arg0 = build_and_insert_call (gsi, loc, sqrtfn, arg0);
|
2011-05-27 21:11:19 +02:00
|
|
|
|
|
|
|
/* sqrt(sqrt(x)) */
|
2012-08-10 11:20:29 +02:00
|
|
|
sqrt_sqrt = build_and_insert_call (gsi, loc, sqrtfn, sqrt_arg0);
|
2011-05-27 21:11:19 +02:00
|
|
|
|
|
|
|
/* sqrt(x) * sqrt(sqrt(x)) */
|
2012-08-10 11:20:29 +02:00
|
|
|
return build_and_insert_binop (gsi, loc, "powroot", MULT_EXPR,
|
2011-05-30 19:12:53 +02:00
|
|
|
sqrt_arg0, sqrt_sqrt);
|
2011-05-27 21:11:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Optimize pow(x,1./3.) = cbrt(x). This requires unsafe math
|
|
|
|
optimizations since 1./3. is not exactly representable. If x
|
|
|
|
is negative and finite, the correct value of pow(x,1./3.) is
|
|
|
|
a NaN with the "invalid" exception raised, because the value
|
|
|
|
of 1./3. actually has an even denominator. The correct value
|
|
|
|
of cbrt(x) is a negative real value. */
|
|
|
|
cbrtfn = mathfn_built_in (type, BUILT_IN_CBRT);
|
|
|
|
dconst1_3 = real_value_truncate (mode, dconst_third ());
|
|
|
|
|
|
|
|
if (flag_unsafe_math_optimizations
|
|
|
|
&& cbrtfn
|
2011-06-07 17:12:04 +02:00
|
|
|
&& (gimple_val_nonnegative_real_p (arg0) || !HONOR_NANS (mode))
|
2011-05-27 21:11:19 +02:00
|
|
|
&& REAL_VALUES_EQUAL (c, dconst1_3))
|
2012-08-10 11:20:29 +02:00
|
|
|
return build_and_insert_call (gsi, loc, cbrtfn, arg0);
|
2011-05-27 21:11:19 +02:00
|
|
|
|
|
|
|
/* Optimize pow(x,1./6.) = cbrt(sqrt(x)). Don't do this optimization
|
|
|
|
if we don't have a hardware sqrt insn. */
|
|
|
|
dconst1_6 = dconst1_3;
|
|
|
|
SET_REAL_EXP (&dconst1_6, REAL_EXP (&dconst1_6) - 1);
|
|
|
|
|
|
|
|
if (flag_unsafe_math_optimizations
|
|
|
|
&& sqrtfn
|
|
|
|
&& cbrtfn
|
2011-06-07 17:12:04 +02:00
|
|
|
&& (gimple_val_nonnegative_real_p (arg0) || !HONOR_NANS (mode))
|
2011-05-27 21:11:19 +02:00
|
|
|
&& optimize_function_for_speed_p (cfun)
|
|
|
|
&& hw_sqrt_exists
|
|
|
|
&& REAL_VALUES_EQUAL (c, dconst1_6))
|
|
|
|
{
|
|
|
|
/* sqrt(x) */
|
2012-08-10 11:20:29 +02:00
|
|
|
sqrt_arg0 = build_and_insert_call (gsi, loc, sqrtfn, arg0);
|
2011-05-27 21:11:19 +02:00
|
|
|
|
|
|
|
/* cbrt(sqrt(x)) */
|
2012-08-10 11:20:29 +02:00
|
|
|
return build_and_insert_call (gsi, loc, cbrtfn, sqrt_arg0);
|
2011-05-30 19:12:53 +02:00
|
|
|
}
|
|
|
|
|
2013-01-28 15:43:03 +01:00
|
|
|
/* Optimize pow(x,c), where n = 2c for some nonzero integer n
|
|
|
|
and c not an integer, into
|
2011-05-30 19:12:53 +02:00
|
|
|
|
|
|
|
sqrt(x) * powi(x, n/2), n > 0;
|
|
|
|
1.0 / (sqrt(x) * powi(x, abs(n/2))), n < 0.
|
|
|
|
|
|
|
|
Do not calculate the powi factor when n/2 = 0. */
|
|
|
|
real_arithmetic (&c2, MULT_EXPR, &c, &dconst2);
|
|
|
|
n = real_to_integer (&c2);
|
2014-05-06 18:25:05 +02:00
|
|
|
real_from_integer (&cint, VOIDmode, n, SIGNED);
|
2013-01-28 15:43:03 +01:00
|
|
|
c2_is_int = real_identical (&c2, &cint);
|
2011-05-30 19:12:53 +02:00
|
|
|
|
|
|
|
if (flag_unsafe_math_optimizations
|
|
|
|
&& sqrtfn
|
2013-01-28 15:43:03 +01:00
|
|
|
&& c2_is_int
|
|
|
|
&& !c_is_int
|
|
|
|
&& optimize_function_for_speed_p (cfun))
|
2011-05-30 19:12:53 +02:00
|
|
|
{
|
|
|
|
tree powi_x_ndiv2 = NULL_TREE;
|
|
|
|
|
|
|
|
/* Attempt to fold powi(arg0, abs(n/2)) into multiplies. If not
|
|
|
|
possible or profitable, give up. Skip the degenerate case when
|
|
|
|
n is 1 or -1, where the result is always 1. */
|
2011-08-18 13:30:42 +02:00
|
|
|
if (absu_hwi (n) != 1)
|
2011-05-30 19:12:53 +02:00
|
|
|
{
|
2011-08-02 22:26:57 +02:00
|
|
|
powi_x_ndiv2 = gimple_expand_builtin_powi (gsi, loc, arg0,
|
|
|
|
abs_hwi (n / 2));
|
2011-05-30 19:12:53 +02:00
|
|
|
if (!powi_x_ndiv2)
|
|
|
|
return NULL_TREE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate sqrt(x). When n is not 1 or -1, multiply it by the
|
|
|
|
result of the optimal multiply sequence just calculated. */
|
2012-08-10 11:20:29 +02:00
|
|
|
sqrt_arg0 = build_and_insert_call (gsi, loc, sqrtfn, arg0);
|
2011-05-30 19:12:53 +02:00
|
|
|
|
2011-08-18 13:30:42 +02:00
|
|
|
if (absu_hwi (n) == 1)
|
2011-05-30 19:12:53 +02:00
|
|
|
result = sqrt_arg0;
|
|
|
|
else
|
2012-08-10 11:20:29 +02:00
|
|
|
result = build_and_insert_binop (gsi, loc, "powroot", MULT_EXPR,
|
2011-05-30 19:12:53 +02:00
|
|
|
sqrt_arg0, powi_x_ndiv2);
|
|
|
|
|
|
|
|
/* If n is negative, reciprocate the result. */
|
|
|
|
if (n < 0)
|
2012-08-10 11:20:29 +02:00
|
|
|
result = build_and_insert_binop (gsi, loc, "powroot", RDIV_EXPR,
|
2011-05-30 19:12:53 +02:00
|
|
|
build_real (type, dconst1), result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Optimize pow(x,c), where 3c = n for some nonzero integer n, into
|
|
|
|
|
|
|
|
powi(x, n/3) * powi(cbrt(x), n%3), n > 0;
|
|
|
|
1.0 / (powi(x, abs(n)/3) * powi(cbrt(x), abs(n)%3)), n < 0.
|
|
|
|
|
|
|
|
Do not calculate the first factor when n/3 = 0. As cbrt(x) is
|
|
|
|
different from pow(x, 1./3.) due to rounding and behavior with
|
|
|
|
negative x, we need to constrain this transformation to unsafe
|
|
|
|
math and positive x or finite math. */
|
2014-05-06 18:25:05 +02:00
|
|
|
real_from_integer (&dconst3, VOIDmode, 3, SIGNED);
|
2011-05-30 19:12:53 +02:00
|
|
|
real_arithmetic (&c2, MULT_EXPR, &c, &dconst3);
|
|
|
|
real_round (&c2, mode, &c2);
|
|
|
|
n = real_to_integer (&c2);
|
2014-05-06 18:25:05 +02:00
|
|
|
real_from_integer (&cint, VOIDmode, n, SIGNED);
|
2011-05-30 19:12:53 +02:00
|
|
|
real_arithmetic (&c2, RDIV_EXPR, &cint, &dconst3);
|
|
|
|
real_convert (&c2, mode, &c2);
|
|
|
|
|
|
|
|
if (flag_unsafe_math_optimizations
|
|
|
|
&& cbrtfn
|
2011-06-07 17:12:04 +02:00
|
|
|
&& (gimple_val_nonnegative_real_p (arg0) || !HONOR_NANS (mode))
|
2011-05-30 19:12:53 +02:00
|
|
|
&& real_identical (&c2, &c)
|
2013-01-28 15:43:03 +01:00
|
|
|
&& !c2_is_int
|
2011-05-30 19:12:53 +02:00
|
|
|
&& optimize_function_for_speed_p (cfun)
|
|
|
|
&& powi_cost (n / 3) <= POWI_MAX_MULTS)
|
|
|
|
{
|
|
|
|
tree powi_x_ndiv3 = NULL_TREE;
|
|
|
|
|
|
|
|
/* Attempt to fold powi(arg0, abs(n/3)) into multiplies. If not
|
|
|
|
possible or profitable, give up. Skip the degenerate case when
|
|
|
|
abs(n) < 3, where the result is always 1. */
|
2011-08-18 13:30:42 +02:00
|
|
|
if (absu_hwi (n) >= 3)
|
2011-05-30 19:12:53 +02:00
|
|
|
{
|
|
|
|
powi_x_ndiv3 = gimple_expand_builtin_powi (gsi, loc, arg0,
|
2011-08-02 22:26:57 +02:00
|
|
|
abs_hwi (n / 3));
|
2011-05-30 19:12:53 +02:00
|
|
|
if (!powi_x_ndiv3)
|
|
|
|
return NULL_TREE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate powi(cbrt(x), n%3). Don't use gimple_expand_builtin_powi
|
|
|
|
as that creates an unnecessary variable. Instead, just produce
|
|
|
|
either cbrt(x) or cbrt(x) * cbrt(x). */
|
2012-08-10 11:20:29 +02:00
|
|
|
cbrt_x = build_and_insert_call (gsi, loc, cbrtfn, arg0);
|
2011-05-30 19:12:53 +02:00
|
|
|
|
2011-08-18 13:30:42 +02:00
|
|
|
if (absu_hwi (n) % 3 == 1)
|
2011-05-30 19:12:53 +02:00
|
|
|
powi_cbrt_x = cbrt_x;
|
|
|
|
else
|
2012-08-10 11:20:29 +02:00
|
|
|
powi_cbrt_x = build_and_insert_binop (gsi, loc, "powroot", MULT_EXPR,
|
2011-05-30 19:12:53 +02:00
|
|
|
cbrt_x, cbrt_x);
|
|
|
|
|
|
|
|
/* Multiply the two subexpressions, unless powi(x,abs(n)/3) = 1. */
|
2011-08-18 13:30:42 +02:00
|
|
|
if (absu_hwi (n) < 3)
|
2011-05-30 19:12:53 +02:00
|
|
|
result = powi_cbrt_x;
|
|
|
|
else
|
2012-08-10 11:20:29 +02:00
|
|
|
result = build_and_insert_binop (gsi, loc, "powroot", MULT_EXPR,
|
2011-05-30 19:12:53 +02:00
|
|
|
powi_x_ndiv3, powi_cbrt_x);
|
|
|
|
|
|
|
|
/* If n is negative, reciprocate the result. */
|
|
|
|
if (n < 0)
|
2012-08-10 11:20:29 +02:00
|
|
|
result = build_and_insert_binop (gsi, loc, "powroot", RDIV_EXPR,
|
2011-05-30 19:12:53 +02:00
|
|
|
build_real (type, dconst1), result);
|
|
|
|
|
|
|
|
return result;
|
2011-05-27 21:11:19 +02:00
|
|
|
}
|
|
|
|
|
2011-05-30 19:12:53 +02:00
|
|
|
/* No optimizations succeeded. */
|
2011-05-25 15:35:53 +02:00
|
|
|
return NULL_TREE;
|
|
|
|
}
|
|
|
|
|
2011-06-10 17:28:46 +02:00
|
|
|
/* ARG is the argument to a cabs builtin call in GSI with location info
|
|
|
|
LOC. Create a sequence of statements prior to GSI that calculates
|
|
|
|
sqrt(R*R + I*I), where R and I are the real and imaginary components
|
|
|
|
of ARG, respectively. Return an expression holding the result. */
|
|
|
|
|
|
|
|
static tree
|
|
|
|
gimple_expand_builtin_cabs (gimple_stmt_iterator *gsi, location_t loc, tree arg)
|
|
|
|
{
|
2012-08-10 11:20:29 +02:00
|
|
|
tree real_part, imag_part, addend1, addend2, sum, result;
|
2011-06-10 17:28:46 +02:00
|
|
|
tree type = TREE_TYPE (TREE_TYPE (arg));
|
|
|
|
tree sqrtfn = mathfn_built_in (type, BUILT_IN_SQRT);
|
|
|
|
enum machine_mode mode = TYPE_MODE (type);
|
|
|
|
|
|
|
|
if (!flag_unsafe_math_optimizations
|
|
|
|
|| !optimize_bb_for_speed_p (gimple_bb (gsi_stmt (*gsi)))
|
|
|
|
|| !sqrtfn
|
|
|
|
|| optab_handler (sqrt_optab, mode) == CODE_FOR_nothing)
|
|
|
|
return NULL_TREE;
|
|
|
|
|
2012-08-10 11:20:29 +02:00
|
|
|
real_part = build_and_insert_ref (gsi, loc, type, "cabs",
|
2011-06-10 17:28:46 +02:00
|
|
|
REALPART_EXPR, arg);
|
2012-08-10 11:20:29 +02:00
|
|
|
addend1 = build_and_insert_binop (gsi, loc, "cabs", MULT_EXPR,
|
2011-06-10 17:28:46 +02:00
|
|
|
real_part, real_part);
|
2012-08-10 11:20:29 +02:00
|
|
|
imag_part = build_and_insert_ref (gsi, loc, type, "cabs",
|
2011-06-10 17:28:46 +02:00
|
|
|
IMAGPART_EXPR, arg);
|
2012-08-10 11:20:29 +02:00
|
|
|
addend2 = build_and_insert_binop (gsi, loc, "cabs", MULT_EXPR,
|
2011-06-10 17:28:46 +02:00
|
|
|
imag_part, imag_part);
|
2012-08-10 11:20:29 +02:00
|
|
|
sum = build_and_insert_binop (gsi, loc, "cabs", PLUS_EXPR, addend1, addend2);
|
|
|
|
result = build_and_insert_call (gsi, loc, sqrtfn, sum);
|
2011-06-10 17:28:46 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-01-22 12:11:00 +01:00
|
|
|
/* Go through all calls to sin, cos and cexpi and call execute_cse_sincos_1
|
2011-05-24 20:02:22 +02:00
|
|
|
on the SSA_NAME argument of each of them. Also expand powi(x,n) into
|
|
|
|
an optimal number of multiplies, when n is a constant. */
|
2007-01-22 12:11:00 +01:00
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
const pass_data pass_data_cse_sincos =
|
|
|
|
{
|
|
|
|
GIMPLE_PASS, /* type */
|
|
|
|
"sincos", /* name */
|
|
|
|
OPTGROUP_NONE, /* optinfo_flags */
|
|
|
|
TV_NONE, /* tv_id */
|
|
|
|
PROP_ssa, /* properties_required */
|
|
|
|
0, /* properties_provided */
|
|
|
|
0, /* properties_destroyed */
|
|
|
|
0, /* todo_flags_start */
|
2014-05-06 15:35:40 +02:00
|
|
|
TODO_update_ssa, /* todo_flags_finish */
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class pass_cse_sincos : public gimple_opt_pass
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
pass_cse_sincos (gcc::context *ctxt)
|
|
|
|
: gimple_opt_pass (pass_data_cse_sincos, ctxt)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/* opt_pass methods: */
|
|
|
|
virtual bool gate (function *)
|
|
|
|
{
|
|
|
|
/* We no longer require either sincos or cexp, since powi expansion
|
|
|
|
piggybacks on this pass. */
|
|
|
|
return optimize;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual unsigned int execute (function *);
|
|
|
|
|
|
|
|
}; // class pass_cse_sincos
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
pass_cse_sincos::execute (function *fun)
|
2007-01-22 12:11:00 +01:00
|
|
|
{
|
|
|
|
basic_block bb;
|
2010-08-25 12:47:50 +02:00
|
|
|
bool cfg_changed = false;
|
2007-01-22 12:11:00 +01:00
|
|
|
|
|
|
|
calculate_dominance_info (CDI_DOMINATORS);
|
2011-04-13 21:39:02 +02:00
|
|
|
memset (&sincos_stats, 0, sizeof (sincos_stats));
|
2007-01-22 12:11:00 +01:00
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
FOR_EACH_BB_FN (bb, fun)
|
2007-01-22 12:11:00 +01:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple_stmt_iterator gsi;
|
2012-09-17 11:18:35 +02:00
|
|
|
bool cleanup_eh = false;
|
2007-01-22 12:11:00 +01:00
|
|
|
|
2008-07-28 16:33:56 +02:00
|
|
|
for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
2007-01-22 12:11:00 +01:00
|
|
|
{
|
2008-07-28 16:33:56 +02:00
|
|
|
gimple stmt = gsi_stmt (gsi);
|
2007-01-22 12:11:00 +01:00
|
|
|
tree fndecl;
|
|
|
|
|
2012-09-17 11:18:35 +02:00
|
|
|
/* Only the last stmt in a bb could throw, no need to call
|
|
|
|
gimple_purge_dead_eh_edges if we change something in the middle
|
|
|
|
of a basic block. */
|
|
|
|
cleanup_eh = false;
|
|
|
|
|
2008-07-28 16:33:56 +02:00
|
|
|
if (is_gimple_call (stmt)
|
|
|
|
&& gimple_call_lhs (stmt)
|
|
|
|
&& (fndecl = gimple_call_fndecl (stmt))
|
2007-01-22 12:11:00 +01:00
|
|
|
&& DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
|
|
|
|
{
|
2011-05-24 20:02:22 +02:00
|
|
|
tree arg, arg0, arg1, result;
|
|
|
|
HOST_WIDE_INT n;
|
|
|
|
location_t loc;
|
2007-01-22 12:11:00 +01:00
|
|
|
|
|
|
|
switch (DECL_FUNCTION_CODE (fndecl))
|
|
|
|
{
|
|
|
|
CASE_FLT_FN (BUILT_IN_COS):
|
|
|
|
CASE_FLT_FN (BUILT_IN_SIN):
|
|
|
|
CASE_FLT_FN (BUILT_IN_CEXPI):
|
2011-05-27 15:29:57 +02:00
|
|
|
/* Make sure we have either sincos or cexp. */
|
2013-08-19 14:21:26 +02:00
|
|
|
if (!targetm.libc_has_function (function_c99_math_complex)
|
|
|
|
&& !targetm.libc_has_function (function_sincos))
|
2011-05-27 15:29:57 +02:00
|
|
|
break;
|
|
|
|
|
2008-07-28 16:33:56 +02:00
|
|
|
arg = gimple_call_arg (stmt, 0);
|
2007-01-22 12:11:00 +01:00
|
|
|
if (TREE_CODE (arg) == SSA_NAME)
|
2010-08-25 12:47:50 +02:00
|
|
|
cfg_changed |= execute_cse_sincos_1 (arg);
|
2007-01-22 12:11:00 +01:00
|
|
|
break;
|
|
|
|
|
2011-05-25 15:35:53 +02:00
|
|
|
CASE_FLT_FN (BUILT_IN_POW):
|
|
|
|
arg0 = gimple_call_arg (stmt, 0);
|
|
|
|
arg1 = gimple_call_arg (stmt, 1);
|
|
|
|
|
|
|
|
loc = gimple_location (stmt);
|
|
|
|
result = gimple_expand_builtin_pow (&gsi, loc, arg0, arg1);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
tree lhs = gimple_get_lhs (stmt);
|
|
|
|
gimple new_stmt = gimple_build_assign (lhs, result);
|
|
|
|
gimple_set_location (new_stmt, loc);
|
|
|
|
unlink_stmt_vdef (stmt);
|
|
|
|
gsi_replace (&gsi, new_stmt, true);
|
2012-09-17 11:18:35 +02:00
|
|
|
cleanup_eh = true;
|
2012-04-05 11:45:18 +02:00
|
|
|
if (gimple_vdef (stmt))
|
|
|
|
release_ssa_name (gimple_vdef (stmt));
|
2011-05-25 15:35:53 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-05-24 20:02:22 +02:00
|
|
|
CASE_FLT_FN (BUILT_IN_POWI):
|
|
|
|
arg0 = gimple_call_arg (stmt, 0);
|
|
|
|
arg1 = gimple_call_arg (stmt, 1);
|
|
|
|
loc = gimple_location (stmt);
|
2013-05-30 23:32:53 +02:00
|
|
|
|
2013-05-31 12:18:40 +02:00
|
|
|
if (real_minus_onep (arg0))
|
2013-05-30 23:32:53 +02:00
|
|
|
{
|
|
|
|
tree t0, t1, cond, one, minus_one;
|
|
|
|
gimple stmt;
|
|
|
|
|
|
|
|
t0 = TREE_TYPE (arg0);
|
|
|
|
t1 = TREE_TYPE (arg1);
|
|
|
|
one = build_real (t0, dconst1);
|
|
|
|
minus_one = build_real (t0, dconstm1);
|
|
|
|
|
|
|
|
cond = make_temp_ssa_name (t1, NULL, "powi_cond");
|
|
|
|
stmt = gimple_build_assign_with_ops (BIT_AND_EXPR, cond,
|
|
|
|
arg1,
|
|
|
|
build_int_cst (t1,
|
|
|
|
1));
|
|
|
|
gimple_set_location (stmt, loc);
|
|
|
|
gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
|
|
|
|
|
|
|
|
result = make_temp_ssa_name (t0, NULL, "powi");
|
|
|
|
stmt = gimple_build_assign_with_ops (COND_EXPR, result,
|
|
|
|
cond,
|
|
|
|
minus_one, one);
|
|
|
|
gimple_set_location (stmt, loc);
|
|
|
|
gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
cuintp.c: Replace host_integerp (..., 0) with tree_fits_shwi_p throughout.
gcc/ada/
* gcc-interface/cuintp.c: Replace host_integerp (..., 0) with
tree_fits_shwi_p throughout.
gcc/c-family/
* c-ada-spec.c, c-common.c, c-format.c, c-pretty-print.c: Replace
host_integerp (..., 0) with tree_fits_shwi_p throughout.
gcc/c/
* c-parser.c: Replace host_integerp (..., 0) with tree_fits_shwi_p
throughout.
gcc/cp/
* error.c, init.c, parser.c, semantics.c: Replace
host_integerp (..., 0) with tree_fits_shwi_p throughout.
gcc/go/
* gofrontend/expressions.cc: Replace host_integerp (..., 0) with
tree_fits_shwi_p throughout.
gcc/java/
* class.c, expr.c: Replace host_integerp (..., 0) with
tree_fits_shwi_p throughout.
gcc/
* builtins.c, config/alpha/alpha.c, config/c6x/predicates.md,
config/ia64/predicates.md, config/iq2000/iq2000.c, config/mips/mips.c,
config/s390/s390.c, dbxout.c, dwarf2out.c, except.c, explow.c, expr.c,
expr.h, fold-const.c, gimple-fold.c, gimple-ssa-strength-reduction.c,
gimple.c, godump.c, graphite-scop-detection.c, graphite-sese-to-poly.c,
omp-low.c, predict.c, rtlanal.c, sdbout.c, simplify-rtx.c,
stor-layout.c, tree-data-ref.c, tree-dfa.c, tree-pretty-print.c,
tree-sra.c, tree-ssa-alias.c, tree-ssa-forwprop.c,
tree-ssa-loop-ivopts.c, tree-ssa-loop-prefetch.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-reassoc.c, tree-ssa-sccvn.c,
tree-ssa-strlen.c, tree-ssa-structalias.c, tree-vect-data-refs.c,
tree-vect-patterns.c, tree-vectorizer.h, tree.c, var-tracking.c,
varasm.c: Replace host_integerp (..., 0) with tree_fits_shwi_p
throughout.
From-SVN: r204955
2013-11-18 15:51:10 +01:00
|
|
|
if (!tree_fits_shwi_p (arg1))
|
2013-06-01 10:39:59 +02:00
|
|
|
break;
|
|
|
|
|
2013-11-20 12:57:27 +01:00
|
|
|
n = tree_to_shwi (arg1);
|
2013-05-30 23:32:53 +02:00
|
|
|
result = gimple_expand_builtin_powi (&gsi, loc, arg0, n);
|
|
|
|
}
|
2011-05-24 20:02:22 +02:00
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
tree lhs = gimple_get_lhs (stmt);
|
|
|
|
gimple new_stmt = gimple_build_assign (lhs, result);
|
|
|
|
gimple_set_location (new_stmt, loc);
|
2011-06-10 17:28:46 +02:00
|
|
|
unlink_stmt_vdef (stmt);
|
|
|
|
gsi_replace (&gsi, new_stmt, true);
|
2012-09-17 11:18:35 +02:00
|
|
|
cleanup_eh = true;
|
2012-04-05 11:45:18 +02:00
|
|
|
if (gimple_vdef (stmt))
|
|
|
|
release_ssa_name (gimple_vdef (stmt));
|
2011-06-10 17:28:46 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_FLT_FN (BUILT_IN_CABS):
|
|
|
|
arg0 = gimple_call_arg (stmt, 0);
|
|
|
|
loc = gimple_location (stmt);
|
|
|
|
result = gimple_expand_builtin_cabs (&gsi, loc, arg0);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
tree lhs = gimple_get_lhs (stmt);
|
|
|
|
gimple new_stmt = gimple_build_assign (lhs, result);
|
|
|
|
gimple_set_location (new_stmt, loc);
|
2011-05-24 20:02:22 +02:00
|
|
|
unlink_stmt_vdef (stmt);
|
|
|
|
gsi_replace (&gsi, new_stmt, true);
|
2012-09-17 11:18:35 +02:00
|
|
|
cleanup_eh = true;
|
2012-04-05 11:45:18 +02:00
|
|
|
if (gimple_vdef (stmt))
|
|
|
|
release_ssa_name (gimple_vdef (stmt));
|
2011-05-24 20:02:22 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-01-22 12:11:00 +01:00
|
|
|
default:;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-17 11:18:35 +02:00
|
|
|
if (cleanup_eh)
|
|
|
|
cfg_changed |= gimple_purge_dead_eh_edges (bb);
|
2007-01-22 12:11:00 +01:00
|
|
|
}
|
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
statistics_counter_event (fun, "sincos statements inserted",
|
2011-04-13 21:39:02 +02:00
|
|
|
sincos_stats.inserted);
|
|
|
|
|
2007-01-22 12:11:00 +01:00
|
|
|
free_dominance_info (CDI_DOMINATORS);
|
2010-08-25 12:47:50 +02:00
|
|
|
return cfg_changed ? TODO_cleanup_cfg : 0;
|
2007-01-22 12:11:00 +01:00
|
|
|
}
|
|
|
|
|
2013-08-05 22:16:05 +02:00
|
|
|
} // anon namespace
|
|
|
|
|
|
|
|
gimple_opt_pass *
|
|
|
|
make_pass_cse_sincos (gcc::context *ctxt)
|
|
|
|
{
|
|
|
|
return new pass_cse_sincos (ctxt);
|
|
|
|
}
|
|
|
|
|
2009-06-14 16:45:32 +02:00
|
|
|
/* A symbolic number is used to detect byte permutation and selection
|
|
|
|
patterns. Therefore the field N contains an artificial number
|
|
|
|
consisting of byte size markers:
|
|
|
|
|
|
|
|
0 - byte has the value 0
|
|
|
|
1..size - byte contains the content of the byte
|
2014-05-23 05:33:28 +02:00
|
|
|
number indexed with that value minus one.
|
|
|
|
|
|
|
|
To detect permutations on memory sources (arrays and structures), a symbolic
|
|
|
|
number is also associated a base address (the array or structure the load is
|
|
|
|
made from), an offset from the base address and a range which gives the
|
|
|
|
difference between the highest and lowest accessed memory location to make
|
|
|
|
such a symbolic number. The range is thus different from size which reflects
|
|
|
|
the size of the type of current expression. Note that for non memory source,
|
|
|
|
range holds the same value as size.
|
|
|
|
|
|
|
|
For instance, for an array char a[], (short) a[0] | (short) a[3] would have
|
|
|
|
a size of 2 but a range of 4 while (short) a[0] | ((short) a[0] << 1) would
|
|
|
|
still have a size of 2 but this time a range of 1. */
|
2009-06-14 16:45:32 +02:00
|
|
|
|
|
|
|
struct symbolic_number {
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
uint64_t n;
|
2014-06-11 12:04:33 +02:00
|
|
|
tree type;
|
2014-05-23 05:33:28 +02:00
|
|
|
tree base_addr;
|
|
|
|
tree offset;
|
|
|
|
HOST_WIDE_INT bytepos;
|
|
|
|
tree alias_set;
|
|
|
|
tree vuse;
|
|
|
|
unsigned HOST_WIDE_INT range;
|
2009-06-14 16:45:32 +02:00
|
|
|
};
|
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
/* The number which the find_bswap_or_nop_1 result should match in
|
|
|
|
order to have a nop. The number is masked according to the size of
|
|
|
|
the symbolic number before using it. */
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
#define CMPNOP (sizeof (int64_t) < 8 ? 0 : \
|
|
|
|
(uint64_t)0x08070605 << 32 | 0x04030201)
|
2014-05-23 05:33:28 +02:00
|
|
|
|
|
|
|
/* The number which the find_bswap_or_nop_1 result should match in
|
|
|
|
order to have a byte swap. The number is masked according to the
|
|
|
|
size of the symbolic number before using it. */
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
#define CMPXCHG (sizeof (int64_t) < 8 ? 0 : \
|
|
|
|
(uint64_t)0x01020304 << 32 | 0x05060708)
|
2014-05-23 05:33:28 +02:00
|
|
|
|
2009-06-14 16:45:32 +02:00
|
|
|
/* Perform a SHIFT or ROTATE operation by COUNT bits on symbolic
|
|
|
|
number N. Return false if the requested operation is not permitted
|
|
|
|
on a symbolic number. */
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
do_shift_rotate (enum tree_code code,
|
|
|
|
struct symbolic_number *n,
|
|
|
|
int count)
|
|
|
|
{
|
2014-06-11 12:04:33 +02:00
|
|
|
int bitsize = TYPE_PRECISION (n->type);
|
|
|
|
|
2009-06-14 16:45:32 +02:00
|
|
|
if (count % 8 != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Zero out the extra bits of N in order to avoid them being shifted
|
|
|
|
into the significant bits. */
|
2014-06-11 12:04:33 +02:00
|
|
|
if (bitsize < 8 * (int)sizeof (int64_t))
|
|
|
|
n->n &= ((uint64_t)1 << bitsize) - 1;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
|
|
|
switch (code)
|
|
|
|
{
|
|
|
|
case LSHIFT_EXPR:
|
|
|
|
n->n <<= count;
|
|
|
|
break;
|
|
|
|
case RSHIFT_EXPR:
|
2014-06-11 12:04:33 +02:00
|
|
|
/* Arithmetic shift of signed type: result is dependent on the value. */
|
2014-06-20 08:30:19 +02:00
|
|
|
if (!TYPE_UNSIGNED (n->type)
|
|
|
|
&& (n->n & ((uint64_t) 0xff << (bitsize - 8))))
|
2014-06-11 12:04:33 +02:00
|
|
|
return false;
|
2009-06-14 16:45:32 +02:00
|
|
|
n->n >>= count;
|
|
|
|
break;
|
|
|
|
case LROTATE_EXPR:
|
2014-06-11 12:04:33 +02:00
|
|
|
n->n = (n->n << count) | (n->n >> (bitsize - count));
|
2009-06-14 16:45:32 +02:00
|
|
|
break;
|
|
|
|
case RROTATE_EXPR:
|
2014-06-11 12:04:33 +02:00
|
|
|
n->n = (n->n >> count) | (n->n << (bitsize - count));
|
2009-06-14 16:45:32 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2011-06-27 15:44:52 +02:00
|
|
|
/* Zero unused bits for size. */
|
2014-06-11 12:04:33 +02:00
|
|
|
if (bitsize < 8 * (int)sizeof (int64_t))
|
|
|
|
n->n &= ((uint64_t)1 << bitsize) - 1;
|
2009-06-14 16:45:32 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform sanity checking for the symbolic number N and the gimple
|
|
|
|
statement STMT. */
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
verify_symbolic_number_p (struct symbolic_number *n, gimple stmt)
|
|
|
|
{
|
|
|
|
tree lhs_type;
|
|
|
|
|
|
|
|
lhs_type = gimple_expr_type (stmt);
|
|
|
|
|
|
|
|
if (TREE_CODE (lhs_type) != INTEGER_TYPE)
|
|
|
|
return false;
|
|
|
|
|
2014-06-11 12:04:33 +02:00
|
|
|
if (TYPE_PRECISION (lhs_type) != TYPE_PRECISION (n->type))
|
2009-06-14 16:45:32 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-03 11:29:06 +02:00
|
|
|
/* Initialize the symbolic number N for the bswap pass from the base element
|
|
|
|
SRC manipulated by the bitwise OR expression. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
init_symbolic_number (struct symbolic_number *n, tree src)
|
|
|
|
{
|
2014-06-11 12:04:33 +02:00
|
|
|
int size;
|
|
|
|
|
2014-06-03 11:29:06 +02:00
|
|
|
n->base_addr = n->offset = n->alias_set = n->vuse = NULL_TREE;
|
|
|
|
|
|
|
|
/* Set up the symbolic number N by setting each byte to a value between 1 and
|
|
|
|
the byte size of rhs1. The highest order byte is set to n->size and the
|
|
|
|
lowest order byte to 1. */
|
2014-06-11 12:04:33 +02:00
|
|
|
n->type = TREE_TYPE (src);
|
|
|
|
size = TYPE_PRECISION (n->type);
|
|
|
|
if (size % BITS_PER_UNIT != 0)
|
2014-06-03 11:29:06 +02:00
|
|
|
return false;
|
2014-06-11 12:04:33 +02:00
|
|
|
size /= BITS_PER_UNIT;
|
2014-06-13 05:17:02 +02:00
|
|
|
if (size > (int)sizeof (uint64_t))
|
|
|
|
return false;
|
2014-06-11 12:04:33 +02:00
|
|
|
n->range = size;
|
2014-06-03 11:29:06 +02:00
|
|
|
n->n = CMPNOP;
|
|
|
|
|
2014-06-11 12:04:33 +02:00
|
|
|
if (size < (int)sizeof (int64_t))
|
|
|
|
n->n &= ((uint64_t)1 << (size * BITS_PER_UNIT)) - 1;
|
2014-06-03 11:29:06 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
/* Check if STMT might be a byte swap or a nop from a memory source and returns
|
|
|
|
the answer. If so, REF is that memory source and the base of the memory area
|
|
|
|
accessed and the offset of the access from that base are recorded in N. */
|
|
|
|
|
|
|
|
bool
|
|
|
|
find_bswap_or_nop_load (gimple stmt, tree ref, struct symbolic_number *n)
|
|
|
|
{
|
|
|
|
/* Leaf node is an array or component ref. Memorize its base and
|
|
|
|
offset from base to compare to other such leaf node. */
|
|
|
|
HOST_WIDE_INT bitsize, bitpos;
|
|
|
|
enum machine_mode mode;
|
|
|
|
int unsignedp, volatilep;
|
2014-06-03 11:29:06 +02:00
|
|
|
tree offset, base_addr;
|
2014-05-23 05:33:28 +02:00
|
|
|
|
|
|
|
if (!gimple_assign_load_p (stmt) || gimple_has_volatile_ops (stmt))
|
|
|
|
return false;
|
|
|
|
|
2014-06-03 11:29:06 +02:00
|
|
|
base_addr = get_inner_reference (ref, &bitsize, &bitpos, &offset, &mode,
|
|
|
|
&unsignedp, &volatilep, false);
|
2014-05-23 05:33:28 +02:00
|
|
|
|
2014-06-03 11:29:06 +02:00
|
|
|
if (TREE_CODE (base_addr) == MEM_REF)
|
2014-05-23 05:33:28 +02:00
|
|
|
{
|
|
|
|
offset_int bit_offset = 0;
|
2014-06-03 11:29:06 +02:00
|
|
|
tree off = TREE_OPERAND (base_addr, 1);
|
2014-05-23 05:33:28 +02:00
|
|
|
|
|
|
|
if (!integer_zerop (off))
|
|
|
|
{
|
2014-06-03 11:29:06 +02:00
|
|
|
offset_int boff, coff = mem_ref_offset (base_addr);
|
2014-05-23 05:33:28 +02:00
|
|
|
boff = wi::lshift (coff, LOG2_BITS_PER_UNIT);
|
|
|
|
bit_offset += boff;
|
|
|
|
}
|
|
|
|
|
2014-06-03 11:29:06 +02:00
|
|
|
base_addr = TREE_OPERAND (base_addr, 0);
|
2014-05-23 05:33:28 +02:00
|
|
|
|
|
|
|
/* Avoid returning a negative bitpos as this may wreak havoc later. */
|
|
|
|
if (wi::neg_p (bit_offset))
|
|
|
|
{
|
|
|
|
offset_int mask = wi::mask <offset_int> (LOG2_BITS_PER_UNIT, false);
|
|
|
|
offset_int tem = bit_offset.and_not (mask);
|
|
|
|
/* TEM is the bitpos rounded to BITS_PER_UNIT towards -Inf.
|
|
|
|
Subtract it to BIT_OFFSET and add it (scaled) to OFFSET. */
|
|
|
|
bit_offset -= tem;
|
|
|
|
tem = wi::arshift (tem, LOG2_BITS_PER_UNIT);
|
2014-06-03 11:29:06 +02:00
|
|
|
if (offset)
|
|
|
|
offset = size_binop (PLUS_EXPR, offset,
|
2014-05-23 05:33:28 +02:00
|
|
|
wide_int_to_tree (sizetype, tem));
|
|
|
|
else
|
2014-06-03 11:29:06 +02:00
|
|
|
offset = wide_int_to_tree (sizetype, tem);
|
2014-05-23 05:33:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bitpos += bit_offset.to_shwi ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bitpos % BITS_PER_UNIT)
|
|
|
|
return false;
|
|
|
|
if (bitsize % BITS_PER_UNIT)
|
|
|
|
return false;
|
|
|
|
|
2014-06-10 04:10:46 +02:00
|
|
|
if (!init_symbolic_number (n, ref))
|
|
|
|
return false;
|
2014-06-03 11:29:06 +02:00
|
|
|
n->base_addr = base_addr;
|
|
|
|
n->offset = offset;
|
2014-05-23 05:33:28 +02:00
|
|
|
n->bytepos = bitpos / BITS_PER_UNIT;
|
|
|
|
n->alias_set = reference_alias_ptr_type (ref);
|
|
|
|
n->vuse = gimple_vuse (stmt);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find_bswap_or_nop_1 invokes itself recursively with N and tries to perform
|
|
|
|
the operation given by the rhs of STMT on the result. If the operation
|
2014-06-18 12:43:50 +02:00
|
|
|
could successfully be executed the function returns a gimple stmt whose
|
|
|
|
rhs's first tree is the expression of the source operand and NULL
|
|
|
|
otherwise. */
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
static gimple
|
2014-05-23 05:33:28 +02:00
|
|
|
find_bswap_or_nop_1 (gimple stmt, struct symbolic_number *n, int limit)
|
2009-06-14 16:45:32 +02:00
|
|
|
{
|
|
|
|
enum tree_code code;
|
|
|
|
tree rhs1, rhs2 = NULL;
|
2014-06-18 12:43:50 +02:00
|
|
|
gimple rhs1_stmt, rhs2_stmt, source_stmt1;
|
2009-06-14 16:45:32 +02:00
|
|
|
enum gimple_rhs_class rhs_class;
|
|
|
|
|
|
|
|
if (!limit || !is_gimple_assign (stmt))
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
|
|
|
rhs1 = gimple_assign_rhs1 (stmt);
|
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
if (find_bswap_or_nop_load (stmt, rhs1, n))
|
2014-06-18 12:43:50 +02:00
|
|
|
return stmt;
|
2014-05-23 05:33:28 +02:00
|
|
|
|
2009-06-14 16:45:32 +02:00
|
|
|
if (TREE_CODE (rhs1) != SSA_NAME)
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
|
|
|
code = gimple_assign_rhs_code (stmt);
|
|
|
|
rhs_class = gimple_assign_rhs_class (stmt);
|
|
|
|
rhs1_stmt = SSA_NAME_DEF_STMT (rhs1);
|
|
|
|
|
|
|
|
if (rhs_class == GIMPLE_BINARY_RHS)
|
|
|
|
rhs2 = gimple_assign_rhs2 (stmt);
|
|
|
|
|
|
|
|
/* Handle unary rhs and binary rhs with integer constants as second
|
|
|
|
operand. */
|
|
|
|
|
|
|
|
if (rhs_class == GIMPLE_UNARY_RHS
|
|
|
|
|| (rhs_class == GIMPLE_BINARY_RHS
|
|
|
|
&& TREE_CODE (rhs2) == INTEGER_CST))
|
|
|
|
{
|
|
|
|
if (code != BIT_AND_EXPR
|
|
|
|
&& code != LSHIFT_EXPR
|
|
|
|
&& code != RSHIFT_EXPR
|
|
|
|
&& code != LROTATE_EXPR
|
|
|
|
&& code != RROTATE_EXPR
|
|
|
|
&& code != NOP_EXPR
|
|
|
|
&& code != CONVERT_EXPR)
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
source_stmt1 = find_bswap_or_nop_1 (rhs1_stmt, n, limit - 1);
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
/* If find_bswap_or_nop_1 returned NULL, STMT is a leaf node and
|
|
|
|
we have to initialize the symbolic number. */
|
2014-06-18 12:43:50 +02:00
|
|
|
if (!source_stmt1)
|
2009-06-14 16:45:32 +02:00
|
|
|
{
|
2014-06-03 11:29:06 +02:00
|
|
|
if (gimple_assign_load_p (stmt)
|
|
|
|
|| !init_symbolic_number (n, rhs1))
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
|
|
|
source_stmt1 = stmt;
|
2009-06-14 16:45:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (code)
|
|
|
|
{
|
|
|
|
case BIT_AND_EXPR:
|
|
|
|
{
|
2014-06-11 12:04:33 +02:00
|
|
|
int i, size = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
uint64_t val = int_cst_value (rhs2);
|
|
|
|
uint64_t tmp = val;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
|
|
|
/* Only constants masking full bytes are allowed. */
|
2014-06-11 12:04:33 +02:00
|
|
|
for (i = 0; i < size; i++, tmp >>= BITS_PER_UNIT)
|
2009-06-14 16:45:32 +02:00
|
|
|
if ((tmp & 0xff) != 0 && (tmp & 0xff) != 0xff)
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
|
|
|
n->n &= val;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case LSHIFT_EXPR:
|
|
|
|
case RSHIFT_EXPR:
|
|
|
|
case LROTATE_EXPR:
|
|
|
|
case RROTATE_EXPR:
|
|
|
|
if (!do_shift_rotate (code, n, (int)TREE_INT_CST_LOW (rhs2)))
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
break;
|
|
|
|
CASE_CONVERT:
|
|
|
|
{
|
2014-06-11 12:04:33 +02:00
|
|
|
int type_size, old_type_size;
|
|
|
|
tree type;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-06-11 12:04:33 +02:00
|
|
|
type = gimple_expr_type (stmt);
|
|
|
|
type_size = TYPE_PRECISION (type);
|
2009-06-14 16:45:32 +02:00
|
|
|
if (type_size % BITS_PER_UNIT != 0)
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2014-06-13 05:17:02 +02:00
|
|
|
if (type_size > (int)sizeof (uint64_t) * 8)
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-06-11 12:04:33 +02:00
|
|
|
/* Sign extension: result is dependent on the value. */
|
|
|
|
old_type_size = TYPE_PRECISION (n->type);
|
|
|
|
if (!TYPE_UNSIGNED (n->type)
|
|
|
|
&& type_size > old_type_size
|
2014-06-20 08:30:19 +02:00
|
|
|
&& n->n & ((uint64_t) 0xff << (old_type_size - 8)))
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2014-06-11 12:04:33 +02:00
|
|
|
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
if (type_size / BITS_PER_UNIT < (int)(sizeof (int64_t)))
|
2009-06-14 16:45:32 +02:00
|
|
|
{
|
|
|
|
/* If STMT casts to a smaller type mask out the bits not
|
|
|
|
belonging to the target type. */
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
n->n &= ((uint64_t)1 << type_size) - 1;
|
2009-06-14 16:45:32 +02:00
|
|
|
}
|
2014-06-11 12:04:33 +02:00
|
|
|
n->type = type;
|
2014-05-23 05:33:28 +02:00
|
|
|
if (!n->base_addr)
|
2014-06-11 12:04:33 +02:00
|
|
|
n->range = type_size / BITS_PER_UNIT;
|
2009-06-14 16:45:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
};
|
2014-06-18 12:43:50 +02:00
|
|
|
return verify_symbolic_number_p (n, stmt) ? source_stmt1 : NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle binary rhs. */
|
|
|
|
|
|
|
|
if (rhs_class == GIMPLE_BINARY_RHS)
|
|
|
|
{
|
2014-06-11 12:04:33 +02:00
|
|
|
int i, size;
|
2009-06-14 16:45:32 +02:00
|
|
|
struct symbolic_number n1, n2;
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
uint64_t mask;
|
2014-06-18 12:43:50 +02:00
|
|
|
gimple source_stmt2;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
|
|
|
if (code != BIT_IOR_EXPR)
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
|
|
|
if (TREE_CODE (rhs2) != SSA_NAME)
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
|
|
|
rhs2_stmt = SSA_NAME_DEF_STMT (rhs2);
|
|
|
|
|
|
|
|
switch (code)
|
|
|
|
{
|
|
|
|
case BIT_IOR_EXPR:
|
2014-06-18 12:43:50 +02:00
|
|
|
source_stmt1 = find_bswap_or_nop_1 (rhs1_stmt, &n1, limit - 1);
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
if (!source_stmt1)
|
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
source_stmt2 = find_bswap_or_nop_1 (rhs2_stmt, &n2, limit - 1);
|
2014-05-23 05:33:28 +02:00
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
if (!source_stmt2)
|
|
|
|
return NULL;
|
2014-06-03 11:29:06 +02:00
|
|
|
|
2014-06-11 12:04:33 +02:00
|
|
|
if (TYPE_PRECISION (n1.type) != TYPE_PRECISION (n2.type))
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
if (!n1.vuse != !n2.vuse ||
|
|
|
|
(n1.vuse && !operand_equal_p (n1.vuse, n2.vuse, 0)))
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
if (gimple_assign_rhs1 (source_stmt1)
|
|
|
|
!= gimple_assign_rhs1 (source_stmt2))
|
2014-05-23 05:33:28 +02:00
|
|
|
{
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
int64_t inc, mask;
|
2014-05-23 05:33:28 +02:00
|
|
|
unsigned i;
|
|
|
|
HOST_WIDE_INT off_sub;
|
|
|
|
struct symbolic_number *n_ptr;
|
|
|
|
|
|
|
|
if (!n1.base_addr || !n2.base_addr
|
|
|
|
|| !operand_equal_p (n1.base_addr, n2.base_addr, 0))
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2014-05-23 05:33:28 +02:00
|
|
|
if (!n1.offset != !n2.offset ||
|
|
|
|
(n1.offset && !operand_equal_p (n1.offset, n2.offset, 0)))
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2014-05-23 05:33:28 +02:00
|
|
|
|
|
|
|
/* We swap n1 with n2 to have n1 < n2. */
|
|
|
|
if (n2.bytepos < n1.bytepos)
|
|
|
|
{
|
|
|
|
struct symbolic_number tmpn;
|
|
|
|
|
|
|
|
tmpn = n2;
|
|
|
|
n2 = n1;
|
|
|
|
n1 = tmpn;
|
2014-06-18 12:43:50 +02:00
|
|
|
source_stmt1 = source_stmt2;
|
2014-05-23 05:33:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
off_sub = n2.bytepos - n1.bytepos;
|
|
|
|
|
|
|
|
/* Check that the range of memory covered < biggest int size. */
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
if (off_sub + n2.range > (int) sizeof (int64_t))
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2014-05-23 05:33:28 +02:00
|
|
|
n->range = n2.range + off_sub;
|
|
|
|
|
|
|
|
/* Reinterpret byte marks in symbolic number holding the value of
|
2014-06-06 10:23:16 +02:00
|
|
|
bigger weight according to target endianness. */
|
2014-05-23 05:33:28 +02:00
|
|
|
inc = BYTES_BIG_ENDIAN ? off_sub + n2.range - n1.range : off_sub;
|
|
|
|
mask = 0xFF;
|
|
|
|
if (BYTES_BIG_ENDIAN)
|
|
|
|
n_ptr = &n1;
|
|
|
|
else
|
|
|
|
n_ptr = &n2;
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
for (i = 0; i < sizeof (int64_t); i++, inc <<= 8,
|
2014-05-23 05:33:28 +02:00
|
|
|
mask <<= 8)
|
|
|
|
{
|
|
|
|
if (n_ptr->n & mask)
|
|
|
|
n_ptr->n += inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
n->range = n1.range;
|
|
|
|
|
|
|
|
if (!n1.alias_set
|
|
|
|
|| alias_ptr_types_compatible_p (n1.alias_set, n2.alias_set))
|
|
|
|
n->alias_set = n1.alias_set;
|
|
|
|
else
|
|
|
|
n->alias_set = ptr_type_node;
|
|
|
|
n->vuse = n1.vuse;
|
|
|
|
n->base_addr = n1.base_addr;
|
|
|
|
n->offset = n1.offset;
|
|
|
|
n->bytepos = n1.bytepos;
|
2014-06-11 12:04:33 +02:00
|
|
|
n->type = n1.type;
|
|
|
|
size = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
|
|
|
|
for (i = 0, mask = 0xff; i < size; i++, mask <<= BITS_PER_UNIT)
|
2014-03-12 11:15:29 +01:00
|
|
|
{
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
uint64_t masked1, masked2;
|
2014-03-12 11:15:29 +01:00
|
|
|
|
|
|
|
masked1 = n1.n & mask;
|
|
|
|
masked2 = n2.n & mask;
|
|
|
|
if (masked1 && masked2 && masked1 != masked2)
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2014-03-12 11:15:29 +01:00
|
|
|
}
|
2009-06-14 16:45:32 +02:00
|
|
|
n->n = n1.n | n2.n;
|
|
|
|
|
|
|
|
if (!verify_symbolic_number_p (n, stmt))
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
}
|
2014-06-18 12:43:50 +02:00
|
|
|
return source_stmt1;
|
2009-06-14 16:45:32 +02:00
|
|
|
}
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
}
|
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
/* Check if STMT completes a bswap implementation or a read in a given
|
|
|
|
endianness consisting of ORs, SHIFTs and ANDs and sets *BSWAP
|
|
|
|
accordingly. It also sets N to represent the kind of operations
|
|
|
|
performed: size of the resulting expression and whether it works on
|
|
|
|
a memory source, and if so alias-set and vuse. At last, the
|
2014-06-18 12:43:50 +02:00
|
|
|
function returns a stmt whose rhs's first tree is the source
|
|
|
|
expression. */
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
static gimple
|
2014-05-23 05:33:28 +02:00
|
|
|
find_bswap_or_nop (gimple stmt, struct symbolic_number *n, bool *bswap)
|
2009-06-14 16:45:32 +02:00
|
|
|
{
|
2014-05-23 05:33:28 +02:00
|
|
|
/* The number which the find_bswap_or_nop_1 result should match in order
|
|
|
|
to have a full byte swap. The number is shifted to the right
|
|
|
|
according to the size of the symbolic number before using it. */
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
uint64_t cmpxchg = CMPXCHG;
|
|
|
|
uint64_t cmpnop = CMPNOP;
|
2014-05-23 05:33:28 +02:00
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
gimple source_stmt;
|
2011-06-27 15:44:52 +02:00
|
|
|
int limit;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2009-06-23 14:10:06 +02:00
|
|
|
/* The last parameter determines the depth search limit. It usually
|
2014-05-23 05:33:28 +02:00
|
|
|
correlates directly to the number n of bytes to be touched. We
|
|
|
|
increase that number by log2(n) + 1 here in order to also
|
|
|
|
cover signed -> unsigned conversions of the src operand as can be seen
|
2011-06-27 15:44:52 +02:00
|
|
|
in libgcc, and for initial shift/and operation of the src operand. */
|
|
|
|
limit = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (gimple_expr_type (stmt)));
|
|
|
|
limit += 1 + (int) ceil_log2 ((unsigned HOST_WIDE_INT) limit);
|
2014-06-18 12:43:50 +02:00
|
|
|
source_stmt = find_bswap_or_nop_1 (stmt, n, limit);
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
if (!source_stmt)
|
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
/* Find real size of result (highest non zero byte). */
|
|
|
|
if (n->base_addr)
|
2009-06-14 16:45:32 +02:00
|
|
|
{
|
2014-05-23 05:33:28 +02:00
|
|
|
int rsize;
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
uint64_t tmpn;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
for (tmpn = n->n, rsize = 0; tmpn; tmpn >>= BITS_PER_UNIT, rsize++);
|
|
|
|
n->range = rsize;
|
2009-06-14 16:45:32 +02:00
|
|
|
}
|
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
/* Zero out the extra bits of N and CMP*. */
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
if (n->range < (int)sizeof (int64_t))
|
2014-05-23 05:33:28 +02:00
|
|
|
{
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
uint64_t mask;
|
2014-05-23 05:33:28 +02:00
|
|
|
|
system.h: Define __STDC_FORMAT_MACROS before including inttypes.h.
2014-05-23 Richard Biener <rguenther@suse.de>
* system.h: Define __STDC_FORMAT_MACROS before
including inttypes.h.
* hwint.h (HOST_WIDEST_INT, HOST_BITS_PER_WIDEST_INT,
HOST_WIDEST_INT_PRINT, HOST_WIDEST_INT_PRINT_DEC,
HOST_WIDEST_INT_PRINT_DEC_C, HOST_WIDEST_INT_PRINT_UNSIGNED,
HOST_WIDEST_INT_PRINT_HEX, HOST_WIDEST_INT_PRINT_DOUBLE_HEX,
HOST_WIDEST_INT_C): Remove.
(PRId64, PRIi64, PRIo64, PRIu64, PRIx64, PRIX64): Define
if C99 inttypes.h is not available.
* coretypes.h (gcov_type, gcov_type_unsigned): Use [u]int64_t.
* gcov-io.h (gcov_type, gcov_type_unsigned): Likewise.
* gcov-io.c (gcov_histo_index): Drop non-64bit hwi case.
* cfgloop.h (struct niter_desc): Use uint64_t for niter field.
* bitmap.c (struct bitmap_descriptor_d): Use uint64_t for counters.
(struct output_info): Likewise.
(print_statistics): Adjust.
(dump_bitmap_statistics): Likewise.
* bt-load.c (migrate_btr_defs): Print with PRId64.
* cfg.c (dump_edge_info, dump_bb_info): Likewise.
(MAX_SAFE_MULTIPLIER): Adjust.
* cfghooks.c (dump_bb_for_graph): Print with PRId64.
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee,
dump_cgraph_node): Likewise.
* final.c (dump_basic_block_info): Likewise.
* gcov-dump.c (tag_counters, tag_summary, dump_working_sets): Likewise.
* gcov.c (format_gcov): Likewise.
* ipa-cp.c (good_cloning_opportunity_p): Likewise. Use int64_t
for calculation.
(get_clone_agg_value): Use HOST_WIDE_INT for offset.
* ipa-inline.c (compute_max_insns): Use int64_t for calcuation.
(inline_small_functions, dump_overall_stats, dump_inline_stats):
Use PRId64 for dumping.
* ipa-profile.c (dump_histogram, ipa_profile): Likewise.
* ira-color.c (struct allocno_hard_regs): Use int64_t for cost.
(add_allocno_hard_regs): Adjust.
* loop-doloop.c (doloop_modify): Print using PRId64.
* loop-iv.c (inverse): Compute in uint64_t.
(determine_max_iter, iv_number_of_iterations): Likewise.
* loop-unroll.c (decide_peel_completely, decide_peel_simple):
Print using PRId64.
* lto-streamer-out.c (write_symbol): Use uint64_t.
* mcf.c (CAP_INFINITY): Use int64_t maximum.
(dump_fixup_edge, create_fixup_graph, cancel_negative_cycle,
find_max_flow, adjust_cfg_counts): Use int64_t and dump with PRId64.
* modulo-sched.c (const_iteration_count): Use int64_t.
(sms_schedule): Dump using PRId64.
* predict.c (dump_prediction): Likewise.
* pretty-print.h (pp_widest_integer): Remove.
* profile.c (get_working_sets, is_edge_inconsistent,
is_inconsistent, read_profile_edge_counts): Dump using PRId64.
* tree-pretty-print.c (pp_double_int): Remove case handling
HOST_BITS_PER_DOUBLE_INT == HOST_BITS_PER_WIDEST_INT.
* tree-ssa-math-opts.c (struct symbolic_number): Use uint64_t
and adjust users.
(pass_optimize_bswap::execute): Remove restriction on hosts.
* tree-streamer-in.c (streamer_alloc_tree): Use HOST_WIDE_INT.
* tree-streamer-out.c (streamer_write_tree_header): Likewise.
* tree.c (widest_int_cst_value): Remove.
* tree.h (widest_int_cst_value): Likewise.
* value-prof.c (dump_histogram_value): Print using PRId64.
* gengtype.c (main): Also inject int64_t.
* ggc-page.c (struct max_alignment): Use int64_t.
* alloc-pool.c (struct allocation_object_def): Likewise.
* ira-conflicts.c (build_conflict_bit_table): Use uint64_t
for computation.
* doc/tm.texi.in: Remove reference to HOST_WIDEST_INT.
* doc/tm.texi: Regenerated.
* gengtype-lex.l (IWORD): Handle [u]int64_t.
* config/sh/sh.c (expand_cbranchdi4): Use gcov_type.
* config/mmix/mmix-protos.h (mmix_intval, mmix_shiftable_wyde_value,
mmix_output_register_setting): Use [u]int64_t in prototypes.
* config/mmix/mmix.c (mmix_print_operand, mmix_output_register_setting,
mmix_shiftable_wyde_value, mmix_output_shiftvalue_op_from_str,
mmix_output_octa, mmix_output_shifted_value): Adjust.
(mmix_intval): Adjust. Remove unreachable case.
* config/mmix/mmix.md (*nonlocal_goto_receiver_expanded): Use
int64_t.
lto/
* lto.c (lto_parse_hex): Use int64_t.
(lto_resolution_read): Likewise.
From-SVN: r210931
2014-05-26 12:42:43 +02:00
|
|
|
mask = ((uint64_t)1 << (n->range * BITS_PER_UNIT)) - 1;
|
|
|
|
cmpxchg >>= (sizeof (int64_t) - n->range) * BITS_PER_UNIT;
|
2014-05-23 05:33:28 +02:00
|
|
|
cmpnop &= mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* A complete byte swap should make the symbolic number to start with
|
|
|
|
the largest digit in the highest order byte. Unchanged symbolic
|
2014-06-06 10:23:16 +02:00
|
|
|
number indicates a read with same endianness as target architecture. */
|
2014-05-23 05:33:28 +02:00
|
|
|
if (n->n == cmpnop)
|
|
|
|
*bswap = false;
|
|
|
|
else if (n->n == cmpxchg)
|
|
|
|
*bswap = true;
|
|
|
|
else
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2014-05-23 05:33:28 +02:00
|
|
|
|
|
|
|
/* Useless bit manipulation performed by code. */
|
|
|
|
if (!n->base_addr && n->n == cmpnop)
|
2014-06-18 12:43:50 +02:00
|
|
|
return NULL;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
n->range *= BITS_PER_UNIT;
|
2014-06-18 12:43:50 +02:00
|
|
|
return source_stmt;
|
2009-06-14 16:45:32 +02:00
|
|
|
}
|
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
const pass_data pass_data_optimize_bswap =
|
|
|
|
{
|
|
|
|
GIMPLE_PASS, /* type */
|
|
|
|
"bswap", /* name */
|
|
|
|
OPTGROUP_NONE, /* optinfo_flags */
|
|
|
|
TV_NONE, /* tv_id */
|
|
|
|
PROP_ssa, /* properties_required */
|
|
|
|
0, /* properties_provided */
|
|
|
|
0, /* properties_destroyed */
|
|
|
|
0, /* todo_flags_start */
|
|
|
|
0, /* todo_flags_finish */
|
|
|
|
};
|
|
|
|
|
|
|
|
class pass_optimize_bswap : public gimple_opt_pass
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
pass_optimize_bswap (gcc::context *ctxt)
|
|
|
|
: gimple_opt_pass (pass_data_optimize_bswap, ctxt)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/* opt_pass methods: */
|
|
|
|
virtual bool gate (function *)
|
|
|
|
{
|
|
|
|
return flag_expensive_optimizations && optimize;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual unsigned int execute (function *);
|
|
|
|
|
|
|
|
}; // class pass_optimize_bswap
|
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
/* Perform the bswap optimization: replace the statement CUR_STMT at
|
|
|
|
GSI with a load of type, VUSE and set-alias as described by N if a
|
|
|
|
memory source is involved (N->base_addr is non null), followed by
|
|
|
|
the builtin bswap invocation in FNDECL if BSWAP is true. SRC_STMT
|
|
|
|
gives where should the replacement be made. It also gives the
|
|
|
|
source on which CUR_STMT is operating via its rhs's first tree nad
|
|
|
|
N->range gives the size of the expression involved for maintaining
|
|
|
|
some statistics. */
|
2014-05-23 05:33:28 +02:00
|
|
|
|
|
|
|
static bool
|
2014-06-18 12:43:50 +02:00
|
|
|
bswap_replace (gimple cur_stmt, gimple_stmt_iterator gsi, gimple src_stmt,
|
|
|
|
tree fndecl, tree bswap_type, tree load_type,
|
|
|
|
struct symbolic_number *n, bool bswap)
|
2014-05-23 05:33:28 +02:00
|
|
|
{
|
2014-06-18 12:43:50 +02:00
|
|
|
tree src, tmp, tgt;
|
2014-05-23 05:33:28 +02:00
|
|
|
gimple call;
|
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
src = gimple_assign_rhs1 (src_stmt);
|
|
|
|
tgt = gimple_assign_lhs (cur_stmt);
|
2014-05-23 05:33:28 +02:00
|
|
|
|
|
|
|
/* Need to load the value from memory first. */
|
|
|
|
if (n->base_addr)
|
|
|
|
{
|
2014-06-18 12:43:50 +02:00
|
|
|
gimple_stmt_iterator gsi_ins = gsi_for_stmt (src_stmt);
|
2014-05-23 05:33:28 +02:00
|
|
|
tree addr_expr, addr_tmp, val_expr, val_tmp;
|
|
|
|
tree load_offset_ptr, aligned_load_type;
|
|
|
|
gimple addr_stmt, load_stmt;
|
|
|
|
unsigned align;
|
|
|
|
|
|
|
|
align = get_object_alignment (src);
|
2014-06-27 12:03:51 +02:00
|
|
|
if (bswap
|
|
|
|
&& align < GET_MODE_ALIGNMENT (TYPE_MODE (load_type))
|
|
|
|
&& SLOW_UNALIGNED_ACCESS (TYPE_MODE (load_type), align))
|
2014-05-23 05:33:28 +02:00
|
|
|
return false;
|
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
gsi_move_before (&gsi, &gsi_ins);
|
|
|
|
gsi = gsi_for_stmt (cur_stmt);
|
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
/* Compute address to load from and cast according to the size
|
|
|
|
of the load. */
|
|
|
|
addr_expr = build_fold_addr_expr (unshare_expr (src));
|
|
|
|
if (is_gimple_min_invariant (addr_expr))
|
|
|
|
addr_tmp = addr_expr;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
addr_tmp = make_temp_ssa_name (TREE_TYPE (addr_expr), NULL,
|
|
|
|
"load_src");
|
|
|
|
addr_stmt = gimple_build_assign (addr_tmp, addr_expr);
|
2014-06-18 12:43:50 +02:00
|
|
|
gsi_insert_before (&gsi, addr_stmt, GSI_SAME_STMT);
|
2014-05-23 05:33:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform the load. */
|
|
|
|
aligned_load_type = load_type;
|
|
|
|
if (align < TYPE_ALIGN (load_type))
|
|
|
|
aligned_load_type = build_aligned_type (load_type, align);
|
|
|
|
load_offset_ptr = build_int_cst (n->alias_set, 0);
|
|
|
|
val_expr = fold_build2 (MEM_REF, aligned_load_type, addr_tmp,
|
|
|
|
load_offset_ptr);
|
|
|
|
|
|
|
|
if (!bswap)
|
|
|
|
{
|
|
|
|
if (n->range == 16)
|
|
|
|
nop_stats.found_16bit++;
|
|
|
|
else if (n->range == 32)
|
|
|
|
nop_stats.found_32bit++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gcc_assert (n->range == 64);
|
|
|
|
nop_stats.found_64bit++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert the result of load if necessary. */
|
|
|
|
if (!useless_type_conversion_p (TREE_TYPE (tgt), load_type))
|
|
|
|
{
|
|
|
|
val_tmp = make_temp_ssa_name (aligned_load_type, NULL,
|
|
|
|
"load_dst");
|
|
|
|
load_stmt = gimple_build_assign (val_tmp, val_expr);
|
|
|
|
gimple_set_vuse (load_stmt, n->vuse);
|
2014-06-18 12:43:50 +02:00
|
|
|
gsi_insert_before (&gsi, load_stmt, GSI_SAME_STMT);
|
|
|
|
gimple_assign_set_rhs_with_ops_1 (&gsi, NOP_EXPR, val_tmp,
|
2014-05-23 05:33:28 +02:00
|
|
|
NULL_TREE, NULL_TREE);
|
|
|
|
}
|
|
|
|
else
|
2014-06-18 12:43:50 +02:00
|
|
|
{
|
|
|
|
gimple_assign_set_rhs_with_ops_1 (&gsi, MEM_REF, val_expr,
|
|
|
|
NULL_TREE, NULL_TREE);
|
|
|
|
gimple_set_vuse (cur_stmt, n->vuse);
|
|
|
|
}
|
|
|
|
update_stmt (cur_stmt);
|
2014-05-23 05:33:28 +02:00
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
{
|
|
|
|
fprintf (dump_file,
|
2014-06-06 10:23:16 +02:00
|
|
|
"%d bit load in target endianness found at: ",
|
2014-05-23 05:33:28 +02:00
|
|
|
(int)n->range);
|
2014-06-18 12:43:50 +02:00
|
|
|
print_gimple_stmt (dump_file, cur_stmt, 0, 0);
|
2014-05-23 05:33:28 +02:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
val_tmp = make_temp_ssa_name (aligned_load_type, NULL, "load_dst");
|
|
|
|
load_stmt = gimple_build_assign (val_tmp, val_expr);
|
|
|
|
gimple_set_vuse (load_stmt, n->vuse);
|
2014-06-18 12:43:50 +02:00
|
|
|
gsi_insert_before (&gsi, load_stmt, GSI_SAME_STMT);
|
2014-05-23 05:33:28 +02:00
|
|
|
}
|
|
|
|
src = val_tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n->range == 16)
|
|
|
|
bswap_stats.found_16bit++;
|
|
|
|
else if (n->range == 32)
|
|
|
|
bswap_stats.found_32bit++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gcc_assert (n->range == 64);
|
|
|
|
bswap_stats.found_64bit++;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = src;
|
|
|
|
|
|
|
|
/* Convert the src expression if necessary. */
|
|
|
|
if (!useless_type_conversion_p (TREE_TYPE (tmp), bswap_type))
|
|
|
|
{
|
|
|
|
gimple convert_stmt;
|
|
|
|
tmp = make_temp_ssa_name (bswap_type, NULL, "bswapsrc");
|
|
|
|
convert_stmt = gimple_build_assign_with_ops (NOP_EXPR, tmp, src, NULL);
|
2014-06-18 12:43:50 +02:00
|
|
|
gsi_insert_before (&gsi, convert_stmt, GSI_SAME_STMT);
|
2014-05-23 05:33:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
call = gimple_build_call (fndecl, 1, tmp);
|
|
|
|
|
|
|
|
tmp = tgt;
|
|
|
|
|
|
|
|
/* Convert the result if necessary. */
|
|
|
|
if (!useless_type_conversion_p (TREE_TYPE (tgt), bswap_type))
|
|
|
|
{
|
|
|
|
gimple convert_stmt;
|
|
|
|
tmp = make_temp_ssa_name (bswap_type, NULL, "bswapdst");
|
|
|
|
convert_stmt = gimple_build_assign_with_ops (NOP_EXPR, tgt, tmp, NULL);
|
2014-06-18 12:43:50 +02:00
|
|
|
gsi_insert_after (&gsi, convert_stmt, GSI_SAME_STMT);
|
2014-05-23 05:33:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gimple_call_set_lhs (call, tmp);
|
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
{
|
|
|
|
fprintf (dump_file, "%d bit bswap implementation found at: ",
|
|
|
|
(int)n->range);
|
2014-06-18 12:43:50 +02:00
|
|
|
print_gimple_stmt (dump_file, cur_stmt, 0, 0);
|
2014-05-23 05:33:28 +02:00
|
|
|
}
|
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
gsi_insert_after (&gsi, call, GSI_SAME_STMT);
|
|
|
|
gsi_remove (&gsi, true);
|
2014-05-23 05:33:28 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find manual byte swap implementations as well as load in a given
|
|
|
|
endianness. Byte swaps are turned into a bswap builtin invokation
|
|
|
|
while endian loads are converted to bswap builtin invokation or
|
2014-06-06 10:23:16 +02:00
|
|
|
simple load according to the target endianness. */
|
2014-05-23 05:33:28 +02:00
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
unsigned int
|
|
|
|
pass_optimize_bswap::execute (function *fun)
|
2009-06-14 16:45:32 +02:00
|
|
|
{
|
|
|
|
basic_block bb;
|
2012-09-26 15:42:47 +02:00
|
|
|
bool bswap16_p, bswap32_p, bswap64_p;
|
2009-06-14 16:45:32 +02:00
|
|
|
bool changed = false;
|
2012-09-26 15:42:47 +02:00
|
|
|
tree bswap16_type = NULL_TREE, bswap32_type = NULL_TREE, bswap64_type = NULL_TREE;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
|
|
|
if (BITS_PER_UNIT != 8)
|
|
|
|
return 0;
|
|
|
|
|
2012-09-26 15:42:47 +02:00
|
|
|
bswap16_p = (builtin_decl_explicit_p (BUILT_IN_BSWAP16)
|
|
|
|
&& optab_handler (bswap_optab, HImode) != CODE_FOR_nothing);
|
2011-10-11 21:55:09 +02:00
|
|
|
bswap32_p = (builtin_decl_explicit_p (BUILT_IN_BSWAP32)
|
optabs.h (optab_handler, [...]): Turn into inline functions that return an insn code.
gcc/
* optabs.h (optab_handler, convert_optab_handler): Turn into
inline functions that return an insn code.
(set_optab_handler, set_convert_optab_handler): New functions.
* builtins.c: Replace optab_handler(X)->insn_code with
optab_handler or set_optab_handler thoughout. Likewise
convert_optab_handler(X)->insn_code with convert_optab_handler
and set_convert_optab_handler.
* expmed.c, expr.c, genopinit.c, ifcvt.c, optabs.c, reload.c,
reload1.c, stmt.c, targhooks.c, tree-ssa-loop-prefetch.c,
tree-ssa-math-opts.c, tree-vect-data-refs.c, tree-vect-generic.c,
tree-vect-loop.c, tree-vect-patterns.c, tree-vect-slp.c,
tree-vect-stmts.c, config/m32c/m32c.c, config/rs6000/rs6000.c,
config/spu/spu.c: Likewise.
From-SVN: r161808
2010-07-05 00:13:09 +02:00
|
|
|
&& optab_handler (bswap_optab, SImode) != CODE_FOR_nothing);
|
2011-10-11 21:55:09 +02:00
|
|
|
bswap64_p = (builtin_decl_explicit_p (BUILT_IN_BSWAP64)
|
optabs.h (optab_handler, [...]): Turn into inline functions that return an insn code.
gcc/
* optabs.h (optab_handler, convert_optab_handler): Turn into
inline functions that return an insn code.
(set_optab_handler, set_convert_optab_handler): New functions.
* builtins.c: Replace optab_handler(X)->insn_code with
optab_handler or set_optab_handler thoughout. Likewise
convert_optab_handler(X)->insn_code with convert_optab_handler
and set_convert_optab_handler.
* expmed.c, expr.c, genopinit.c, ifcvt.c, optabs.c, reload.c,
reload1.c, stmt.c, targhooks.c, tree-ssa-loop-prefetch.c,
tree-ssa-math-opts.c, tree-vect-data-refs.c, tree-vect-generic.c,
tree-vect-loop.c, tree-vect-patterns.c, tree-vect-slp.c,
tree-vect-stmts.c, config/m32c/m32c.c, config/rs6000/rs6000.c,
config/spu/spu.c: Likewise.
From-SVN: r161808
2010-07-05 00:13:09 +02:00
|
|
|
&& (optab_handler (bswap_optab, DImode) != CODE_FOR_nothing
|
2010-01-03 16:23:29 +01:00
|
|
|
|| (bswap32_p && word_mode == SImode)));
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2009-06-24 09:01:24 +02:00
|
|
|
/* Determine the argument type of the builtins. The code later on
|
|
|
|
assumes that the return and argument type are the same. */
|
2012-09-26 15:42:47 +02:00
|
|
|
if (bswap16_p)
|
|
|
|
{
|
|
|
|
tree fndecl = builtin_decl_explicit (BUILT_IN_BSWAP16);
|
|
|
|
bswap16_type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
|
|
|
|
}
|
|
|
|
|
2009-06-24 09:01:24 +02:00
|
|
|
if (bswap32_p)
|
|
|
|
{
|
2011-10-11 21:55:09 +02:00
|
|
|
tree fndecl = builtin_decl_explicit (BUILT_IN_BSWAP32);
|
2009-06-24 09:01:24 +02:00
|
|
|
bswap32_type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bswap64_p)
|
|
|
|
{
|
2011-10-11 21:55:09 +02:00
|
|
|
tree fndecl = builtin_decl_explicit (BUILT_IN_BSWAP64);
|
2009-06-24 09:01:24 +02:00
|
|
|
bswap64_type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
|
|
|
|
}
|
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
memset (&nop_stats, 0, sizeof (nop_stats));
|
2011-04-13 21:39:02 +02:00
|
|
|
memset (&bswap_stats, 0, sizeof (bswap_stats));
|
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
FOR_EACH_BB_FN (bb, fun)
|
2009-06-14 16:45:32 +02:00
|
|
|
{
|
|
|
|
gimple_stmt_iterator gsi;
|
|
|
|
|
2011-06-28 12:36:48 +02:00
|
|
|
/* We do a reverse scan for bswap patterns to make sure we get the
|
|
|
|
widest match. As bswap pattern matching doesn't handle
|
|
|
|
previously inserted smaller bswap replacements as sub-
|
|
|
|
patterns, the wider variant wouldn't be detected. */
|
|
|
|
for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
|
2009-06-14 16:45:32 +02:00
|
|
|
{
|
2014-06-18 12:43:50 +02:00
|
|
|
gimple src_stmt, cur_stmt = gsi_stmt (gsi);
|
|
|
|
tree fndecl = NULL_TREE, bswap_type = NULL_TREE, load_type;
|
2014-05-23 05:33:28 +02:00
|
|
|
struct symbolic_number n;
|
|
|
|
bool bswap;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
if (!is_gimple_assign (cur_stmt)
|
|
|
|
|| gimple_assign_rhs_code (cur_stmt) != BIT_IOR_EXPR)
|
2009-06-14 16:45:32 +02:00
|
|
|
continue;
|
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
src_stmt = find_bswap_or_nop (cur_stmt, &n, &bswap);
|
2014-05-23 05:33:28 +02:00
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
if (!src_stmt)
|
2014-05-23 05:33:28 +02:00
|
|
|
continue;
|
2009-06-14 16:45:32 +02:00
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
switch (n.range)
|
2009-06-14 16:45:32 +02:00
|
|
|
{
|
2012-09-26 15:42:47 +02:00
|
|
|
case 16:
|
2014-05-23 05:33:28 +02:00
|
|
|
load_type = uint16_type_node;
|
2012-09-26 15:42:47 +02:00
|
|
|
if (bswap16_p)
|
|
|
|
{
|
|
|
|
fndecl = builtin_decl_explicit (BUILT_IN_BSWAP16);
|
|
|
|
bswap_type = bswap16_type;
|
|
|
|
}
|
|
|
|
break;
|
2009-06-14 16:45:32 +02:00
|
|
|
case 32:
|
2014-05-23 05:33:28 +02:00
|
|
|
load_type = uint32_type_node;
|
2009-06-14 16:45:32 +02:00
|
|
|
if (bswap32_p)
|
2009-06-24 09:01:24 +02:00
|
|
|
{
|
2011-10-11 21:55:09 +02:00
|
|
|
fndecl = builtin_decl_explicit (BUILT_IN_BSWAP32);
|
2009-06-24 09:01:24 +02:00
|
|
|
bswap_type = bswap32_type;
|
|
|
|
}
|
2009-06-14 16:45:32 +02:00
|
|
|
break;
|
|
|
|
case 64:
|
2014-05-23 05:33:28 +02:00
|
|
|
load_type = uint64_type_node;
|
2009-06-14 16:45:32 +02:00
|
|
|
if (bswap64_p)
|
2009-06-24 09:01:24 +02:00
|
|
|
{
|
2011-10-11 21:55:09 +02:00
|
|
|
fndecl = builtin_decl_explicit (BUILT_IN_BSWAP64);
|
2009-06-24 09:01:24 +02:00
|
|
|
bswap_type = bswap64_type;
|
|
|
|
}
|
2009-06-14 16:45:32 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
if (bswap && !fndecl)
|
2009-06-14 16:45:32 +02:00
|
|
|
continue;
|
|
|
|
|
2014-06-18 12:43:50 +02:00
|
|
|
if (bswap_replace (cur_stmt, gsi, src_stmt, fndecl, bswap_type,
|
|
|
|
load_type, &n, bswap))
|
2014-05-23 05:33:28 +02:00
|
|
|
changed = true;
|
2009-06-14 16:45:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-23 05:33:28 +02:00
|
|
|
statistics_counter_event (fun, "16-bit nop implementations found",
|
|
|
|
nop_stats.found_16bit);
|
|
|
|
statistics_counter_event (fun, "32-bit nop implementations found",
|
|
|
|
nop_stats.found_32bit);
|
|
|
|
statistics_counter_event (fun, "64-bit nop implementations found",
|
|
|
|
nop_stats.found_64bit);
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
statistics_counter_event (fun, "16-bit bswap implementations found",
|
2012-09-26 15:42:47 +02:00
|
|
|
bswap_stats.found_16bit);
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
statistics_counter_event (fun, "32-bit bswap implementations found",
|
2011-04-13 21:39:02 +02:00
|
|
|
bswap_stats.found_32bit);
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
statistics_counter_event (fun, "64-bit bswap implementations found",
|
2011-04-13 21:39:02 +02:00
|
|
|
bswap_stats.found_64bit);
|
|
|
|
|
2014-05-06 15:35:40 +02:00
|
|
|
return (changed ? TODO_update_ssa : 0);
|
2009-06-14 16:45:32 +02:00
|
|
|
}
|
|
|
|
|
2013-08-05 22:16:05 +02:00
|
|
|
} // anon namespace
|
|
|
|
|
|
|
|
gimple_opt_pass *
|
|
|
|
make_pass_optimize_bswap (gcc::context *ctxt)
|
|
|
|
{
|
|
|
|
return new pass_optimize_bswap (ctxt);
|
|
|
|
}
|
|
|
|
|
2012-08-20 14:49:47 +02:00
|
|
|
/* Return true if stmt is a type conversion operation that can be stripped
|
|
|
|
when used in a widening multiply operation. */
|
|
|
|
static bool
|
|
|
|
widening_mult_conversion_strippable_p (tree result_type, gimple stmt)
|
|
|
|
{
|
|
|
|
enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
|
|
|
|
|
|
|
|
if (TREE_CODE (result_type) == INTEGER_TYPE)
|
|
|
|
{
|
|
|
|
tree op_type;
|
|
|
|
tree inner_op_type;
|
|
|
|
|
|
|
|
if (!CONVERT_EXPR_CODE_P (rhs_code))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
op_type = TREE_TYPE (gimple_assign_lhs (stmt));
|
|
|
|
|
|
|
|
/* If the type of OP has the same precision as the result, then
|
|
|
|
we can strip this conversion. The multiply operation will be
|
|
|
|
selected to create the correct extension as a by-product. */
|
|
|
|
if (TYPE_PRECISION (result_type) == TYPE_PRECISION (op_type))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
/* We can also strip a conversion if it preserves the signed-ness of
|
|
|
|
the operation and doesn't narrow the range. */
|
|
|
|
inner_op_type = TREE_TYPE (gimple_assign_rhs1 (stmt));
|
|
|
|
|
2012-09-07 12:37:08 +02:00
|
|
|
/* If the inner-most type is unsigned, then we can strip any
|
|
|
|
intermediate widening operation. If it's signed, then the
|
|
|
|
intermediate widening operation must also be signed. */
|
|
|
|
if ((TYPE_UNSIGNED (inner_op_type)
|
|
|
|
|| TYPE_UNSIGNED (op_type) == TYPE_UNSIGNED (inner_op_type))
|
2012-08-20 14:49:47 +02:00
|
|
|
&& TYPE_PRECISION (op_type) > TYPE_PRECISION (inner_op_type))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rhs_code == FIXED_CONVERT_EXPR;
|
|
|
|
}
|
|
|
|
|
2011-08-19 16:45:56 +02:00
|
|
|
/* Return true if RHS is a suitable operand for a widening multiplication,
|
|
|
|
assuming a target type of TYPE.
|
2010-07-22 23:55:32 +02:00
|
|
|
There are two cases:
|
|
|
|
|
2011-08-19 16:21:48 +02:00
|
|
|
- RHS makes some value at least twice as wide. Store that value
|
|
|
|
in *NEW_RHS_OUT if so, and store its type in *TYPE_OUT.
|
2010-07-22 23:55:32 +02:00
|
|
|
|
|
|
|
- RHS is an integer constant. Store that value in *NEW_RHS_OUT if so,
|
|
|
|
but leave *TYPE_OUT untouched. */
|
2010-06-25 10:56:24 +02:00
|
|
|
|
|
|
|
static bool
|
2011-08-19 16:45:56 +02:00
|
|
|
is_widening_mult_rhs_p (tree type, tree rhs, tree *type_out,
|
|
|
|
tree *new_rhs_out)
|
2010-07-22 23:55:32 +02:00
|
|
|
{
|
|
|
|
gimple stmt;
|
2011-08-19 16:45:56 +02:00
|
|
|
tree type1, rhs1;
|
2010-07-22 23:55:32 +02:00
|
|
|
|
|
|
|
if (TREE_CODE (rhs) == SSA_NAME)
|
|
|
|
{
|
|
|
|
stmt = SSA_NAME_DEF_STMT (rhs);
|
2011-08-19 16:45:56 +02:00
|
|
|
if (is_gimple_assign (stmt))
|
|
|
|
{
|
2012-08-20 14:49:47 +02:00
|
|
|
if (! widening_mult_conversion_strippable_p (type, stmt))
|
2011-08-19 16:45:56 +02:00
|
|
|
rhs1 = rhs;
|
|
|
|
else
|
2011-08-19 17:05:22 +02:00
|
|
|
{
|
|
|
|
rhs1 = gimple_assign_rhs1 (stmt);
|
|
|
|
|
|
|
|
if (TREE_CODE (rhs1) == INTEGER_CST)
|
|
|
|
{
|
|
|
|
*new_rhs_out = rhs1;
|
|
|
|
*type_out = NULL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2011-08-19 16:45:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rhs1 = rhs;
|
2010-07-22 23:55:32 +02:00
|
|
|
|
|
|
|
type1 = TREE_TYPE (rhs1);
|
2011-08-19 16:45:56 +02:00
|
|
|
|
2010-07-22 23:55:32 +02:00
|
|
|
if (TREE_CODE (type1) != TREE_CODE (type)
|
2011-08-19 16:21:48 +02:00
|
|
|
|| TYPE_PRECISION (type1) * 2 > TYPE_PRECISION (type))
|
2010-07-22 23:55:32 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
*new_rhs_out = rhs1;
|
|
|
|
*type_out = type1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TREE_CODE (rhs) == INTEGER_CST)
|
|
|
|
{
|
|
|
|
*new_rhs_out = rhs;
|
|
|
|
*type_out = NULL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-19 16:45:56 +02:00
|
|
|
/* Return true if STMT performs a widening multiplication, assuming the
|
|
|
|
output type is TYPE. If so, store the unwidened types of the operands
|
|
|
|
in *TYPE1_OUT and *TYPE2_OUT respectively. Also fill *RHS1_OUT and
|
|
|
|
*RHS2_OUT such that converting those operands to types *TYPE1_OUT
|
|
|
|
and *TYPE2_OUT would give the operands of the multiplication. */
|
2010-07-22 23:55:32 +02:00
|
|
|
|
|
|
|
static bool
|
2011-10-18 21:57:15 +02:00
|
|
|
is_widening_mult_p (gimple stmt,
|
2010-07-22 23:55:32 +02:00
|
|
|
tree *type1_out, tree *rhs1_out,
|
|
|
|
tree *type2_out, tree *rhs2_out)
|
2010-06-25 10:56:24 +02:00
|
|
|
{
|
2011-10-18 21:57:15 +02:00
|
|
|
tree type = TREE_TYPE (gimple_assign_lhs (stmt));
|
|
|
|
|
2010-07-22 23:55:32 +02:00
|
|
|
if (TREE_CODE (type) != INTEGER_TYPE
|
|
|
|
&& TREE_CODE (type) != FIXED_POINT_TYPE)
|
|
|
|
return false;
|
2010-06-25 10:56:24 +02:00
|
|
|
|
2011-08-19 16:45:56 +02:00
|
|
|
if (!is_widening_mult_rhs_p (type, gimple_assign_rhs1 (stmt), type1_out,
|
|
|
|
rhs1_out))
|
2010-06-25 10:56:24 +02:00
|
|
|
return false;
|
|
|
|
|
2011-08-19 16:45:56 +02:00
|
|
|
if (!is_widening_mult_rhs_p (type, gimple_assign_rhs2 (stmt), type2_out,
|
|
|
|
rhs2_out))
|
2010-07-22 23:55:32 +02:00
|
|
|
return false;
|
2010-06-25 10:56:24 +02:00
|
|
|
|
2010-07-22 23:55:32 +02:00
|
|
|
if (*type1_out == NULL)
|
2010-06-25 10:56:24 +02:00
|
|
|
{
|
2010-07-22 23:55:32 +02:00
|
|
|
if (*type2_out == NULL || !int_fits_type_p (*rhs1_out, *type2_out))
|
2010-06-25 10:56:24 +02:00
|
|
|
return false;
|
2010-07-22 23:55:32 +02:00
|
|
|
*type1_out = *type2_out;
|
2010-06-25 10:56:24 +02:00
|
|
|
}
|
|
|
|
|
2010-07-22 23:55:32 +02:00
|
|
|
if (*type2_out == NULL)
|
2010-06-25 10:56:24 +02:00
|
|
|
{
|
2010-07-22 23:55:32 +02:00
|
|
|
if (!int_fits_type_p (*rhs2_out, *type1_out))
|
2010-06-25 10:56:24 +02:00
|
|
|
return false;
|
2010-07-22 23:55:32 +02:00
|
|
|
*type2_out = *type1_out;
|
2010-06-25 10:56:24 +02:00
|
|
|
}
|
|
|
|
|
2011-08-19 16:41:34 +02:00
|
|
|
/* Ensure that the larger of the two operands comes first. */
|
|
|
|
if (TYPE_PRECISION (*type1_out) < TYPE_PRECISION (*type2_out))
|
|
|
|
{
|
|
|
|
tree tmp;
|
|
|
|
tmp = *type1_out;
|
|
|
|
*type1_out = *type2_out;
|
|
|
|
*type2_out = tmp;
|
|
|
|
tmp = *rhs1_out;
|
|
|
|
*rhs1_out = *rhs2_out;
|
|
|
|
*rhs2_out = tmp;
|
|
|
|
}
|
2011-08-19 16:21:48 +02:00
|
|
|
|
2010-07-22 23:55:32 +02:00
|
|
|
return true;
|
|
|
|
}
|
2010-06-25 10:56:24 +02:00
|
|
|
|
2010-07-22 23:55:32 +02:00
|
|
|
/* Process a single gimple statement STMT, which has a MULT_EXPR as
|
|
|
|
its rhs, and try to convert it into a WIDEN_MULT_EXPR. The return
|
|
|
|
value is true iff we converted the statement. */
|
|
|
|
|
|
|
|
static bool
|
2011-08-19 16:21:48 +02:00
|
|
|
convert_mult_to_widen (gimple stmt, gimple_stmt_iterator *gsi)
|
2010-07-22 23:55:32 +02:00
|
|
|
{
|
2012-08-10 11:20:29 +02:00
|
|
|
tree lhs, rhs1, rhs2, type, type1, type2;
|
2010-07-22 23:55:32 +02:00
|
|
|
enum insn_code handler;
|
2011-08-19 16:21:48 +02:00
|
|
|
enum machine_mode to_mode, from_mode, actual_mode;
|
2011-08-19 16:12:32 +02:00
|
|
|
optab op;
|
2011-08-19 16:21:48 +02:00
|
|
|
int actual_precision;
|
|
|
|
location_t loc = gimple_location (stmt);
|
2011-08-19 16:36:34 +02:00
|
|
|
bool from_unsigned1, from_unsigned2;
|
2010-07-22 23:55:32 +02:00
|
|
|
|
|
|
|
lhs = gimple_assign_lhs (stmt);
|
|
|
|
type = TREE_TYPE (lhs);
|
|
|
|
if (TREE_CODE (type) != INTEGER_TYPE)
|
2010-06-25 10:56:24 +02:00
|
|
|
return false;
|
|
|
|
|
2011-10-18 21:57:15 +02:00
|
|
|
if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2))
|
2010-06-25 10:56:24 +02:00
|
|
|
return false;
|
|
|
|
|
2011-08-19 16:12:32 +02:00
|
|
|
to_mode = TYPE_MODE (type);
|
|
|
|
from_mode = TYPE_MODE (type1);
|
2011-08-19 16:36:34 +02:00
|
|
|
from_unsigned1 = TYPE_UNSIGNED (type1);
|
|
|
|
from_unsigned2 = TYPE_UNSIGNED (type2);
|
2011-08-19 16:12:32 +02:00
|
|
|
|
2011-08-19 16:36:34 +02:00
|
|
|
if (from_unsigned1 && from_unsigned2)
|
2011-08-19 16:12:32 +02:00
|
|
|
op = umul_widen_optab;
|
2011-08-19 16:36:34 +02:00
|
|
|
else if (!from_unsigned1 && !from_unsigned2)
|
2011-08-19 16:12:32 +02:00
|
|
|
op = smul_widen_optab;
|
2010-06-25 10:56:24 +02:00
|
|
|
else
|
2011-08-19 16:12:32 +02:00
|
|
|
op = usmul_widen_optab;
|
|
|
|
|
2011-08-19 16:21:48 +02:00
|
|
|
handler = find_widening_optab_handler_and_mode (op, to_mode, from_mode,
|
|
|
|
0, &actual_mode);
|
2010-07-22 23:55:32 +02:00
|
|
|
|
|
|
|
if (handler == CODE_FOR_nothing)
|
2011-08-19 16:36:34 +02:00
|
|
|
{
|
|
|
|
if (op != smul_widen_optab)
|
|
|
|
{
|
2011-08-19 16:56:24 +02:00
|
|
|
/* We can use a signed multiply with unsigned types as long as
|
|
|
|
there is a wider mode to use, or it is the smaller of the two
|
|
|
|
types that is unsigned. Note that type1 >= type2, always. */
|
|
|
|
if ((TYPE_UNSIGNED (type1)
|
|
|
|
&& TYPE_PRECISION (type1) == GET_MODE_PRECISION (from_mode))
|
|
|
|
|| (TYPE_UNSIGNED (type2)
|
|
|
|
&& TYPE_PRECISION (type2) == GET_MODE_PRECISION (from_mode)))
|
|
|
|
{
|
|
|
|
from_mode = GET_MODE_WIDER_MODE (from_mode);
|
|
|
|
if (GET_MODE_SIZE (to_mode) <= GET_MODE_SIZE (from_mode))
|
|
|
|
return false;
|
|
|
|
}
|
2011-08-19 16:36:34 +02:00
|
|
|
|
|
|
|
op = smul_widen_optab;
|
|
|
|
handler = find_widening_optab_handler_and_mode (op, to_mode,
|
|
|
|
from_mode, 0,
|
|
|
|
&actual_mode);
|
|
|
|
|
|
|
|
if (handler == CODE_FOR_nothing)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
from_unsigned1 = from_unsigned2 = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2010-07-22 23:55:32 +02:00
|
|
|
|
2011-08-19 16:21:48 +02:00
|
|
|
/* Ensure that the inputs to the handler are in the correct precison
|
|
|
|
for the opcode. This will be the full mode size. */
|
|
|
|
actual_precision = GET_MODE_PRECISION (actual_mode);
|
2012-03-07 10:24:40 +01:00
|
|
|
if (2 * actual_precision > TYPE_PRECISION (type))
|
|
|
|
return false;
|
2011-08-19 16:36:34 +02:00
|
|
|
if (actual_precision != TYPE_PRECISION (type1)
|
|
|
|
|| from_unsigned1 != TYPE_UNSIGNED (type1))
|
2012-08-10 11:20:29 +02:00
|
|
|
rhs1 = build_and_insert_cast (gsi, loc,
|
|
|
|
build_nonstandard_integer_type
|
|
|
|
(actual_precision, from_unsigned1), rhs1);
|
2011-08-19 16:36:34 +02:00
|
|
|
if (actual_precision != TYPE_PRECISION (type2)
|
|
|
|
|| from_unsigned2 != TYPE_UNSIGNED (type2))
|
2012-08-10 11:20:29 +02:00
|
|
|
rhs2 = build_and_insert_cast (gsi, loc,
|
|
|
|
build_nonstandard_integer_type
|
|
|
|
(actual_precision, from_unsigned2), rhs2);
|
2011-08-19 16:21:48 +02:00
|
|
|
|
2011-08-19 17:05:22 +02:00
|
|
|
/* Handle constants. */
|
|
|
|
if (TREE_CODE (rhs1) == INTEGER_CST)
|
|
|
|
rhs1 = fold_convert (type1, rhs1);
|
|
|
|
if (TREE_CODE (rhs2) == INTEGER_CST)
|
|
|
|
rhs2 = fold_convert (type2, rhs2);
|
|
|
|
|
2011-08-19 16:21:48 +02:00
|
|
|
gimple_assign_set_rhs1 (stmt, rhs1);
|
|
|
|
gimple_assign_set_rhs2 (stmt, rhs2);
|
2010-06-25 10:56:24 +02:00
|
|
|
gimple_assign_set_rhs_code (stmt, WIDEN_MULT_EXPR);
|
|
|
|
update_stmt (stmt);
|
2011-04-13 21:39:02 +02:00
|
|
|
widen_mul_stats.widen_mults_inserted++;
|
2010-06-25 10:56:24 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Process a single gimple statement STMT, which is found at the
|
|
|
|
iterator GSI and has a either a PLUS_EXPR or a MINUS_EXPR as its
|
|
|
|
rhs (given by CODE), and try to convert it into a
|
|
|
|
WIDEN_MULT_PLUS_EXPR or a WIDEN_MULT_MINUS_EXPR. The return value
|
|
|
|
is true iff we converted the statement. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple stmt,
|
|
|
|
enum tree_code code)
|
|
|
|
{
|
|
|
|
gimple rhs1_stmt = NULL, rhs2_stmt = NULL;
|
2011-08-19 16:31:30 +02:00
|
|
|
gimple conv1_stmt = NULL, conv2_stmt = NULL, conv_stmt;
|
2012-08-10 11:20:29 +02:00
|
|
|
tree type, type1, type2, optype;
|
2010-06-25 10:56:24 +02:00
|
|
|
tree lhs, rhs1, rhs2, mult_rhs1, mult_rhs2, add_rhs;
|
|
|
|
enum tree_code rhs1_code = ERROR_MARK, rhs2_code = ERROR_MARK;
|
|
|
|
optab this_optab;
|
|
|
|
enum tree_code wmult_code;
|
2011-08-19 16:21:48 +02:00
|
|
|
enum insn_code handler;
|
|
|
|
enum machine_mode to_mode, from_mode, actual_mode;
|
|
|
|
location_t loc = gimple_location (stmt);
|
|
|
|
int actual_precision;
|
2011-08-19 16:36:34 +02:00
|
|
|
bool from_unsigned1, from_unsigned2;
|
2010-06-25 10:56:24 +02:00
|
|
|
|
|
|
|
lhs = gimple_assign_lhs (stmt);
|
|
|
|
type = TREE_TYPE (lhs);
|
2010-07-22 23:55:32 +02:00
|
|
|
if (TREE_CODE (type) != INTEGER_TYPE
|
|
|
|
&& TREE_CODE (type) != FIXED_POINT_TYPE)
|
2010-06-25 10:56:24 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (code == MINUS_EXPR)
|
|
|
|
wmult_code = WIDEN_MULT_MINUS_EXPR;
|
|
|
|
else
|
|
|
|
wmult_code = WIDEN_MULT_PLUS_EXPR;
|
|
|
|
|
|
|
|
rhs1 = gimple_assign_rhs1 (stmt);
|
|
|
|
rhs2 = gimple_assign_rhs2 (stmt);
|
|
|
|
|
|
|
|
if (TREE_CODE (rhs1) == SSA_NAME)
|
|
|
|
{
|
|
|
|
rhs1_stmt = SSA_NAME_DEF_STMT (rhs1);
|
|
|
|
if (is_gimple_assign (rhs1_stmt))
|
|
|
|
rhs1_code = gimple_assign_rhs_code (rhs1_stmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TREE_CODE (rhs2) == SSA_NAME)
|
|
|
|
{
|
|
|
|
rhs2_stmt = SSA_NAME_DEF_STMT (rhs2);
|
|
|
|
if (is_gimple_assign (rhs2_stmt))
|
|
|
|
rhs2_code = gimple_assign_rhs_code (rhs2_stmt);
|
|
|
|
}
|
|
|
|
|
2011-08-19 16:31:30 +02:00
|
|
|
/* Allow for one conversion statement between the multiply
|
|
|
|
and addition/subtraction statement. If there are more than
|
|
|
|
one conversions then we assume they would invalidate this
|
|
|
|
transformation. If that's not the case then they should have
|
|
|
|
been folded before now. */
|
|
|
|
if (CONVERT_EXPR_CODE_P (rhs1_code))
|
|
|
|
{
|
|
|
|
conv1_stmt = rhs1_stmt;
|
|
|
|
rhs1 = gimple_assign_rhs1 (rhs1_stmt);
|
|
|
|
if (TREE_CODE (rhs1) == SSA_NAME)
|
|
|
|
{
|
|
|
|
rhs1_stmt = SSA_NAME_DEF_STMT (rhs1);
|
|
|
|
if (is_gimple_assign (rhs1_stmt))
|
|
|
|
rhs1_code = gimple_assign_rhs_code (rhs1_stmt);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (CONVERT_EXPR_CODE_P (rhs2_code))
|
|
|
|
{
|
|
|
|
conv2_stmt = rhs2_stmt;
|
|
|
|
rhs2 = gimple_assign_rhs1 (rhs2_stmt);
|
|
|
|
if (TREE_CODE (rhs2) == SSA_NAME)
|
|
|
|
{
|
|
|
|
rhs2_stmt = SSA_NAME_DEF_STMT (rhs2);
|
|
|
|
if (is_gimple_assign (rhs2_stmt))
|
|
|
|
rhs2_code = gimple_assign_rhs_code (rhs2_stmt);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-19 16:21:48 +02:00
|
|
|
/* If code is WIDEN_MULT_EXPR then it would seem unnecessary to call
|
|
|
|
is_widening_mult_p, but we still need the rhs returns.
|
|
|
|
|
|
|
|
It might also appear that it would be sufficient to use the existing
|
|
|
|
operands of the widening multiply, but that would limit the choice of
|
2013-10-25 19:25:08 +02:00
|
|
|
multiply-and-accumulate instructions.
|
|
|
|
|
|
|
|
If the widened-multiplication result has more than one uses, it is
|
|
|
|
probably wiser not to do the conversion. */
|
2011-08-19 16:21:48 +02:00
|
|
|
if (code == PLUS_EXPR
|
|
|
|
&& (rhs1_code == MULT_EXPR || rhs1_code == WIDEN_MULT_EXPR))
|
2010-06-25 10:56:24 +02:00
|
|
|
{
|
2013-10-25 19:25:08 +02:00
|
|
|
if (!has_single_use (rhs1)
|
|
|
|
|| !is_widening_mult_p (rhs1_stmt, &type1, &mult_rhs1,
|
|
|
|
&type2, &mult_rhs2))
|
2010-06-25 10:56:24 +02:00
|
|
|
return false;
|
2010-07-22 23:55:32 +02:00
|
|
|
add_rhs = rhs2;
|
2011-08-19 16:31:30 +02:00
|
|
|
conv_stmt = conv1_stmt;
|
2010-06-25 10:56:24 +02:00
|
|
|
}
|
2011-08-19 16:21:48 +02:00
|
|
|
else if (rhs2_code == MULT_EXPR || rhs2_code == WIDEN_MULT_EXPR)
|
2010-06-25 10:56:24 +02:00
|
|
|
{
|
2013-10-25 19:25:08 +02:00
|
|
|
if (!has_single_use (rhs2)
|
|
|
|
|| !is_widening_mult_p (rhs2_stmt, &type1, &mult_rhs1,
|
|
|
|
&type2, &mult_rhs2))
|
2010-06-25 10:56:24 +02:00
|
|
|
return false;
|
2010-07-22 23:55:32 +02:00
|
|
|
add_rhs = rhs1;
|
2011-08-19 16:31:30 +02:00
|
|
|
conv_stmt = conv2_stmt;
|
2010-06-25 10:56:24 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
2011-08-19 16:21:48 +02:00
|
|
|
to_mode = TYPE_MODE (type);
|
|
|
|
from_mode = TYPE_MODE (type1);
|
2011-08-19 16:36:34 +02:00
|
|
|
from_unsigned1 = TYPE_UNSIGNED (type1);
|
|
|
|
from_unsigned2 = TYPE_UNSIGNED (type2);
|
2011-12-20 22:33:48 +01:00
|
|
|
optype = type1;
|
2011-08-19 16:21:48 +02:00
|
|
|
|
2011-08-19 16:36:34 +02:00
|
|
|
/* There's no such thing as a mixed sign madd yet, so use a wider mode. */
|
|
|
|
if (from_unsigned1 != from_unsigned2)
|
|
|
|
{
|
2011-12-20 22:33:48 +01:00
|
|
|
if (!INTEGRAL_TYPE_P (type))
|
|
|
|
return false;
|
2011-08-19 16:56:24 +02:00
|
|
|
/* We can use a signed multiply with unsigned types as long as
|
|
|
|
there is a wider mode to use, or it is the smaller of the two
|
|
|
|
types that is unsigned. Note that type1 >= type2, always. */
|
|
|
|
if ((from_unsigned1
|
|
|
|
&& TYPE_PRECISION (type1) == GET_MODE_PRECISION (from_mode))
|
|
|
|
|| (from_unsigned2
|
|
|
|
&& TYPE_PRECISION (type2) == GET_MODE_PRECISION (from_mode)))
|
2011-08-19 16:36:34 +02:00
|
|
|
{
|
2011-08-19 16:56:24 +02:00
|
|
|
from_mode = GET_MODE_WIDER_MODE (from_mode);
|
|
|
|
if (GET_MODE_SIZE (from_mode) >= GET_MODE_SIZE (to_mode))
|
|
|
|
return false;
|
2011-08-19 16:36:34 +02:00
|
|
|
}
|
2011-08-19 16:56:24 +02:00
|
|
|
|
|
|
|
from_unsigned1 = from_unsigned2 = false;
|
2011-12-20 22:33:48 +01:00
|
|
|
optype = build_nonstandard_integer_type (GET_MODE_PRECISION (from_mode),
|
|
|
|
false);
|
2011-08-19 16:36:34 +02:00
|
|
|
}
|
2010-07-31 17:51:17 +02:00
|
|
|
|
2011-08-19 16:31:30 +02:00
|
|
|
/* If there was a conversion between the multiply and addition
|
|
|
|
then we need to make sure it fits a multiply-and-accumulate.
|
|
|
|
The should be a single mode change which does not change the
|
|
|
|
value. */
|
|
|
|
if (conv_stmt)
|
|
|
|
{
|
2011-08-19 16:36:34 +02:00
|
|
|
/* We use the original, unmodified data types for this. */
|
2011-08-19 16:31:30 +02:00
|
|
|
tree from_type = TREE_TYPE (gimple_assign_rhs1 (conv_stmt));
|
|
|
|
tree to_type = TREE_TYPE (gimple_assign_lhs (conv_stmt));
|
|
|
|
int data_size = TYPE_PRECISION (type1) + TYPE_PRECISION (type2);
|
|
|
|
bool is_unsigned = TYPE_UNSIGNED (type1) && TYPE_UNSIGNED (type2);
|
|
|
|
|
|
|
|
if (TYPE_PRECISION (from_type) > TYPE_PRECISION (to_type))
|
|
|
|
{
|
|
|
|
/* Conversion is a truncate. */
|
|
|
|
if (TYPE_PRECISION (to_type) < data_size)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (TYPE_PRECISION (from_type) < TYPE_PRECISION (to_type))
|
|
|
|
{
|
|
|
|
/* Conversion is an extend. Check it's the right sort. */
|
|
|
|
if (TYPE_UNSIGNED (from_type) != is_unsigned
|
|
|
|
&& !(is_unsigned && TYPE_PRECISION (from_type) > data_size))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
/* else convert is a no-op for our purposes. */
|
|
|
|
}
|
|
|
|
|
2010-07-31 17:51:17 +02:00
|
|
|
/* Verify that the machine can perform a widening multiply
|
|
|
|
accumulate in this mode/signedness combination, otherwise
|
|
|
|
this transformation is likely to pessimize code. */
|
2011-08-19 16:36:34 +02:00
|
|
|
this_optab = optab_for_tree_code (wmult_code, optype, optab_default);
|
2011-08-19 16:21:48 +02:00
|
|
|
handler = find_widening_optab_handler_and_mode (this_optab, to_mode,
|
|
|
|
from_mode, 0, &actual_mode);
|
|
|
|
|
|
|
|
if (handler == CODE_FOR_nothing)
|
2010-07-31 17:51:17 +02:00
|
|
|
return false;
|
|
|
|
|
2011-08-19 16:21:48 +02:00
|
|
|
/* Ensure that the inputs to the handler are in the correct precison
|
|
|
|
for the opcode. This will be the full mode size. */
|
|
|
|
actual_precision = GET_MODE_PRECISION (actual_mode);
|
2011-08-19 16:36:34 +02:00
|
|
|
if (actual_precision != TYPE_PRECISION (type1)
|
|
|
|
|| from_unsigned1 != TYPE_UNSIGNED (type1))
|
2012-08-10 11:20:29 +02:00
|
|
|
mult_rhs1 = build_and_insert_cast (gsi, loc,
|
|
|
|
build_nonstandard_integer_type
|
|
|
|
(actual_precision, from_unsigned1),
|
|
|
|
mult_rhs1);
|
2011-08-19 16:36:34 +02:00
|
|
|
if (actual_precision != TYPE_PRECISION (type2)
|
|
|
|
|| from_unsigned2 != TYPE_UNSIGNED (type2))
|
2012-08-10 11:20:29 +02:00
|
|
|
mult_rhs2 = build_and_insert_cast (gsi, loc,
|
|
|
|
build_nonstandard_integer_type
|
|
|
|
(actual_precision, from_unsigned2),
|
|
|
|
mult_rhs2);
|
2010-06-25 10:56:24 +02:00
|
|
|
|
2011-08-19 17:01:41 +02:00
|
|
|
if (!useless_type_conversion_p (type, TREE_TYPE (add_rhs)))
|
2012-08-10 11:20:29 +02:00
|
|
|
add_rhs = build_and_insert_cast (gsi, loc, type, add_rhs);
|
2011-08-19 17:01:41 +02:00
|
|
|
|
2011-08-19 17:05:22 +02:00
|
|
|
/* Handle constants. */
|
|
|
|
if (TREE_CODE (mult_rhs1) == INTEGER_CST)
|
2011-09-08 21:45:37 +02:00
|
|
|
mult_rhs1 = fold_convert (type1, mult_rhs1);
|
2011-08-19 17:05:22 +02:00
|
|
|
if (TREE_CODE (mult_rhs2) == INTEGER_CST)
|
2011-09-08 21:45:37 +02:00
|
|
|
mult_rhs2 = fold_convert (type2, mult_rhs2);
|
2011-08-19 17:05:22 +02:00
|
|
|
|
2011-08-19 16:21:48 +02:00
|
|
|
gimple_assign_set_rhs_with_ops_1 (gsi, wmult_code, mult_rhs1, mult_rhs2,
|
2010-06-25 10:56:24 +02:00
|
|
|
add_rhs);
|
|
|
|
update_stmt (gsi_stmt (*gsi));
|
2011-04-13 21:39:02 +02:00
|
|
|
widen_mul_stats.maccs_inserted++;
|
2010-06-25 10:56:24 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-30 17:55:35 +01:00
|
|
|
/* Combine the multiplication at MUL_STMT with operands MULOP1 and MULOP2
|
|
|
|
with uses in additions and subtractions to form fused multiply-add
|
|
|
|
operations. Returns true if successful and MUL_STMT should be removed. */
|
2010-11-04 11:56:22 +01:00
|
|
|
|
|
|
|
static bool
|
2010-11-30 17:55:35 +01:00
|
|
|
convert_mult_to_fma (gimple mul_stmt, tree op1, tree op2)
|
2010-11-04 11:56:22 +01:00
|
|
|
{
|
2010-11-30 17:55:35 +01:00
|
|
|
tree mul_result = gimple_get_lhs (mul_stmt);
|
2010-11-04 11:56:22 +01:00
|
|
|
tree type = TREE_TYPE (mul_result);
|
2010-11-11 17:20:54 +01:00
|
|
|
gimple use_stmt, neguse_stmt, fma_stmt;
|
2010-11-04 11:56:22 +01:00
|
|
|
use_operand_p use_p;
|
|
|
|
imm_use_iterator imm_iter;
|
|
|
|
|
|
|
|
if (FLOAT_TYPE_P (type)
|
|
|
|
&& flag_fp_contract_mode == FP_CONTRACT_OFF)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* We don't want to do bitfield reduction ops. */
|
|
|
|
if (INTEGRAL_TYPE_P (type)
|
|
|
|
&& (TYPE_PRECISION (type)
|
|
|
|
!= GET_MODE_PRECISION (TYPE_MODE (type))))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* If the target doesn't support it, don't generate it. We assume that
|
|
|
|
if fma isn't available then fms, fnma or fnms are not either. */
|
|
|
|
if (optab_handler (fma_optab, TYPE_MODE (type)) == CODE_FOR_nothing)
|
|
|
|
return false;
|
|
|
|
|
2011-12-05 21:56:14 +01:00
|
|
|
/* If the multiplication has zero uses, it is kept around probably because
|
|
|
|
of -fnon-call-exceptions. Don't optimize it away in that case,
|
|
|
|
it is DCE job. */
|
|
|
|
if (has_zero_uses (mul_result))
|
|
|
|
return false;
|
|
|
|
|
2010-11-04 11:56:22 +01:00
|
|
|
/* Make sure that the multiplication statement becomes dead after
|
|
|
|
the transformation, thus that all uses are transformed to FMAs.
|
|
|
|
This means we assume that an FMA operation has the same cost
|
|
|
|
as an addition. */
|
|
|
|
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, mul_result)
|
|
|
|
{
|
|
|
|
enum tree_code use_code;
|
2010-11-11 17:20:54 +01:00
|
|
|
tree result = mul_result;
|
|
|
|
bool negate_p = false;
|
2010-11-04 11:56:22 +01:00
|
|
|
|
|
|
|
use_stmt = USE_STMT (use_p);
|
|
|
|
|
2010-11-15 13:04:46 +01:00
|
|
|
if (is_gimple_debug (use_stmt))
|
|
|
|
continue;
|
|
|
|
|
2010-11-04 11:56:22 +01:00
|
|
|
/* For now restrict this operations to single basic blocks. In theory
|
|
|
|
we would want to support sinking the multiplication in
|
|
|
|
m = a*b;
|
|
|
|
if ()
|
|
|
|
ma = m + c;
|
|
|
|
else
|
|
|
|
d = m;
|
|
|
|
to form a fma in the then block and sink the multiplication to the
|
|
|
|
else block. */
|
|
|
|
if (gimple_bb (use_stmt) != gimple_bb (mul_stmt))
|
|
|
|
return false;
|
|
|
|
|
2010-11-11 17:20:54 +01:00
|
|
|
if (!is_gimple_assign (use_stmt))
|
2010-11-04 11:56:22 +01:00
|
|
|
return false;
|
|
|
|
|
2010-11-11 17:20:54 +01:00
|
|
|
use_code = gimple_assign_rhs_code (use_stmt);
|
|
|
|
|
|
|
|
/* A negate on the multiplication leads to FNMA. */
|
|
|
|
if (use_code == NEGATE_EXPR)
|
|
|
|
{
|
2011-03-11 17:36:16 +01:00
|
|
|
ssa_op_iter iter;
|
2011-06-10 14:18:55 +02:00
|
|
|
use_operand_p usep;
|
2011-03-11 17:36:16 +01:00
|
|
|
|
2010-11-11 17:20:54 +01:00
|
|
|
result = gimple_assign_lhs (use_stmt);
|
|
|
|
|
|
|
|
/* Make sure the negate statement becomes dead with this
|
|
|
|
single transformation. */
|
|
|
|
if (!single_imm_use (gimple_assign_lhs (use_stmt),
|
|
|
|
&use_p, &neguse_stmt))
|
|
|
|
return false;
|
|
|
|
|
2011-03-11 17:36:16 +01:00
|
|
|
/* Make sure the multiplication isn't also used on that stmt. */
|
2011-06-10 14:18:55 +02:00
|
|
|
FOR_EACH_PHI_OR_STMT_USE (usep, neguse_stmt, iter, SSA_OP_USE)
|
|
|
|
if (USE_FROM_PTR (usep) == mul_result)
|
2011-03-11 17:36:16 +01:00
|
|
|
return false;
|
|
|
|
|
2010-11-11 17:20:54 +01:00
|
|
|
/* Re-validate. */
|
|
|
|
use_stmt = neguse_stmt;
|
|
|
|
if (gimple_bb (use_stmt) != gimple_bb (mul_stmt))
|
|
|
|
return false;
|
|
|
|
if (!is_gimple_assign (use_stmt))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
use_code = gimple_assign_rhs_code (use_stmt);
|
|
|
|
negate_p = true;
|
|
|
|
}
|
2010-11-04 11:56:22 +01:00
|
|
|
|
2010-11-11 17:20:54 +01:00
|
|
|
switch (use_code)
|
|
|
|
{
|
|
|
|
case MINUS_EXPR:
|
2010-11-11 19:42:35 +01:00
|
|
|
if (gimple_assign_rhs2 (use_stmt) == result)
|
|
|
|
negate_p = !negate_p;
|
|
|
|
break;
|
2010-11-11 17:20:54 +01:00
|
|
|
case PLUS_EXPR:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* FMA can only be formed from PLUS and MINUS. */
|
|
|
|
return false;
|
|
|
|
}
|
2010-11-04 11:56:22 +01:00
|
|
|
|
2013-04-10 11:54:25 +02:00
|
|
|
/* If the subtrahend (gimple_assign_rhs2 (use_stmt)) is computed
|
|
|
|
by a MULT_EXPR that we'll visit later, we might be able to
|
|
|
|
get a more profitable match with fnma.
|
|
|
|
OTOH, if we don't, a negate / fma pair has likely lower latency
|
|
|
|
that a mult / subtract pair. */
|
|
|
|
if (use_code == MINUS_EXPR && !negate_p
|
|
|
|
&& gimple_assign_rhs1 (use_stmt) == result
|
|
|
|
&& optab_handler (fms_optab, TYPE_MODE (type)) == CODE_FOR_nothing
|
|
|
|
&& optab_handler (fnma_optab, TYPE_MODE (type)) != CODE_FOR_nothing)
|
|
|
|
{
|
|
|
|
tree rhs2 = gimple_assign_rhs2 (use_stmt);
|
|
|
|
|
2013-05-03 13:18:37 +02:00
|
|
|
if (TREE_CODE (rhs2) == SSA_NAME)
|
|
|
|
{
|
|
|
|
gimple stmt2 = SSA_NAME_DEF_STMT (rhs2);
|
|
|
|
if (has_single_use (rhs2)
|
|
|
|
&& is_gimple_assign (stmt2)
|
|
|
|
&& gimple_assign_rhs_code (stmt2) == MULT_EXPR)
|
|
|
|
return false;
|
|
|
|
}
|
2013-04-10 11:54:25 +02:00
|
|
|
}
|
|
|
|
|
2010-11-11 17:20:54 +01:00
|
|
|
/* We can't handle a * b + a * b. */
|
|
|
|
if (gimple_assign_rhs1 (use_stmt) == gimple_assign_rhs2 (use_stmt))
|
|
|
|
return false;
|
2010-11-11 19:42:35 +01:00
|
|
|
|
|
|
|
/* While it is possible to validate whether or not the exact form
|
|
|
|
that we've recognized is available in the backend, the assumption
|
|
|
|
is that the transformation is never a loss. For instance, suppose
|
|
|
|
the target only has the plain FMA pattern available. Consider
|
|
|
|
a*b-c -> fma(a,b,-c): we've exchanged MUL+SUB for FMA+NEG, which
|
|
|
|
is still two operations. Consider -(a*b)-c -> fma(-a,b,-c): we
|
|
|
|
still have 3 operations, but in the FMA form the two NEGs are
|
2012-05-29 16:14:06 +02:00
|
|
|
independent and could be run in parallel. */
|
2010-11-04 11:56:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, mul_result)
|
|
|
|
{
|
|
|
|
gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt);
|
2010-11-15 13:04:46 +01:00
|
|
|
enum tree_code use_code;
|
2010-11-30 17:55:35 +01:00
|
|
|
tree addop, mulop1 = op1, result = mul_result;
|
2010-11-11 17:20:54 +01:00
|
|
|
bool negate_p = false;
|
2010-11-04 11:56:22 +01:00
|
|
|
|
2010-11-15 13:04:46 +01:00
|
|
|
if (is_gimple_debug (use_stmt))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
use_code = gimple_assign_rhs_code (use_stmt);
|
2010-11-11 17:20:54 +01:00
|
|
|
if (use_code == NEGATE_EXPR)
|
|
|
|
{
|
|
|
|
result = gimple_assign_lhs (use_stmt);
|
|
|
|
single_imm_use (gimple_assign_lhs (use_stmt), &use_p, &neguse_stmt);
|
|
|
|
gsi_remove (&gsi, true);
|
|
|
|
release_defs (use_stmt);
|
|
|
|
|
|
|
|
use_stmt = neguse_stmt;
|
|
|
|
gsi = gsi_for_stmt (use_stmt);
|
|
|
|
use_code = gimple_assign_rhs_code (use_stmt);
|
|
|
|
negate_p = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimple_assign_rhs1 (use_stmt) == result)
|
2010-11-04 11:56:22 +01:00
|
|
|
{
|
|
|
|
addop = gimple_assign_rhs2 (use_stmt);
|
|
|
|
/* a * b - c -> a * b + (-c) */
|
|
|
|
if (gimple_assign_rhs_code (use_stmt) == MINUS_EXPR)
|
|
|
|
addop = force_gimple_operand_gsi (&gsi,
|
|
|
|
build1 (NEGATE_EXPR,
|
|
|
|
type, addop),
|
|
|
|
true, NULL_TREE, true,
|
|
|
|
GSI_SAME_STMT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
addop = gimple_assign_rhs1 (use_stmt);
|
|
|
|
/* a - b * c -> (-b) * c + a */
|
|
|
|
if (gimple_assign_rhs_code (use_stmt) == MINUS_EXPR)
|
2010-11-11 17:20:54 +01:00
|
|
|
negate_p = !negate_p;
|
2010-11-04 11:56:22 +01:00
|
|
|
}
|
|
|
|
|
2010-11-11 17:20:54 +01:00
|
|
|
if (negate_p)
|
|
|
|
mulop1 = force_gimple_operand_gsi (&gsi,
|
|
|
|
build1 (NEGATE_EXPR,
|
|
|
|
type, mulop1),
|
|
|
|
true, NULL_TREE, true,
|
|
|
|
GSI_SAME_STMT);
|
|
|
|
|
2012-09-18 11:17:27 +02:00
|
|
|
fma_stmt = gimple_build_assign_with_ops (FMA_EXPR,
|
|
|
|
gimple_assign_lhs (use_stmt),
|
|
|
|
mulop1, op2,
|
|
|
|
addop);
|
2010-11-04 11:56:22 +01:00
|
|
|
gsi_replace (&gsi, fma_stmt, true);
|
2011-04-13 21:39:02 +02:00
|
|
|
widen_mul_stats.fmas_inserted++;
|
2010-11-04 11:56:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-04-22 11:30:27 +02:00
|
|
|
/* Find integer multiplications where the operands are extended from
|
|
|
|
smaller types, and replace the MULT_EXPR with a WIDEN_MULT_EXPR
|
|
|
|
where appropriate. */
|
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
const pass_data pass_data_optimize_widening_mul =
|
|
|
|
{
|
|
|
|
GIMPLE_PASS, /* type */
|
|
|
|
"widening_mul", /* name */
|
|
|
|
OPTGROUP_NONE, /* optinfo_flags */
|
|
|
|
TV_NONE, /* tv_id */
|
|
|
|
PROP_ssa, /* properties_required */
|
|
|
|
0, /* properties_provided */
|
|
|
|
0, /* properties_destroyed */
|
|
|
|
0, /* todo_flags_start */
|
2014-05-06 15:35:40 +02:00
|
|
|
TODO_update_ssa, /* todo_flags_finish */
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class pass_optimize_widening_mul : public gimple_opt_pass
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
pass_optimize_widening_mul (gcc::context *ctxt)
|
|
|
|
: gimple_opt_pass (pass_data_optimize_widening_mul, ctxt)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/* opt_pass methods: */
|
|
|
|
virtual bool gate (function *)
|
|
|
|
{
|
|
|
|
return flag_expensive_optimizations && optimize;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual unsigned int execute (function *);
|
|
|
|
|
|
|
|
}; // class pass_optimize_widening_mul
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
pass_optimize_widening_mul::execute (function *fun)
|
2010-04-22 11:30:27 +02:00
|
|
|
{
|
|
|
|
basic_block bb;
|
2010-11-30 17:55:35 +01:00
|
|
|
bool cfg_changed = false;
|
2010-04-22 11:30:27 +02:00
|
|
|
|
2011-04-13 21:39:02 +02:00
|
|
|
memset (&widen_mul_stats, 0, sizeof (widen_mul_stats));
|
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
FOR_EACH_BB_FN (bb, fun)
|
2010-04-22 11:30:27 +02:00
|
|
|
{
|
|
|
|
gimple_stmt_iterator gsi;
|
|
|
|
|
2010-11-04 11:56:22 +01:00
|
|
|
for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi);)
|
2010-04-22 11:30:27 +02:00
|
|
|
{
|
|
|
|
gimple stmt = gsi_stmt (gsi);
|
2010-06-25 10:56:24 +02:00
|
|
|
enum tree_code code;
|
2010-04-22 11:30:27 +02:00
|
|
|
|
2010-11-04 11:56:22 +01:00
|
|
|
if (is_gimple_assign (stmt))
|
|
|
|
{
|
|
|
|
code = gimple_assign_rhs_code (stmt);
|
|
|
|
switch (code)
|
|
|
|
{
|
|
|
|
case MULT_EXPR:
|
2011-08-19 16:21:48 +02:00
|
|
|
if (!convert_mult_to_widen (stmt, &gsi)
|
2010-11-30 17:55:35 +01:00
|
|
|
&& convert_mult_to_fma (stmt,
|
|
|
|
gimple_assign_rhs1 (stmt),
|
|
|
|
gimple_assign_rhs2 (stmt)))
|
2010-11-04 11:56:22 +01:00
|
|
|
{
|
|
|
|
gsi_remove (&gsi, true);
|
|
|
|
release_defs (stmt);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PLUS_EXPR:
|
|
|
|
case MINUS_EXPR:
|
|
|
|
convert_plusminus_to_widen (&gsi, stmt, code);
|
|
|
|
break;
|
2010-04-22 11:30:27 +02:00
|
|
|
|
2010-11-04 11:56:22 +01:00
|
|
|
default:;
|
|
|
|
}
|
|
|
|
}
|
2010-12-07 13:36:40 +01:00
|
|
|
else if (is_gimple_call (stmt)
|
|
|
|
&& gimple_call_lhs (stmt))
|
2010-11-30 17:55:35 +01:00
|
|
|
{
|
|
|
|
tree fndecl = gimple_call_fndecl (stmt);
|
|
|
|
if (fndecl
|
|
|
|
&& DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
|
|
|
|
{
|
|
|
|
switch (DECL_FUNCTION_CODE (fndecl))
|
|
|
|
{
|
|
|
|
case BUILT_IN_POWF:
|
|
|
|
case BUILT_IN_POW:
|
|
|
|
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)
|
|
|
|
&& convert_mult_to_fma (stmt,
|
|
|
|
gimple_call_arg (stmt, 0),
|
|
|
|
gimple_call_arg (stmt, 0)))
|
|
|
|
{
|
2010-12-07 11:07:36 +01:00
|
|
|
unlink_stmt_vdef (stmt);
|
2012-04-05 11:43:48 +02:00
|
|
|
if (gsi_remove (&gsi, true)
|
|
|
|
&& gimple_purge_dead_eh_edges (bb))
|
2010-11-30 17:55:35 +01:00
|
|
|
cfg_changed = true;
|
2012-04-05 11:43:48 +02:00
|
|
|
release_defs (stmt);
|
2010-11-30 17:55:35 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-11-04 11:56:22 +01:00
|
|
|
gsi_next (&gsi);
|
2010-04-22 11:30:27 +02:00
|
|
|
}
|
|
|
|
}
|
2010-06-25 10:56:24 +02:00
|
|
|
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
statistics_counter_event (fun, "widening multiplications inserted",
|
2011-04-13 21:39:02 +02:00
|
|
|
widen_mul_stats.widen_mults_inserted);
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
statistics_counter_event (fun, "widening maccs inserted",
|
2011-04-13 21:39:02 +02:00
|
|
|
widen_mul_stats.maccs_inserted);
|
pass cfun to pass::execute
gcc/
* passes.c (opt_pass::execute): Adjust.
(pass_manager::execute_pass_mode_switching): Likewise.
(early_local_passes::execute): Likewise.
(execute_one_pass): Pass cfun to the pass's execute method.
* tree-pass.h (opt_pass::execute): Add function * argument.
* asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c, cfgcleanup.c,
cfgexpand.c, cfgrtl.c, cgraphbuild.c, combine-stack-adj.c, combine.c,
compare-elim.c, config/arc/arc.c, config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/i386/i386.c,
config/mips/mips.c, config/rl78/rl78.c, config/s390/s390.c,
config/sparc/sparc.c, cprop.c, dce.c, df-core.c, dse.c, dwarf2cfi.c,
except.c, final.c, function.c, fwprop.c, gcse.c, gimple-low.c,
gimple-ssa-isolate-paths.c, gimple-ssa-strength-reduction.c,
graphite.c, ifcvt.c, init-regs.c, ipa-cp.c, ipa-devirt.c,
ipa-inline-analysis.c, ipa-inline.c, ipa-profile.c, ipa-pure-const.c,
ipa-reference.c, ipa-split.c, ipa.c, ira.c, jump.c, loop-init.c,
lower-subreg.c, mode-switching.c, omp-low.c, postreload-gcse.c,
postreload.c, predict.c, recog.c, ree.c, reg-stack.c, regcprop.c,
reginfo.c, regrename.c, reorg.c, sched-rgn.c, stack-ptr-mod.c,
store-motion.c, tracer.c, trans-mem.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-eh.c, tree-emutls.c,
tree-if-conv.c, tree-into-ssa.c, tree-loop-distribution.c, tree-nrv.c,
tree-object-size.c, tree-parloops.c, tree-predcom.c, tree-ssa-ccp.c,
tree-ssa-copy.c, tree-ssa-copyrename.c, tree-ssa-dce.c,
tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-loop-ch.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop-unswitch.c, tree-ssa-loop.c, tree-ssa-math-opts.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-ssa-uninit.c,
tree-ssa.c, tree-ssanames.c, tree-stdarg.c, tree-switch-conversion.c,
tree-tailcall.c, tree-vect-generic.c, tree-vectorizer.c, tree-vrp.c,
tree.c, tsan.c, ubsan.c, var-tracking.c, vtable-verify.c, web.c:
Adjust.
From-SVN: r209482
2014-04-17 14:37:34 +02:00
|
|
|
statistics_counter_event (fun, "fused multiply-adds inserted",
|
2011-04-13 21:39:02 +02:00
|
|
|
widen_mul_stats.fmas_inserted);
|
|
|
|
|
2010-11-30 17:55:35 +01:00
|
|
|
return cfg_changed ? TODO_cleanup_cfg : 0;
|
2010-04-22 11:30:27 +02:00
|
|
|
}
|
|
|
|
|
2013-08-05 22:16:05 +02:00
|
|
|
} // anon namespace
|
|
|
|
|
|
|
|
gimple_opt_pass *
|
|
|
|
make_pass_optimize_widening_mul (gcc::context *ctxt)
|
|
|
|
{
|
|
|
|
return new pass_optimize_widening_mul (ctxt);
|
|
|
|
}
|