summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
Commit message (Collapse)AuthorAgeFilesLines
* 2015-11-12 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>naveenh2015-11-121-45/+0
| | | | | | | | | | | | | | | | | | | * fold-const.c (fold_binary_loc) : Move Convert A/B/C to A/(B*C) to match.pd. Move Convert A/(B/C) to (A/B)*C to match.pd. Move Convert C1/(X*C2) into (C1/C2)/X to match.pd. Move Optimize (X & (-A)) / A where A is a power of 2, to X >> log2(A) to match.pd. * match.pd (rdiv (rdiv:s @0 @1) @2): New simplifier. (rdiv @0 (rdiv:s @1 @2)): New simplifier. (div (convert? (bit_and @0 INTEGER_CST@1)) INTEGER_CST@2): New simplifier. (rdiv REAL_CST@0 (mult @1 REAL_CST@2)): New simplifier. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230204 138bc75d-0d04-0410-961f-82ee72b054a4
* Fix whitespace+typo from "Share code from fold_array_ctor_reference with fold."alalaw012015-11-111-29/+29
| | | | | | | * fold-const.c (get_array_ctor_element_at_index): Fix whitespace, typo. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230159 138bc75d-0d04-0410-961f-82ee72b054a4
* PR middle-end/68253ebotcazou2015-11-091-0/+1
| | | | | | | * fold-const.c (fold_truth_andor_1): Initialize new variables to 0. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230011 138bc75d-0d04-0410-961f-82ee72b054a4
* Add TARGET_ADDR_SPACE_ZERO_ADDRESS_VALIDrth2015-11-091-1/+5
| | | | | | | | | | | | | * gimple.c (check_loadstore): Return false when 0 is a valid address. * fold-const.c (const_unop) [ADDR_SPACE_CONVERT_EXPR]: Do not fold null when 0 is valid in the source address space. * target.def (TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID): New. * targhooks.c (default_addr_space_zero_address_valid): New. * targhooks.h (default_addr_space_zero_address_valid): Declare. * doc/tm.texi.in (TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID): Mark it. * doc/tm.texi: Rebuild. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229999 138bc75d-0d04-0410-961f-82ee72b054a4
* Avoid CSE of MEMs in different address spacesrth2015-11-091-7/+7
| | | | | | | | | | * cselib.c (add_mem_for_addr): Compare address spaces when matching memories. (cselib_lookup_mem): Likewise. * fold-const.c (operand_equal_p): Check address spaces of pointer types before checking integer constants. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229998 138bc75d-0d04-0410-961f-82ee72b054a4
* Merge of the scalar-storage-order branch.ebotcazou2015-11-081-53/+79
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229965 138bc75d-0d04-0410-961f-82ee72b054a4
* Move c_getstr to fold-const.crsandifo2015-11-071-0/+21
| | | | | | | | | | | | | | | | | | | Upcoming patches to fold-const-call.c want to use c_getstr, which is currently defined in builtins.c. The function doesn't really do anything related to built-ins, and I'd rather not make fold-const-call.c depend on builtins.c and builtins.c depend on fold-const-call.c, so this patch moves the function to fold-const.c instead. Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. gcc/ * builtins.h (c_getstr): Move to... * fold-const.h (c_getstr): ...here. * builtins.c (c_getstr): Move to... * fold-const.c (c_getstr): ...here. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229919 138bc75d-0d04-0410-961f-82ee72b054a4
* * tree-core.h (size_type_kind): Remove OEP_CONSTANT_ADDRESS_OF andhubicka2015-11-061-23/+24
| | | | | | | | | | | add OEP_MATCH_SIDE_EFFECTS. * fold-const.c (operand_equal_p): Update documentation; handle OEP_MATCH_SIDE_EFFECTS. * tree-ssa-tail-merge.c (gimple_operand_equal_value_p): Use OEP_MATCH_SIDE_EFFECTS. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229867 138bc75d-0d04-0410-961f-82ee72b054a4
* Move constant folds for maths functions to new filersandifo2015-11-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new routines operate on the built-in enum rather than on tree decls. The idea is to extend this to handle internal functions too, with a combined enum for both. The patch also moves fold_fma too, with the same prototype. The long-term plan is to replace FMA_EXPR with an internal function, for consistency with the way that things like SQRT will be handled. Tested on x86_64-linux-gnu, arm-linux-gnueabi and aarch64-linux-gnu. gcc/ * builtins.h (fold_fma): Move to fold-const-call.h. * builtins.c: Include fold-const-call.h. (mathfn_built_in_2): New function, split out from... (mathfn_built_in_1): ...here. (do_real_to_int_conversion, fold_const_builtin_pow) (fold_const_builtin_logb, fold_const_builtin_significand) (fold_const_builtin_load_exponent, do_mpfr_arg1, do_mpfr_arg2) (do_mpfr_arg3, do_mpfr_sincos, do_mpfr_bessel_n, do_mpc_arg1): Delete. (fold_builtin_sincos): Use fold_const_call to handle constants. (fold_builtin_1, fold_builtin_2, fold_builtin_3): Add explicit checks for ERROR_MARK. Use fold_const_call to handle constant folds for math functions. (fold_fma): Move to fold-const-call.c. * fold-const.c: Include fold-const-call.h. * Makefile.in (OBJS): Add fold-const-call.o. (PLUGIN_HEADERS): Add fold-const-call.h. * realmpfr.h (real_from_mpfr): Allow the format to be specified directly. * realmpfr.c (real_from_mpfr): Likewise. * fold-const-call.h, fold-const-call.c: New files. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229669 138bc75d-0d04-0410-961f-82ee72b054a4
* [PR middle-end/68166] Restore build with fold checking enabledtschwinge2015-11-021-0/+1
| | | | | | | | gcc/ PR middle-end/68166 * fold-const.c: Include "md5.h". git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229652 138bc75d-0d04-0410-961f-82ee72b054a4
* Tune pointer-plus foldingvries2015-10-311-6/+4
| | | | | | | | | | | 2015-10-31 Tom de Vries <tom@codesourcery.com> * fold-const.c (fold_unary_loc): Tune POINTER_PLUS_EXPR folding. * gfortran.dg/assumed_type_2.f90: Update test. * gfortran.dg/no_arg_check_2.f90: Same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229621 138bc75d-0d04-0410-961f-82ee72b054a4
* Share code from fold_array_ctor_reference with fold.alalaw012015-10-301-25/+71
| | | | | | | | | | | * gimple-fold.c (fold_array_ctor_reference): Move searching code to: * fold-const.c (get_array_ctor_element_at_index): New. (fold): Remove binary-search through CONSTRUCTOR, call previous. * fold-const.h (get_array_ctor_element_at_index): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229605 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-10-30 Andrew MacLeod <amacleod@redhat.com>amacleod2015-10-301-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alias.c: Remove unused headers. * asan.c: Likewise. * attribs.c: Likewise. * auto-inc-dec.c: Likewise. * auto-profile.c: Likewise. * bb-reorder.c: Likewise. * bitmap.c: Likewise. * bt-load.c: Likewise. * builtins.c: Likewise. * caller-save.c: Likewise. * calls.c: Likewise. * ccmp.c: Likewise. * cfg.c: Likewise. * cfganal.c: Likewise. * cfgbuild.c: Likewise. * cfgcleanup.c: Likewise. * cfgexpand.c: Likewise. * cfghooks.c: Likewise. * cfgloop.c: Likewise. * cfgloopanal.c: Likewise. * cfgloopmanip.c: Likewise. * cfgrtl.c: Likewise. * cgraph.c: Likewise. * cgraphbuild.c: Likewise. * cgraphclones.c: Likewise. * cgraphunit.c: Likewise. * cilk-common.c: Likewise. * combine-stack-adj.c: Likewise. * combine.c: Likewise. * compare-elim.c: Likewise. * convert.c: Likewise. * coverage.c: Likewise. * cppbuiltin.c: Likewise. * cprop.c: Likewise. * cse.c: Likewise. * cselib.c: Likewise. * data-streamer-in.c: Likewise. * data-streamer-out.c: Likewise. * data-streamer.c: Likewise. * dbxout.c: Likewise. * dce.c: Likewise. * ddg.c: Likewise. * debug.c: Likewise. * df-core.c: Likewise. * df-problems.c: Likewise. * df-scan.c: Likewise. * dfp.c: Likewise. * dojump.c: Likewise. * dominance.c: Likewise. * domwalk.c: Likewise. * double-int.c: Likewise. * dse.c: Likewise. * dumpfile.c: Likewise. * dwarf2asm.c: Likewise. * dwarf2cfi.c: Likewise. * dwarf2out.c: Likewise. * emit-rtl.c: Likewise. * except.c: Likewise. * explow.c: Likewise. * expmed.c: Likewise. * expr.c: Likewise. * final.c: Likewise. * fixed-value.c: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * fwprop.c: Likewise. * gcse.c: Likewise. * generic-match-head.c: Likewise. * ggc-common.c: Likewise. * gimple-builder.c: Likewise. * gimple-expr.c: Likewise. * gimple-fold.c: Likewise. * gimple-iterator.c: Likewise. * gimple-low.c: Likewise. * gimple-match-head.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. * gimple-walk.c: Likewise. * gimple.c: Likewise. * gimplify-me.c: Likewise. * gimplify.c: Likewise. * godump.c: Likewise. * graph.c: Likewise. * graphds.c: Likewise. * haifa-sched.c: Likewise. * hw-doloop.c: Likewise. * ifcvt.c: Likewise. * init-regs.c: Likewise. * internal-fn.c: Likewise. * ipa-chkp.c: Likewise. * ipa-comdats.c: Likewise. * ipa-cp.c: Likewise. * ipa-devirt.c: Likewise. * ipa-icf-gimple.c: Likewise. * ipa-icf.c: Likewise. * ipa-inline-analysis.c: Likewise. * ipa-inline-transform.c: Likewise. * ipa-inline.c: Likewise. * ipa-polymorphic-call.c: Likewise. * ipa-profile.c: Likewise. * ipa-prop.c: Likewise. * ipa-pure-const.c: Likewise. * ipa-ref.c: Likewise. * ipa-reference.c: Likewise. * ipa-split.c: Likewise. * ipa-utils.c: Likewise. * ipa-visibility.c: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-conflicts.c: Likewise. * ira-costs.c: Likewise. * ira-emit.c: Likewise. * ira-lives.c: Likewise. * ira.c: Likewise. * jump.c: Likewise. * langhooks.c: Likewise. * lcm.c: Likewise. * lists.c: Likewise. * loop-doloop.c: Likewise. * loop-init.c: Likewise. * loop-invariant.c: Likewise. * loop-iv.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lra-assigns.c: Likewise. * lra-coalesce.c: Likewise. * lra-constraints.c: Likewise. * lra-eliminations.c: Likewise. * lra-lives.c: Likewise. * lra-remat.c: Likewise. * lra-spills.c: Likewise. * lra.c: Likewise. * lto-cgraph.c: Likewise. * lto-compress.c: Likewise. * lto-opts.c: Likewise. * lto-section-in.c: Likewise. * lto-section-out.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * lto-streamer.c: Likewise. * mcf.c: Likewise. * mode-switching.c: Likewise. * modulo-sched.c: Likewise. * optabs.c: Likewise. * opts-global.c: Likewise. * passes.c: Likewise. * plugin.c: Likewise. * postreload-gcse.c: Likewise. * postreload.c: Likewise. * predict.c: Likewise. * print-tree.c: Likewise. * profile.c: Likewise. * real.c: Likewise. * realmpfr.c: Likewise. * recog.c: Likewise. * ree.c: Likewise. * reg-stack.c: Likewise. * regcprop.c: Likewise. * reginfo.c: Likewise. * regrename.c: Likewise. * regstat.c: Likewise. * reload.c: Likewise. * reload1.c: Likewise. * reorg.c: Likewise. * resource.c: Likewise. * rtl-chkp.c: Likewise. * rtl-error.c: Likewise. * rtlanal.c: Likewise. * rtlhooks.c: Likewise. * sanopt.c: Likewise. * sched-deps.c: Likewise. * sched-ebb.c: Likewise. * sched-rgn.c: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-ir.c: Likewise. * sel-sched.c: Likewise. * sese.c: Likewise. * shrink-wrap.c: Likewise. * simplify-rtx.c: Likewise. * stack-ptr-mod.c: Likewise. * statistics.c: Likewise. * stmt.c: Likewise. * stor-layout.c: Likewise. * store-motion.c: Likewise. * stringpool.c: Likewise. * symtab.c: Likewise. * target-globals.c: Likewise. * targhooks.c: Likewise. * toplev.c: Likewise. * tracer.c: Likewise. * trans-mem.c: Likewise. * tree-affine.c: Likewise. * tree-call-cdce.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chkp-opt.c: Likewise. * tree-chkp.c: Likewise. * tree-chrec.c: Likewise. * tree-complex.c: Likewise. * tree-data-ref.c: Likewise. * tree-dfa.c: Likewise. * tree-diagnostic.c: Likewise. * tree-dump.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-iterator.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-phinodes.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-profile.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-copy.c: Likewise. * tree-ssa-dce.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-unswitch.c: Likewise. * tree-ssa-loop.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-scopedtables.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-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-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. * ubsan.c: Likewise. * value-prof.c: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * vmsdbgout.c: Likewise. * vtable-verify.c: Likewise. * web.c: Likewise. * wide-int-print.cc: Likewise. * wide-int.cc: Likewise. * xcoffout.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229585 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-10-30 Richard Biener <rguenther@suse.de>rguenth2015-10-301-19/+6
| | | | | | | | | | | * gimple-fold.c (fold_gimple_assign): Do not dispatch to fold () on single RHSs. Allow CONSTRUCTORS with trailing zeros to be folded to VECTOR_CSTs. * tree.c (build_vector_from_ctor): Handle VECTOR_CST elements. * fold-const.c (fold): Use build_vector_from_ctor. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229574 138bc75d-0d04-0410-961f-82ee72b054a4
* Allow CAST_RESTRICT foldingvries2015-10-291-1/+0
| | | | | | | | | 2015-10-29 Tom de Vries <tom@codesourcery.com> * fold-const.c (fold_unary_loc): Remove folding inhibition for restrict types. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229537 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-10-29 Richard Biener <rguenther@suse.de>rguenth2015-10-291-2/+11
| | | | | | | | | | | PR middle-end/68142 * fold-const.c (extract_muldiv_1): Avoid introducing undefined overflow. * c-c++-common/ubsan/pr68142.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229528 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-10-29 Andrew MacLeod <amacleod@redhat.com>amacleod2015-10-291-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alias.c: Reorder #include statements and remove duplicates. * asan.c: Likewise. * attribs.c: Likewise. * auto-inc-dec.c: Likewise. * auto-profile.c: Likewise. * bb-reorder.c: Likewise. * bt-load.c: Likewise. * builtins.c: Likewise. * caller-save.c: Likewise. * calls.c: Likewise. * ccmp.c: Likewise. * cfg.c: Likewise. * cfganal.c: Likewise. * cfgbuild.c: Likewise. * cfgcleanup.c: Likewise. * cfgexpand.c: Likewise. * cfghooks.c: Likewise. * cfgloop.c: Likewise. * cfgloopanal.c: Likewise. * cfgloopmanip.c: Likewise. * cfgrtl.c: Likewise. * cgraph.c: Likewise. * cgraphbuild.c: Likewise. * cgraphclones.c: Likewise. * cgraphunit.c: Likewise. * cilk-common.c: Likewise. * combine-stack-adj.c: Likewise. * combine.c: Likewise. * compare-elim.c: Likewise. * convert.c: Likewise. * coverage.c: Likewise. * cppbuiltin.c: Likewise. * cprop.c: Likewise. * cse.c: Likewise. * cselib.c: Likewise. * data-streamer-in.c: Likewise. * data-streamer-out.c: Likewise. * data-streamer.c: Likewise. * dbxout.c: Likewise. * dce.c: Likewise. * ddg.c: Likewise. * debug.c: Likewise. * df-core.c: Likewise. * df-problems.c: Likewise. * df-scan.c: Likewise. * dfp.c: Likewise. * dojump.c: Likewise. * dominance.c: Likewise. * double-int.c: Likewise. * dse.c: Likewise. * dumpfile.c: Likewise. * dwarf2asm.c: Likewise. * dwarf2cfi.c: Likewise. * dwarf2out.c: Likewise. * emit-rtl.c: Likewise. * except.c: Likewise. * explow.c: Likewise. * expmed.c: Likewise. * expr.c: Likewise. * final.c: Likewise. * fixed-value.c: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * fwprop.c: Likewise. * gcse.c: Likewise. * generic-match-head.c: Likewise. * ggc-common.c: Likewise. * gimple-builder.c: Likewise. * gimple-expr.c: Likewise. * gimple-fold.c: Likewise. * gimple-iterator.c: Likewise. * gimple-low.c: Likewise. * gimple-match-head.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. * gimple-walk.c: Likewise. * gimple.c: Likewise. * gimplify-me.c: Likewise. * gimplify.c: Likewise. * godump.c: Likewise. * graph.c: Likewise. * graphite-poly.c: Likewise. * haifa-sched.c: Likewise. * hw-doloop.c: Likewise. * ifcvt.c: Likewise. * incpath.c: Likewise. * init-regs.c: Likewise. * internal-fn.c: Likewise. * ipa-chkp.c: Likewise. * ipa-comdats.c: Likewise. * ipa-cp.c: Likewise. * ipa-devirt.c: Likewise. * ipa-icf-gimple.c: Likewise. * ipa-icf.c: Likewise. * ipa-inline-analysis.c: Likewise. * ipa-inline-transform.c: Likewise. * ipa-inline.c: Likewise. * ipa-polymorphic-call.c: Likewise. * ipa-profile.c: Likewise. * ipa-prop.c: Likewise. * ipa-pure-const.c: Likewise. * ipa-ref.c: Likewise. * ipa-reference.c: Likewise. * ipa-split.c: Likewise. * ipa-utils.c: Likewise. * ipa-visibility.c: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-conflicts.c: Likewise. * ira-costs.c: Likewise. * ira-emit.c: Likewise. * ira-lives.c: Likewise. * ira.c: Likewise. * jump.c: Likewise. * langhooks.c: Likewise. * lcm.c: Likewise. * lists.c: Likewise. * loop-doloop.c: Likewise. * loop-init.c: Likewise. * loop-invariant.c: Likewise. * loop-iv.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lra-assigns.c: Likewise. * lra-coalesce.c: Likewise. * lra-constraints.c: Likewise. * lra-eliminations.c: Likewise. * lra-lives.c: Likewise. * lra-remat.c: Likewise. * lra-spills.c: Likewise. * lra.c: Likewise. * lto-cgraph.c: Likewise. * lto-compress.c: Likewise. * lto-opts.c: Likewise. * lto-section-in.c: Likewise. * lto-section-out.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * lto-streamer.c: Likewise. * mode-switching.c: Likewise. * modulo-sched.c: Likewise. * omp-low.c: Likewise. * optabs.c: Likewise. * opts-global.c: Likewise. * passes.c: Likewise. * plugin.c: Likewise. * postreload-gcse.c: Likewise. * postreload.c: Likewise. * predict.c: Likewise. * print-tree.c: Likewise. * profile.c: Likewise. * real.c: Likewise. * realmpfr.c: Likewise. * recog.c: Likewise. * ree.c: Likewise. * reg-stack.c: Likewise. * regcprop.c: Likewise. * reginfo.c: Likewise. * regrename.c: Likewise. * regstat.c: Likewise. * reload.c: Likewise. * reload1.c: Likewise. * reorg.c: Likewise. * resource.c: Likewise. * rtl-chkp.c: Likewise. * rtl-error.c: Likewise. * rtlanal.c: Likewise. * rtlhooks.c: Likewise. * sanopt.c: Likewise. * sched-deps.c: Likewise. * sched-ebb.c: Likewise. * sched-rgn.c: Likewise. * sese.c: Likewise. * shrink-wrap.c: Likewise. * simplify-rtx.c: Likewise. * stack-ptr-mod.c: Likewise. * statistics.c: Likewise. * stmt.c: Likewise. * stor-layout.c: Likewise. * store-motion.c: Likewise. * stringpool.c: Likewise. * symtab.c: Likewise. * target-globals.c: Likewise. * targhooks.c: Likewise. * toplev.c: Likewise. * tracer.c: Likewise. * trans-mem.c: Likewise. * tree-affine.c: Likewise. * tree-call-cdce.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chkp-opt.c: Likewise. * tree-chkp.c: Likewise. * tree-chrec.c: Likewise. * tree-complex.c: Likewise. * tree-data-ref.c: Likewise. * tree-dfa.c: Likewise. * tree-diagnostic.c: Likewise. * tree-dump.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-iterator.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-phinodes.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-profile.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-copy.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-unswitch.c: Likewise. * tree-ssa-loop.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-scopedtables.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-ssanames.c: Likewise. * tree-stdarg.c: Likewise. * tree-streamer-in.c: Likewise. * tree-streamer-out.c: Likewise. * tree-streamer.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. * ubsan.c: Likewise. * value-prof.c: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * vtable-verify.c: Likewise. * web.c: Likewise. * wide-int-print.cc: Likewise. * wide-int.cc: Likewise. * xcoffout.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229526 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-10-29 Richard Biener <rguenther@suse.de>rguenth2015-10-291-4/+2
| | | | | | | | | | | PR middle-end/56956 * fold-const.c (fold_cond_expr_with_comparison): Do not fold unsigned conditonal negation to ABS_EXPR. * c-c++-common/ubsan/pr56956.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229517 138bc75d-0d04-0410-961f-82ee72b054a4
* * fold-const.c (operand_equal_p): Do not verify that types arehubicka2015-10-281-3/+0
| | | | | | | compatible for MEM_REFs. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229494 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-10-28 Richard Biener <rguenther@suse.de>rguenth2015-10-281-55/+28
| | | | | | | | | * fold-const.c (negate_expr_p): Adjust the division case to properly avoid introducing undefined overflow. (fold_negate_expr): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229484 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-10-28 Richard Biener <rguenther@suse.de>rguenth2015-10-281-3/+16
| | | | | | | | | | | | | | PR middle-end/68067 * fold-const.c (negate_expr_p): We cannot negate plus or minus if overflow is not wrapping. Likewise multiplication unless one operand is constant and not power of two. (fold_negate_expr): Adjust accordingly. * gcc.dg/torture/pr68067-1.c: New testcase. * gcc.dg/torture/pr68067-2.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229479 138bc75d-0d04-0410-961f-82ee72b054a4
* Move min(max...) and max(min...) folds to match.pdrsandifo2015-10-271-51/+0
| | | | | | | | | | | | | | | This handles both integer and floating-point arguments. It's needed for the follow-on patch to move fmin and fmax to match.pd. Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. gcc/ * fold-const.c (fold_minmax): Delete. (fold_binary_loc): Don't call it. * match.pd: Add rules previously handled by fold_minmax. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229430 138bc75d-0d04-0410-961f-82ee72b054a4
* * fold-const.c (operand_equal_p): Handle VIEW_CONVERT_EXPR.hubicka2015-10-231-0/+1
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229278 138bc75d-0d04-0410-961f-82ee72b054a4
* * fold-const.c (operand_equal_p): Do not compare TYPE_MODE whenhubicka2015-10-231-3/+4
| | | | | | | comparing addresses. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229265 138bc75d-0d04-0410-961f-82ee72b054a4
* * fold-const.c (operand_equal_p): Handle matching of vectorhubicka2015-10-231-0/+50
| | | | | | | | constructors. * gcc.dg/tree-ssa/operand-equal-2.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229264 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-10-23 Richard Biener <rguenther@suse.de>naveenh2015-10-231-44/+0
| | | | | | | | | | | | | | | | | | | | | | | Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com> * fold-const.c (fold_binary_loc) : Move Fold (A & ~B) - (A & B) into (A ^ B) - B to match.pd Move (X & ~Y) | (~X & Y) is X ^ Y to match.pd. * match.pd (minus (bit_and:cs @0 (bit_not @1)) (bit_and:s @0 @1)): New simplifier. (minus (bit_and:s @0 INTEGER_CST@2) (bit_and:s @0 INTEGER_CST@1)): New simplifier. (minus (bit_and:s @0 @1) (bit_and:cs @0 (bit_not @1))): New simplifier. (bit_ior:c (bit_and:c @0 (bit_not @1)) (bit_and:c (bit_not @0) @1)): New simplifier. (bit_ior:c (bit_and @0 INTEGER_CST@2) (bit_and (bit_not @0) INTEGER_CST@1)): New simplifier. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229225 138bc75d-0d04-0410-961f-82ee72b054a4
* Move fold_trunc_transparent_mathfn to match.pdrsandifo2015-10-231-8/+214
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This moves the fold rules for trunc, floor, ceil, round, nearbyint and rint in one go, since they're tested as a group. Most of the code is supporting the f(x)->x fold when x is known to be integer-valued. Like with the non-negative test, this is probably more elegantly handled by tracking range information for reals, but until that happens, I think we should handle it analogously to tree_expr_nonnegative_p. I've incorporated the fix for PR68031 in the new version of integer_valued_real_p. However, it seemed confusing to test for an SSA name at the head of the function rather than the case statement, and not fall through to tree_simple_nonnegative_warnv_p (which conceptually shouldn't care whether an update is in progress). But tree_simple_nonnegative_warnv_p is a no-op for SSA names, so I simply changed it to: return (!name_registered_for_update_p (t) && depth < PARAM_VALUE (PARAM_MAX_SSA_NAME_QUERY_DEPTH) && gimple_stmt_nonnegative_warnv_p (SSA_NAME_DEF_STMT (t), strict_overflow_p, depth)); and used that in the new code too. Doing these folds later meant that IPA would start to use information about the aborting sinf and floor in 20030125-1.c before the folds kicked in. I changed them from noinline to weak to stop that. Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. gcc/ * builtins.c (integer_valued_real_p): Move to fold-const.c. (fold_trunc_transparent_mathfn, fold_builtin_trunc, fold_builtin_floor) (fold_builtin_ceil, fold_builtin_round): Delete. (fold_builtin_1): Handle constant trunc, floor, ceil and round arguments here. * convert.c (convert_to_real): Remove narrowing of rounding functions. * fold-const.h (integer_valued_real_unary_p) (integer_valued_real_binary_p, integer_valued_real_call_p) (integer_valued_real_single_p, integer_valued_real_p): Declare. * fold-const.c (tree_single_nonnegative_warnv_p): Move name_registered_for_update_p check to SSA_NAME case statement. Don't call tree_simple_nonnegative_warnv_p for SSA names. (integer_valued_real_unary_p, integer_valued_real_binary_p) (integer_valued_real_call_p, integer_valued_real_single_p) (integer_valued_real_invalid_p): New functions. (integer_valued_real_p): Move from fold-const.c and rework to call the functions above. Handle SSA names. * gimple-fold.h (gimple_stmt_integer_valued_real_p): Declare. * gimple-fold.c (gimple_assign_integer_valued_real_p) (gimple_call_integer_valued_real_p, gimple_phi_integer_valued_real_p) (gimple_stmt_integer_valued_real_p): New functions. * match.pd: Fold f(f(x))->f(x) for fp->fp rounding functions f. Fold f(x)->x for the same f if x is known to be integer-valued. Fold f(extend(x))->extend(f'(x)) if doing so doesn't affect the result. Canonicalize floor(x) as trunc(x) if x is nonnegative. gcc/testsuite/ * gcc.c-torture/execute/20030125-1.c (floor, floorf, sin, sinf): Make weak rather than noinline. * gcc.dg/builtins-57.c: Compile with -O. * gcc.dg/torture/builtin-integral-1.c: Skip for -O0. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229221 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-10-22 Richard Biener <rguenther@suse.de>rguenth2015-10-221-45/+5
| | | | | | | | | | | | | | | | | | | | * fold-const.c (fold_addr_of_array_ref_difference): Properly convert operands before folding a MINUS_EXPR. (fold_binary_loc): Move simplification of MINUS_EXPR on converted POINTER_PLUS_EXPRs ... * match.pd: ... here. c/ * c-typeck.c (c_finish_omp_clauses): Properly convert operands before folding a MINUS_EXPR. cp/ * semantics.c (cp_finish_omp_clause_depend_sink): Properly convert before folding a MINUS_EXPR. (finish_omp_clauses): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229167 138bc75d-0d04-0410-961f-82ee72b054a4
* * fold-const.c (operand_equal_p): Add code matching emptyhubicka2015-10-211-0/+5
| | | | | | | | | | constructors. * gcc.dg/tree-ssa/operand-equal-1.c: Verify that empty constructors are matched. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229147 138bc75d-0d04-0410-961f-82ee72b054a4
* * tree.def (CEIL_DIV_EXPR, FLOOR_DIV_EXPR, ROUND_DIV_EXPR): Tweakebotcazou2015-10-211-3/+5
| | | | | | | | | | | | | comments. (TRUNC_MOD_EXPR, CEIL_MOD_EXPR, FLOOR_MOD_EXPR, ROUND_MOD_EXPR): Add comments on sign of the result. * fold-const.c (tree_binary_nonnegative_warnv_p) <FLOOR_MOD_EXPR>: Recurse on operand #1 instead of operand #0. <CEIL_MOD_EXPR>: Do not recurse. <ROUND_MOD_EXPR>: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229146 138bc75d-0d04-0410-961f-82ee72b054a4
* Remove fold_strip_sign_opsrsandifo2015-10-211-96/+0
| | | | | | | | | | | | | | | | | | | | | | | | | This patch deletes fold_strip_sign_ops in favour of the gimple-ssa-backprop.c pass. Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. gcc/ * fold-const.h (fold_strip_sign_ops): Delete. * fold-const.c (fold_strip_sign_ops): Likewise. (fold_unary_loc, fold_binary_loc): Remove calls to it. * builtins.c (fold_builtin_cos, fold_builtin_cosh) (fold_builtin_ccos): Delete. (fold_builtin_pow): Don't call fold_strip_sign_ops. (fold_builtin_hypot, fold_builtin_copysign): Likewise. Remove fndecl argument. (fold_builtin_1): Update calls accordingly. Handle constant cos, cosh, ccos and ccosh here. gcc/testsuite/ * gcc.dg/torture/builtin-symmetric-1.c: Don't run at -O0. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229140 138bc75d-0d04-0410-961f-82ee72b054a4
* Add a pass to back-propagate use informationrsandifo2015-10-211-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a pass that collects information that is common to all uses of an SSA name X and back-propagates that information up the statements that generate X. The general idea is to use the information to simplify instructions (rather than a pure DCE) so I've simply called it gimple-ssa-backprop.c, to go with tree-ssa-forwprop.c. At the moment the only use of the pass is to remove unnecessary sign operations, so that it's effectively a global version of fold_strip_sign_ops. I'm hoping it could be extended in future to record which bits of an integer are significant. There are probably other potential uses too. A later patch gets rid of fold_strip_sign_ops. Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. gcc/ * doc/invoke.texi (-fdump-tree-backprop, -fssa-backprop): Document. * Makefile.in (OBJS): Add gimple-ssa-backprop.o. * common.opt (fssa-backprop): New option. * fold-const.h (negate_mathfn_p): Declare. * fold-const.c (negate_mathfn_p): Make public. * timevar.def (TV_TREE_BACKPROP): New. * tree-pass.h (make_pass_backprop): Declare. * passes.def (pass_backprop): Add. * gimple-ssa-backprop.c: New file. gcc/testsuite/ * gcc.dg/tree-ssa/backprop-1.c, gcc.dg/tree-ssa/backprop-2.c, gcc.dg/tree-ssa/backprop-3.c, gcc.dg/tree-ssa/backprop-4.c, gcc.dg/tree-ssa/backprop-5.c, gcc.dg/tree-ssa/backprop-6.c: New tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229139 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-10-21 Richard Biener <rguenther@suse.de>rguenth2015-10-211-21/+16
| | | | | | | | | | | | | PR middle-end/68031 * fold-const.c: Include tree-ssa-operands.h and tree-into-ssa.h. (tree_ssa_name_nonnegative_warnv_p): Fold into ... (tree_single_nonnegative_warnv_p): ... here. For SSA names make sure they are not registered for update. * gcc.dg/torture/pr68031.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229118 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-10-20 Richard Biener <rguenther@suse.de>naveenh2015-10-211-55/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com> * fold-const.c (fold_binary_loc) : Move (-A) * (-B) -> A * B to match.pd. Move (a * (1 << b)) is (a << b) to match.pd. Move convert (C1/X)*C2 into (C1*C2)/X to match.pd. Move ~X & X, (X == 0) & X, and !X & X are zero to match.pd. Move X & ~X , X & (X == 0), and X & !X are zero to match.pd. * match.pd (mult:c @0 (convert? (lshift integer_onep@1 @2))): New simplifier. (mult (rdiv:s REAL_CST@0 @1) REAL_CST@2): New simplifier. (bit_and:c (convert? @0) (convert? (bit_not @0))): New simplifier. (bit_ior (bit_and:s @0 (bit_not:s @1)) (bit_and:s (bit_not:s @0) @1)) : New simplifier. (mult:c (convert1? (negate @0)) (convert2? negate_expr_p@1)): New simplifier. (match (logical_inverted_value @0) (truth_not @0)) : New Predicate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229107 138bc75d-0d04-0410-961f-82ee72b054a4
* * fold-const.c (fold_comparsion): Pass OEP_ADDRESS_OF when comparinghubicka2015-10-121-2/+3
| | | | | | | | addresses. (fold_addr_of_array_ref_difference): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228701 138bc75d-0d04-0410-961f-82ee72b054a4
* * fold-const.c (operand_equal_p): Document OEP_ADDRESS_OFhubicka2015-10-101-47/+86
| | | | | | | | and OEP_CONSTANT_ADDRESS_OF; skip type compatibility checks when OEP_ADDRESS_OF is se. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228679 138bc75d-0d04-0410-961f-82ee72b054a4
* Make tree_expr_nonnegative_warnv_p recurse into SSA namesrsandifo2015-10-081-87/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The upcoming patch to move sqrt and cbrt simplifications to match.pd caused a regression because the (abs @0)->@0 simplification didn't trigger for: (abs (convert (abs X))) The simplification is based on tree_expr_nonnegative_p, which at the moment just gives up if it sees an SSA_NAME. This patch makes tree_expr_nonnegative_p recurse into SSA name definitions, but limits the depth of recursion to a small number for the reason mentioned in the comment (adapted from an existing comment in gimple_val_nonnegative_real_p). The patch reuses code in tree-vrp.c, moving it to gimple-fold.c. It also replaces calls to gimple_val_nonnegative_real_p with calls to tree_expr_nonnegative_p. A knock-on effect is that we can now prove _i_589 < 0 is false in sequences like: i_1917 = ASSERT_EXPR <i_1075, i_1075 == 0>; _i_589 = (const int) i_1917; _i_1507 = ASSERT_EXPR <_i_589, _i_589 < 0>; This defeats an assert in tree-vrp.c that ASSERT_EXPR conditions are never known to be false. Previously the assert only ever used local knowledge and so would be limited to cases like x != x for integer x. Now that we use global knowledge it's possible to prove the assertion condition is false in blocks that are in practice unreachable. The patch therefore removes the assert. Bootstrapped & regression-tested on x86_64-linux-gnu. I didn't write a specific test because this is already covered by the testsuite if the follow-on patch is also applied. gcc/ * params.def (PARAM_MAX_SSA_NAME_QUERY_DEPTH): New param. * doc/invoke.texi (--param max-ssa-name-query-depth): Document. * fold-const.h (tree_unary_nonnegative_warnv_p) (tree_single_nonnegative_warnv_p, tree_call_nonnegative_warnv_p) (tree_expr_nonnegative_warnv_p): Add depth parameters. * fold-const.c: Include gimple-fold.h and params.h. (tree_ssa_name_nonnegative_warnv_p): New function. (tree_unary_nonnegative_warnv_p, tree_binary_nonnegative_warnv_p) (tree_single_nonnegative_warnv_p, tree_call_nonnegative_warnv_p) (tree_invalid_nonnegative_warnv_p, tree_expr_nonnegative_warnv_p): Add a depth parameter and increment it for recursive calls to tree_expr_nonnegative_warnv_p. Use tree_ssa_name_nonnegative_warnv_p to handle SSA names. * gimple-fold.h (gimple_val_nonnegative_real_p): Delete. (gimple_stmt_nonnegative_warnv_p): Declare. * tree-vrp.c (remove_range_assertions): Remove assert that condition cannot be proven false. (gimple_assign_nonnegative_warnv_p, gimple_call_nonnegative_warnv_p) (gimple_stmt_nonnegative_warnv_p): Move to... * gimple-fold.c: ...here. Add depth parameters and pass them down to the tree routines. Accept statements that aren't assignments or calls but just return false for them. (gimple_val_nonnegative_real_p): Delete. * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Use tree_expr_nonnegative_p instead of gimple_val_nonnegative_real_p. Check HONOR_NANs first. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228614 138bc75d-0d04-0410-961f-82ee72b054a4
* Replace REAL_VALUES_LESS with real_lessrsandifo2015-10-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch continues the removal of real-related macros by replacing REAL_VALUES_LESS with real_less. Bootstrapped & regression-tested on x86_64-linux-gnu. Also tested by building one target per CPU directory and checking that there were no new warnings and no changes in testsuite output at -O2. gcc/ada/ * gcc-interface/trans.c (convert_with_check): Use real_less instead of REAL_VALUES_LESS. gcc/ * doc/tm.texi.in (REAL_VALUES_LESS): Delete. * doc/tm.texi: Regenerate. * real.h (real_less): Declare. (REAL_VALUES_LESS): Delete. * real.c (real_less): New function. (real_compare): Use it. * config/m68k/m68k.c (floating_exact_log2): Use real_less instead of REAL_VALUES_LESS. * config/microblaze/microblaze.c (microblaze_const_double_ok): Likewise. * fold-const.c (fold_convert_const_int_from_real): Likewise. * simplify-rtx.c (simplify_const_unary_operation): Likewise. (simplify_const_relational_operation): Likewise. * tree-call-cdce.c (check_pow): Likewise. (gen_conditions_for_pow_cst_base): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228475 138bc75d-0d04-0410-961f-82ee72b054a4
* Remove remaining uses of REAL_VALUES_IDENTICALrsandifo2015-10-051-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch continues the removal of real-related macros. We already had both the old-style REAL_VALUES_IDENTICAL and the new-style real_identical, so this patch replaces all remaining uses of the former with the latter. Bootstrapped & regression-tested on x86_64-linux-gnu. Also tested by building one target per CPU directory and checking that there were no new warnings and no changes in testsuite output at -O2. gcc/ * real.h (REAL_VALUES_IDENTICAL): Delete. * config/m68k/m68k.c (standard_68881_constant_p): Use real_identical instead of REAL_VALUES_IDENTICAL. * fold-const.c (operand_equal_p): Likewise. * ipa-icf.c (sem_variable::equals): Likewise. * tree-complex.c (some_nonzerop): Likewise. (expand_complex_multiplication): Likewise. * tree.c (simple_cst_equal): Likewise. * varasm.c (compare_constant): Likewise. --- gcc/config/m68k/m68k.c | 5 ++--- gcc/fold-const.c | 3 +-- gcc/ipa-icf.c | 4 ++-- gcc/real.h | 1 - gcc/tree-complex.c | 4 ++-- gcc/tree.c | 2 +- gcc/varasm.c | 2 +- 7 files changed, 9 insertions(+), 12 deletions(-) git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228474 138bc75d-0d04-0410-961f-82ee72b054a4
* Replace REAL_VALUES_EQUAL with real_equalrsandifo2015-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Richard B suggested we should replace dconsthalf etc. with dconst<1, 2> (). When I tried that, the extra comma caused problems with some lingering uses of the old target macros for handling reals (e.g. REAL_ARITHMETIC instead of real_arithmetic), since the constant was then treated as two macro parameters. It would have been possible to add an extra level of brackets to avoid this, but I thought I might as well take the opportunity to remove the macros instead. (Note that I'm only removing macros that caused a problem directly, or are closely related to ones that did.) This first patch replaces REAL_VALUES_EQUAL with a real_equal function. The prototype is the same as for real_identical, which has already undergone a half-transition in this direction. Bootstrapped & regression-tested on x86_64-linux-gnu. Also tested by building one target per CPU directory and checking that there were no new warnings and no changes in testsuite output at -O2. gcc/c-family/ * c-lex.c (interpret_float): Use real_equal instead of REAL_VALUES_EQUAL. gcc/c/ * c-typeck.c (c_tree_equal): Use real_equal instead of REAL_VALUES_EQUAL. gcc/cp/ * tree.c (cp_tree_equal): Use real_equal instead of REAL_VALUES_EQUAL. gcc/ * real.h (real_equal): Declare. (REAL_VALUES_EQUAL): Delete. * real.c (real_equal): New function. (real_compare): Use it. * doc/tm.texi.in (REAL_VALUES_EQUAL): Delete. * doc/tm.texi: Regenerate. * builtins.c (fold_builtin_pow, fold_builtin_load_exponent): Use real_equal instead of REAL_VALUES_EQUAL. * config/aarch64/aarch64.c (aarch64_float_const_zero_rtx_p): Likewise. * config/arm/arm.c (arm_const_double_rtx, neon_valid_immediate) (fp_const_from_val): Likewise. * config/fr30/fr30.c (fr30_const_double_is_zero): Likewise. * config/m68k/m68k.c (standard_68881_constant_p): Likewise. (floating_exact_log2): Likewise. * config/sh/sh.c (fp_zero_operand, fp_one_operand): Likewise. * config/vax/vax.c (vax_float_literal): Likewise. * config/xtensa/predicates.md (const_float_1_operand): Likewise. * cprop.c (implicit_set_cond_p): Likewise. * expmed.c (expand_mult): Likewise. * fold-const.c (const_binop): Likewise. * simplify-rtx.c (simplify_binary_operation_1): Likewise. (simplify_const_binary_operation): Likewise. (simplify_const_relational_operation): Likewise. * tree-call-cdce.c (check_pow): Likewise. (gen_conditions_for_pow_cst_base): Likewise. * tree-inline.c (estimate_num_insns): Likewise. * tree-ssa-dom.c (record_equality): Likewise. * tree-ssa-math-opts.c (representable_as_half_series_p): Likewise. (gimple_expand_builtin_pow): Likewise. (pass_optimize_widening_mul::execute): Likewise. * tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise. * tree-vect-patterns.c (vect_recog_pow_pattern): Likewise. * tree.c (real_zerop, real_onep, real_minus_onep): Likewise. --- gcc/builtins.c | 14 +++++++------- gcc/c-family/c-lex.c | 6 +++--- gcc/c/c-typeck.c | 2 +- gcc/config/aarch64/aarch64.c | 2 +- gcc/config/arm/arm.c | 6 +++--- gcc/config/fr30/fr30.c | 2 +- gcc/config/m68k/m68k.c | 6 +++--- gcc/config/sh/sh.c | 4 ++-- gcc/config/vax/vax.c | 4 ++-- gcc/config/xtensa/predicates.md | 2 +- gcc/cp/tree.c | 2 +- gcc/cprop.c | 2 +- gcc/doc/tm.texi | 7 ------- gcc/doc/tm.texi.in | 7 ------- gcc/expmed.c | 2 +- gcc/fold-const.c | 2 +- gcc/real.c | 10 +++++++++- gcc/real.h | 4 ++-- gcc/simplify-rtx.c | 16 ++++++++-------- gcc/tree-call-cdce.c | 4 ++-- gcc/tree-inline.c | 5 +++-- gcc/tree-ssa-dom.c | 2 +- gcc/tree-ssa-math-opts.c | 16 ++++++++-------- gcc/tree-ssa-uncprop.c | 2 +- gcc/tree-vect-patterns.c | 4 ++-- gcc/tree.c | 6 +++--- 26 files changed, 67 insertions(+), 72 deletions(-) git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228473 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-09-23 Richard Biener <rguenther@suse.de>rguenth2015-09-231-5/+12
| | | | | | | | | | | PR middle-end/67662 * fold-const.c (fold_binary_loc): Do not reassociate two vars with undefined overflow unless they will cancel out. * gcc.dg/ubsan/pr67662.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228051 138bc75d-0d04-0410-961f-82ee72b054a4
* switch from gimple to gimple*tbsaunde2015-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This renames the gimple_statement_base struct to gimple removes the typedef of gimple_statement_base * to gimple, and then adjusts all of the places that use the type. gcc/ChangeLog: 2015-09-19 Trevor Saunders <tbsaunde@tbsaunde.org> * coretypes.h (gimple): Change typedef to be a forward declaration. * gimple.h (gimple_statement_base): rename to gimple. * (all functions and types using gimple): Adjust. * *.[ch]: Likewise. gcc/cp/ChangeLog: 2015-09-19 Trevor Saunders <tbsaunde@tbsaunde.org> * cp-gimplify.c (gimplify_must_not_throw_expr): Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227941 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-09-18 Richard Biener <rguenther@suse.de>rguenth2015-09-181-3/+26
| | | | | | | | | | | | | | | | | | | | | PR tree-optimization/66142 * fold-const.c (operand_equal_p): When OEP_ADDRESS_OF treat MEM[&x] and x the same. * tree-ssa-sccvn.h (vn_reference_fold_indirect): Remove. * tree-ssa-sccvn.c (vn_reference_fold_indirect): Return true when we simplified sth. (vn_reference_maybe_forwprop_address): Likewise. (valueize_refs_1): When we simplified through vn_reference_fold_indirect or vn_reference_maybe_forwprop_address set valueized_anything to true. (vn_reference_lookup_3): Use stmt_kills_ref_p to see whether one ref kills the other instead of just a offset-based test. * tree-ssa-alias.c (stmt_kills_ref_p): Use OEP_ADDRESS_OF for the operand_equal_p test to compare bases and also compare sizes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227896 138bc75d-0d04-0410-961f-82ee72b054a4
* Split up optabs.[hc]rsandifo2015-09-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | optabs.[hc] is a bit of a behemoth. It includes basic functions for querying what a target can do, related tree- and gimple-level query functions, related rtl-level query functions, and the functions that actually generate code. Some gimple optimisations therefore need: #include "insn-config.h" #include "expmed.h" #include "dojump.h" #include "explow.h" #include "emit-rtl.h" #include "varasm.h" #include "stmt.h" #include "expr.h" purely to query whether the target has support for a particular operation. This patch splits optabs up as follows: - optabs-query.[hc]: IL-independent functions for querying what a target can do natively. - optabs-tree.[hc]: tree and gimple query functions (an extension of optabs-query.[hc]). - optabs-libfuncs.[hc]: optabs-specific libfuncs (an extension of libfuncs.h) - optabs.h: For now includes optabs-query.h and optabs-libfuncs.h. Only two files outside optabs need to include both optabs.h and optabs-tree.h: expr.c and function.c. I think that's expected given that both are related to expand. It might be good to split optabs.h further, but this is already quite a big patch. I changed can_conditionally_move_p from returning an int to returning a bool and fixed a few formatting glitches. There should be no other changes to the functions themselves. gcc/ * Makefile.in (OBJS): Add optabs-libfuncs.o, optabs-query.o and optabs-tree.o. (GTFILES): Replace optabs.c with optabs-libfunc.c. * genopinit.c (main): Add an include guard to insn-opinit.h. Protect the rtx_code parts with NUM_RTX_CODE. * optabs.h: Split parts out to... * optabs-libfuncs.h, optabs-query.h, optabs-tree.h: ...these new files. * optabs.c: Split parts out to... * optabs-libfuncs.c, optabs-query.c, optabs-tree.c: ...these new files. * cilk-common.c: Include optabs-query.h rather than optabs.h. * fold-const.c: Likewise. * target-globals.c: Likewise. * tree-if-conv.c: Likewise. * tree-ssa-forwprop.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-math-opts.c: Include optabs-tree.h rather than optabs.h. Remove unncessary include files. * tree-ssa-phiopt.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-switch-conversion.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-generic.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vrp.c: Likewise. * toplev.c: Include optabs-query.h and optabs-libfuncs.h rather than optabs.h. * expr.c: Include optabs-tree.h. * function.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227865 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-09-16 Richard Biener <rguenther@suse.de>rguenth2015-09-161-0/+4
| | | | | | | | | | PR middle-end/67271 * fold-const.c (native_encode_expr): Bail out on bogus offsets. * gcc.dg/pr67271.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227825 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-09-16 Richard Biener <rguenther@suse.de>rguenth2015-09-161-2/+6
| | | | | | | | | | | PR middle-end/67442 * fold-const.c (extract_muldiv_1): Properly extend multiplication result before builting a tree via wide_int_to_tree. * gcc.dg/torture/pr67442.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227818 138bc75d-0d04-0410-961f-82ee72b054a4
* [fold-const.c] Fix bigendian HFmode in native_interpret_realalalaw012015-09-081-6/+16
| | | | | | | | * fold-const.c (native_interpret_real): Fix HFmode for bigendian where UNITS_PER_WORD >= 4. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227552 138bc75d-0d04-0410-961f-82ee72b054a4
* 2015-09-03 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>naveenh2015-09-031-26/+0
| | | | | | | | | | | | | | | | | | | PR middle-end/67351 gcc/ChangeLog: * fold-const.c (fold_binary_loc) : Move Transform (x >> c) << c into x & (-1<<c) or transform (x << c) >> c into x & ((unsigned)-1 >> c) for unsigned types using simplify and match. * match.pd (lshift (rshift @0 INTEGER_CST@1) @1) : New simplifier. (rshift (lshift @0 INTEGER_CST@1) @1) : New Simplifier. gcc/testsuite/ChangeLog: * g++.dg/pr66752-2.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227432 138bc75d-0d04-0410-961f-82ee72b054a4
* Move some comparison simplifications to match.pdglisse2015-08-311-20/+0
| | | | | | | | | | | | | | | | | | | 2015-08-31 Marc Glisse <marc.glisse@inria.fr> gcc/ * tree.h (zerop): New function. * tree.c (zerop): Likewise. (element_precision): Handle expressions. * match.pd (define_predicates): Add zerop. (x <= +Inf): Fix comment. (abs (x) == 0, A & C == C, A & C != 0): Converted from ... * fold-const.c (fold_binary_loc): ... here. Remove. gcc/testsuite/ * gcc.dg/tree-ssa/cmp-1.c: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227346 138bc75d-0d04-0410-961f-82ee72b054a4
* Move some complex simplifications to match.pdglisse2015-08-311-90/+0
| | | | | | | | | | | | | | | | | | | 2015-08-31 Marc Glisse <marc.glisse@inria.fr> gcc/ * match.pd (SIN, COS, TAN, COSH): Reorder for consistency. (CEXPI): New operator list. (real (conj (x)), imag (conj (x)), real (x +- y), real (cexpi (x)), imag (cexpi (x)), conj (conj (x)), conj (complex (x, y))): Converted from ... * fold-const.c (fold_unary_loc, fold_binary_loc): ... here. Remove. gcc/testsuite/ * gcc.dg/tree-ssa/complex-7.c: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227343 138bc75d-0d04-0410-961f-82ee72b054a4