Commit Graph

142008 Commits

Author SHA1 Message Date
Eric Botcazou e1c78addb3 re PR middle-end/68253 (conditional jump or move depends on uninitialized value in fold-const.c:5587)
PR middle-end/68253
	* fold-const.c (fold_truth_andor_1): Initialize new variables to 0.

From-SVN: r230011
2015-11-09 10:45:00 +00:00
Thomas Preud'homme e732ca6c9d thumb2-slow-flash-data.c: Add missing typespec for labelref and check use of constant pool by looking for...
2015-11-09  Thomas Preud'homme  <thomas.preudhomme@arm.com>

    gcc/
    * gcc.target/arm/thumb2-slow-flash-data.c: Add missing typespec for
    labelref and check use of constant pool by looking for .word and
    similar directives.

From-SVN: r230010
2015-11-09 10:29:06 +00:00
Igor Zamyatin a42062b176 re PR target/66326 (Floating point exception with -mfpmath=387 and -fcilkplus.)
libcilkrts/

2015-11-09  Igor Zamyatin  <igor.zamyatin@intel.com>

	PR target/66326
	* runtime/config/x86/os-unix-sysdep.c (sysdep_save_fp_ctrl_state):
	Use fnstcw instead fnstsw.


gcc/testsuite

2015-11-09  Igor Zamyatin  <igor.zamyatin@intel.com>

	PR target/66326
	* g++.dg/cilk-plus/CK/pr66326.cc: New test.

From-SVN: r230008
2015-11-09 10:12:34 +00:00
Richard Henderson 00402c9415 i386: Add address spaces for fs/gs segments and tls
* config/i386/i386-c.c (ix86_target_macros): Define __SEG_FS,
        __SEG_GS, __SEG_TLS.
        (ix86_register_pragmas): Register address spaces __seg_fs,
        __seg_gs, __seg_tls.
        * config/i386/i386-protos.h (enum ix86_address_seg): Remove.
        (ADDR_SPACE_SEG_FS, ADDR_SPACE_SEG_GS, ADDR_SPACE_SEG_TLS): New.
        (struct ix86_address): Use addr_space_t instead of ix86_address_seg.
        * config/i386/i386.c (ix86_decompose_address): Likewise.
        (ix86_legitimate_address_p): Likewise.
        (memory_address_length): Likewise.  Check mem address space too.
        (ix86_print_operand): Use ix86_print_operand_address_as.
        (ix86_print_operand_address_as): Rename from
        ix86_print_operand_address, add new addr_space_t parameter.
        Validate that either the parameter or the ix86_address segment
        is default address space.  Handle ADDR_SPACE_SEG_TLS.
        (ix86_print_operand_address): New.
        (ix86_addr_space_subset_p, TARGET_ADDR_SPACE_SUBSET_P): New.
        (ix86_addr_space_convert, TARGET_ADDR_SPACE_CONVERT): New.
        (ix86_addr_space_debug, TARGET_ADDR_SPACE_DEBUG): New.
        (ix86_addr_space_zero_address_valid): New.
        (TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID): New.
        * config/i386/i386.h (DEFAULT_TLS_SEG_REG): Use addr_space_t constants.
        * config/i386/rdos.h (DEFAULT_TLS_SEG_REG): Likewise.
        * config/i386/predicates.md (address_no_seg_operand): Likewise.
        (vsib_address_operand): Likewise.
        (address_mpx_no_base_operand): Likewise.
        (address_mpx_no_index_operand): Likewise.
        * doc/extend.texi (x86 Named Address Spaces): New section.

        * gcc.target/i386/addr-space-1.c: New test.
        * gcc.target/i386/addr-space-2.c: New test.
        * gcc.target/i386/addr-space-3.c: New test.

From-SVN: r230003
2015-11-09 01:20:21 -08:00
Richard Henderson 1673467767 i386: Disallow address spaces with string insns
While cmps and movs allow a segment override of the ds:esi
source, the es:edi source/destination cannot be overriden.
Simplify things in the backend for now by disallowing
segments for string insns entirely.

	* config/i386/i386.c (ix86_check_no_addr_space): New.
	(decide_alg): Add have_as parameter.
	(alg_usable_p): Likewise; disable rep algorithms if set.
	(ix86_expand_set_or_movmem): Notice if either MEM has a
	non-default address space.
	(ix86_expand_strlen): Likewise.
	* config/i386/i386.md (strmov, strset): Likewise.
	(*strmovdi_rex_1): Use ix86_check_no_addr_space.
	(*strmovsi_1, *strmovqi_1, *rep_movdi_rex64, *rep_movsi, *rep_movqi,
	*strsetdi_rex_1, *strsetsi_1, *strsethi_1, *strsetqi_1,
	*rep_stosdi_rex64, *rep_stossi, *rep_stosqi, *cmpstrnqi_nz_1,
	*cmpstrnqi_1, *strlenqi_1): Likewise.

From-SVN: r230002
2015-11-09 01:19:59 -08:00
Richard Henderson fe5f926316 i386: Handle address spaces in movabs patterns
* config/i386/i386.md (*movabs<mode>_1): Print the full memory rtx.
	(*movabs<mode>_2): Likewise.

From-SVN: r230001
2015-11-09 01:19:40 -08:00
Richard Henderson f736b911e6 Add hook for modifying debug info for address spaces
* dwarf2out.c (modified_type_die): Pass the address space number
        through TARGET_ADDR_SPACE_DEBUG to produce the dwarf address class.
        * target.def (TARGET_ADDR_SPACE_DEBUG): New.
        * targhooks.c (default_addr_space_debug): New.
        * targhooks.h (default_addr_space_debug): Declare.
        * doc/tm.texi.in (TARGET_ADDR_SPACE_DEBUG): Mark it.
        * doc/tm.texi: Rebuild.

From-SVN: r230000
2015-11-09 01:19:19 -08:00
Richard Henderson 6626f97034 Add TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID
* 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.

From-SVN: r229999
2015-11-09 01:18:59 -08:00
Richard Henderson bd68a3a7e7 Avoid CSE of MEMs in different address spaces
* 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.

From-SVN: r229998
2015-11-09 01:18:35 -08:00
Richard Henderson f0ebde5ace re PR tree-optimization/66768 (address space gets lost on literal pointer)
PR tree-opt/66768

        * tree-ssa-address.c (create_mem_ref_raw): Use a pointer of
        the correct type for the base.

From-SVN: r229997
2015-11-09 01:18:16 -08:00
Jeff Law d2e2feaa4d [PATCH] Minor refactoring in tree-ssanames.c & freelists verifier
[PATCH] Minor refactoring in tree-ssanames.c & freelists verifier
	* tree-into-ssa.c (names_to_release): No longer static.
	* tree-into-ssa.h (names_to_release): Declare.
	* tree-ssanames.c (verify_ssaname_freelists): New debug function.
	(release_free_names_and_compact_live_names): New function extracted
	from pass_release_ssa_names::execute.
	(pass_release_ssa_names::execute): Use it.

Co-Authored-By: Nathan Sidwell <nathan@acm.org>

From-SVN: r229995
2015-11-09 02:02:27 -07:00
Steven G. Kargl cdffe78809 re PR fortran/68053 (lower bound of implied shape array restricted too much)
2015-11-08  Steven g. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68053
	* decl.c (add_init_expr_to_sym):  Try to reduce initialization expression
	before testing for a constant value.

2015-11-08  Steven g. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68053
	* gfortran.dg/pr68053.f90: New test.

From-SVN: r229992
2015-11-09 05:50:24 +00:00
Alan Modra 61c94e79eb Configury changes for obstack optimization
Missed from last patch

	* config.in: Regenerate.

From-SVN: r229991
2015-11-09 15:24:15 +10:30
Alan Modra 126e0b6b61 Configury changes for obstack optimization
* configure.ac: Check size of size_t.
	* configure: Regenerate.

From-SVN: r229990
2015-11-09 15:02:08 +10:30
Alan Modra a186d523f2 Silence obstack.c -Wc++compat warning
* obstack.c (_obstack_newchunk): Silence -Wc++compat warning.
	(_obstack_begin_worker): Likewise.  Move assignment to h->chunk
	after alloc failure check.

From-SVN: r229989
2015-11-09 15:00:26 +10:30
Alan Modra f0e525fe18 Modify obstack.[hc] to avoid having to include other gnulib files
Using the standard gnulib obstack source requires importing quite a
lot of other files from gnulib, and requires build changes.

include/
	* obstack.h (__attribute_pure__): Expand _GL_ATTRIBUTE_PURE.
libiberty/
	* obstack.c (__alignof__): Expand alignof_type from alignof.h.
	(obstack_exit_failure): Don't use exitfail.h.
	(_): Include libintl.h when HAVE_LIBINTL_H and nls enabled.
	Provide default.  Don't include gettext.h.
	(_Noreturn): Define.
	* obstacks.texi: Adjust node references to external libc info files.

From-SVN: r229988
2015-11-09 14:58:21 +10:30
Alan Modra c9f265c945 Copy gnulib obstack files
This copies obstack.[ch] from gnulib, and updates the docs.  The next
patch should be applied if someone repeats the import at a later date.

include/
	* obstack.h: Import current gnulib file.
libiberty/
	* obstack.c: Import current gnulib file.
	* obstacks.texi: Updated doc, from glibc's manual/memory.texi.

From-SVN: r229987
2015-11-09 14:56:32 +10:30
Alan Modra 62c0f0a637 Update libsanitizer obstack interceptors
New obstack uses sensible types, size_t instead of int for length
params.  Since libsanitizer does not use prototypes from obstack.h to
call the real functions, it's necessary to update the libsanitizer
function declarations emitted by the INTERCEPTOR macro.

	* sanitizer_common/sanitizer_common_interceptors.inc: Update size
	params for _obstack_begin_1, _obstack_begin, _obstack_newchunk
	interceptors.
	* configure.ac: Substitute OBSTACK_DEFS.
	* asan/Makefile.am: Add OBSTACK_DEFS to DEFS.
	* tsan/Makefile.am: Likewise.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* asan/Makefile.in: Regenerate.
	* interception/Makefile.in: Regenerate.
	* libbacktrace/Makefile.in: Regenerate.
	* lsan/Makefile.in: Regenerate.
	* sanitizer_common/Makefile.in: Regenerate.
	* tsan/Makefile.in: Regenerate.
	* ubsan/Makefile.in: Regenerate.

From-SVN: r229986
2015-11-09 14:53:25 +10:30
Alan Modra 37697711e7 Correct libvtv obstack use
Fixes a compile error with both old and new obstacks due to
obstack_chunk_free having the wrong signature.  Also, setting chunk
size and alignment before obstack_init is pointless since they are
overwritten.

	* vtv_malloc.cc (obstack_chunk_free): Correct param type.
	(__vtv_malloc_init): Use obstack_specify_allocation.

From-SVN: r229985
2015-11-09 14:49:43 +10:30
Alan Modra c240b3e0de New obstack_next_free is not an lvalue
New obstack.h casts obstack_next_free to (void *), resulting in it
being a non-lvalue, and warnings on pointer arithmetic.

gcc/
	* gensupport.c (add_mnemonic_string): Make len param a size_t.
	(gen_mnemonic_setattr): Make "size" var a size_t.  Use
	obstack_blank_fast to shrink obstack.  Cast obstack_next_free
	return value.
gcc/objc/
	* objc-encoding.c (encode_aggregate_within): Cast obstack_next_free
	return value.

From-SVN: r229984
2015-11-09 14:47:53 +10:30
Segher Boessenkool d4c8d5ede1 Fix bb-reorder problem with degenerate cond_jump (PR68182)
The code mistakenly thinks any cond_jump has two successors.  This is
not true if both destinations are the same, as can happen with weird
patterns as in the PR.


	PR rtl-optimization/68182
	* gcc/bb-reorder.c (reorder_basic_blocks_simple): Treat a conditional
	branch with only one successor just like unconditional branches.

From-SVN: r229983
2015-11-09 04:57:19 +01:00
Jeff Law 4f70cb39c0 [PATCH] Remove backedge handling support in tree-ssa-threadupdate.c
* tree-ssa-threadupdate.c (register_jump_thraed): Assert that a
	non-FSM path has no edges marked with EDGE_DFS_BACK.
	(ssa_redirect_edges): No longer call mark_loop_for_removal.
	(thread_single_edge, def_split_header_continue_p): Remove.
	(bb_ends_with_multiway_branch): Likewise.
	(thread_through_loop_header): Remove cases of threading from
	latch through the header.  Simplify knowing we won't thread
	the latch.
	(thread_through_all_blocks): Simplify knowing that only the FSM
	threader needs to handle backedges.

From-SVN: r229982
2015-11-08 20:19:09 -07:00
GCC Administrator a2478e36e0 Daily bump.
From-SVN: r229980
2015-11-09 00:16:11 +00:00
Jan Hubicka 285af20657 * g++.dg/lto/pr68057_0.C: Fix testcase.
From-SVN: r229968
2015-11-08 19:14:29 +00:00
Joost VandeVondele c6fa91cfcd Move tests depending on graphite to correct subdirectory.
2015-11-08  Joost VandeVondele <vondele@gcc.gnu.org>

	* gfortran.dg/PR67518.f90: move from here...
	* gfortran.dg/graphite/PR67518.f90: to here.
	* gfortran.dg/PR53852.f90: move from here...
	* gfortran.dg/graphite/PR53852.f90: to here.

From-SVN: r229967
2015-11-08 19:12:53 +00:00
Eric Botcazou ee45a32dae Merge of the scalar-storage-order branch.
From-SVN: r229965
2015-11-08 18:33:42 +00:00
Martin Sebor eb11eb157c Clean up fallout on ILP32 from r229831.
gcc/
	PR c++/67942 
	* cp/init.c (warn_placement_new_too_small): Convert integer
	operand of POINTER_PLUS_EXPR to ssize_t to determine its signed
	value.

c-family/
        * c.opt (Wplacement-new): Add a period to the end of
        a sentence.

From-SVN: r229959
2015-11-08 10:53:51 -07:00
Andre Vehreschild 3e4d188a5f re PR fortran/68218 (ALLOCATE with size given by a module function)
gcc/fortran/ChangeLog:

2015-11-08  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/68218
	* trans-array.c (gfc_array_init_size): Add gfc_evaluate_now() when
	array spec in allocate is a function call.

gcc/testsuite/ChangeLog:

2015-11-08  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/68218
	* gfortran.dg/allocate_with_arrayspec_1.f90: New test.

From-SVN: r229956
2015-11-08 18:37:42 +01:00
Steven G. Kargl 28bc117f58 re PR fortran/68224 (ICE on referencing parameter array with dimension null)
2015-11-08  Steven G. Kargl  <kargl@gc.gnu.org>

	PR fortran/68224
	* array.c (match_array_element_spec): Check of invalid NULL().
	While here, fix nearby comments.

2015-11-08  Steven G. Kargl  <kargl@gc.gnu.org>

	PR fortran/68224
	* gfortran.dg/pr68224.f90: New test.

From-SVN: r229955
2015-11-08 17:25:16 +00:00
Paul Thomas 57905c2bb3 re PR fortran/68196 (ICE on function result with procedure pointer component)
2015-11-08  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/68196
	* class.c (has_finalizer_component): Prevent infinite recursion
	through this function if the derived type and that of its
	component are the same.
	* trans-types.c (gfc_get_derived_type): Do the same for proc
	pointers by ignoring the explicit interface for the component.

	PR fortran/66465
	* check.c (same_type_check): If either of the expressions is
	BT_PROCEDURE, use the typespec from the symbol, rather than the
	expression.

2015-11-08  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/68196
	* gfortran.dg/proc_ptr_47.f90: New test.

	PR fortran/66465
	* gfortran.dg/pr66465.f90: New test.

From-SVN: r229954
2015-11-08 16:47:58 +00:00
Christophe Lyon 210172f47d [AArch64] Fix vqtb[lx][234] on big-endian
Forgot to commit the new testcases:
gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vqtbX.c

From-SVN: r229946
2015-11-08 08:59:31 +01:00
GCC Administrator 46d59b585a Daily bump.
From-SVN: r229944
2015-11-08 00:16:11 +00:00
Eric Botcazou cad669df64 * config/sparc/sparc.opt (mfix-at697f): Add final period.
From-SVN: r229941
2015-11-07 22:34:20 +00:00
John David Anglin 171258f706 Wno-frame-address.c: Skip on hppa*-*-*.
* gcc.dg/Wno-frame-address.c: Skip on hppa*-*-*.

From-SVN: r229940
2015-11-07 22:22:33 +00:00
Steven G. Kargl 57e596204f re PR fortran/68153 (ICE for intrinsic reshape with negative dim in effective shape)
2015-11-07  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68153
	* check.c (gfc_check_reshape): Improve check for valid SHAPE argument.

2015-11-07  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68153
	* gfortran.dg/pr68153.f90: New test.

From-SVN: r229939
2015-11-07 20:18:17 +00:00
Steven G. Kargl 727cde644d re PR fortran/68151 (ICE on using select case with function of wrong type)
2015-11-07  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68151
	* match.c (match_case_selector):  Check for invalid type.

2015-11-07  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68151
	* gfortran.dg/pr68151.f90: New test.

From-SVN: r229938
2015-11-07 20:04:43 +00:00
Segher Boessenkool bc05d49d10 i386: Use the STC bb-reorder algorithm at -Os (PR67864)
For x86, STC still gives better results for optimise-for-size than
"simple" does.  So use STC at -Os as well.


	PR rtl-optimization/67864
	* common/config/i386/i386-common.c (ix86_option_optimization_table)
	<OPT_freorder_blocks_algorithm_>: Use REORDER_BLOCKS_ALGORITHM_STC
	at -Os and up.

From-SVN: r229937
2015-11-07 20:44:21 +01:00
Trevor Saunders a153644f75 replace BITS_PER_UNIT with __CHAR_BIT__ in target libs
libgcc/ChangeLog:

2015-11-07  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* config/visium/lib2funcs.c (__set_trampoline_parity): Use
	__CHAR_BIT__ instead of BITS_PER_UNIT.
	* fixed-bit.h: Likewise.
	* fp-bit.h: Likewise.
	* libgcc2.c (__popcountSI2): Likewise.
	(__popcountDI2): Likewise.
	* libgcc2.h: Likewise.
	* libgcov.h: Likewise.

libobjc/ChangeLog:

2015-11-07  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	PR libobjc/24775
	* encoding.c (_darwin_rs6000_special_round_type_align): Use
	__CHAR_BIT__ instead of BITS_PER_UNIT.
	(objc_sizeof_type): Likewise.
	(objc_layout_structure): Likewise.
	(objc_layout_structure_next_member): Likewise.
	(objc_layout_finish_structure): Likewise.
	(objc_layout_structure_get_info): Likewise.

From-SVN: r229936
2015-11-07 19:36:26 +00:00
David Edelsohn 3dee689d8f atexit.c: New file.
* config/rs6000/atexit.c: New file.
* config/rs6000/t-aix-cxa (LIB2ADDEH): Build atexit.c.
* config/rs6000/libgcc-aix-cxa.ver (atexit): Add symbol to exports.
* config/rs6000/cxa_finalize.c
(catomic_compare_and_exchange_bool_acq): Negate return value.

From-SVN: r229932
2015-11-07 09:23:32 -05:00
Richard Sandiford 6ca5a44255 Handle internal functions in is_tm_pure_call
The upcoming changes to use internal functions for things like sqrt
caused a failure in gcc.dg/tm/20100610.c, because we were trying to get
call flags from the null gimple_call_fn of an IFN_SQRT call.  We've been
making fairly heavy use of internal functions for a while now so I think
this might be latent.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/
	* trans-mem.c (is_tm_pure_call): Use gimple_call_flags for
	internal functions.

From-SVN: r229925
2015-11-07 10:19:56 +00:00
Richard Sandiford 0aad019857 Move #undef DEF_BUILTIN* to builtins.def
I was confused at first why tree-core.h was undefining DEF_BUILTIN_CHKP
before defining it, then undefining it again after including builtins.def.
This is because builtins.def provides a default definition of
DEF_BUILTIN_CHKP, but leaves it up to the caller to undefine it where
necessary.  Similarly to the previous internal-fn.def patch, it seems
more obvious for builtins.def to #undef things unconditionally.

One argument might have been that keeping preprocessor stuff
out of the .def files makes it easier for non-cpp parsers.  In practice
though we already have #ifs and multiline #defines, so single-line #undefs
should be easy in comparison.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/ada/
	* gcc-interface/utils.c: Don't undef DEF_BUILTIN.

gcc/c-family/
	* c-common.c: Don't undef DEF_BUILTIN.

gcc/jit/
	* jit-builtins.c: Don't undef DEF_BUILTIN.

gcc/lto/
	* lto-lang.c: Don't undef DEF_BUILTIN.

gcc/
	* builtins.def: #undef DEF_BUILTIN and DEF_BUILTIN_CHKP
	* builtins.c, genmatch.c, tree-core.h: Don't undef them here.

From-SVN: r229924
2015-11-07 10:18:38 +00:00
Richard Sandiford 46e343b8d2 Move #undef DEF_INTERNAL_FN to internal-fn.def
In practice the definition of DEF_INTERNAL_FN is never reused after
including internal-fn.def, so we might as well #undef it there.

This becomes more obvious with a later patch that adds other
DEF_INTERNAL_* directives, such as DEF_INTERNAL_OPTAB_FN.
If the includer doesn't care about the information carried in
these new directives, it can simply leave the macro undefined
and internals.def will provide a definition that forwards to
DEF_INTERNAL_FN.  It doesn't make much sense for includers to have
to #undef macros that are defined by internals.def and it seems overly
complicated to get internals.def to undef macros only in the cases
where it provided a definition.  Instead I went with the approach of
#undeffing all the DEF_INTERNAL_* macros unconditionally.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/
	* internal-fn.def: #undef DEF_INTERNAL_FN at the end.
	* internal-fn.c: Don't undef it here.
	* tree-core.h: Likewise.

From-SVN: r229923
2015-11-07 10:17:05 +00:00
Richard Sandiford df838ef0f1 Move const char * -> int/fp folds to fold-const-call.c
This patch moves folds that deal with constant string arguments and
return a constant integer or floating-point value.  For example, it
handles strcmp ("foo", "bar") but not strstr ("foobar", "bar"),
which wouldn't currently be accepted by the gimple folders.

The builtins.c folding for strlen (via c_strlen) is a bit more general
than what the fold-const-call.c code does (and more general than we need
for the gimple folders).  I've therefore left it as-is, even though it
partially duplicates the new code.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/
	* builtins.c (fold_builtin_nan): Delete.
	(fold_builtin_memcmp): Remove case where both arguments are constant.
	(fold_builtin_strcmp, fold_builtin_strncmp): Likewise.
	(fold_builtin_strspn, fold_builtin_strcspn): Likewise.
	(fold_builtin_1): Remove BUILT_IN_NAN* handling.
	* fold-const-call.c: Include fold-const.h.
	(host_size_t_cst_p): New function.
	(build_cmp_result, fold_const_builtin_nan): Likewise.
	(fold_const_call_1): New function, split out from...
	(fold_const_call): ...here (for all three interfaces).  Handle
	constant nan, nans, strlen, strcmp, strncmp, strspn and strcspn.

From-SVN: r229922
2015-11-07 10:10:44 +00:00
Richard Sandiford db9bd5d575 Move constant bitop and bswap folds to fold-const-call.c
The only folds left in builtins.c were for constants, so we can remove
the builtins.c handling entirely.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/
	* builtins.c (fold_builtin_bitop, fold_builtin_bswap): Delete.
	(fold_builtin_1): Don't call them.
	* fold-const-call.c: Include tm.h.
	(fold_const_call_ss): New variant for integer-to-integer folds.
	(fold_const_call): Call it.

From-SVN: r229921
2015-11-07 10:08:31 +00:00
Richard Sandiford 2556a032cc Handle constant fp classifications in fold-const-call.c
Move the constant "is finite", "is infinite" and "is nan" queries
to fold-const-call.c.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/
	* builtins.c (fold_builtin_classify): Move constant cases to...
	* fold-const-call.c (fold_const_call_ss): ...here.

From-SVN: r229920
2015-11-07 10:05:51 +00:00
Richard Sandiford 5486d91300 Move c_getstr to fold-const.c
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.

From-SVN: r229919
2015-11-07 10:01:52 +00:00
Richard Sandiford eb0b164e5f Don't treat rint as setting errno
builtins.def says that rint sets errno, but it looks like this might
be a mistake.  C99 says that rint doesn't set errno and the builtins.c
expansion code doesn't try to keep errno up to date.

Perhaps this was because earlier versions of POSIX said that
rint sets errno on overflow:

        http://pubs.opengroup.org/onlinepubs/009695399/functions/rintf.html

However, this is another instance of the observation that "rounding
functions could never overflow" (because anything using exponents
that large is already integral).  The page above also says that
differences with C99 are unintentional and the ERANGE clause has
been removed from later versions of POSIX:

        http://pubs.opengroup.org/onlinepubs/9699919799/functions/rint.html

Also, the version of POSIX that lists ERANGE for rint does the same
for nearbyint:

        http://pubs.opengroup.org/onlinepubs/009695399/functions/nearbyintf.html

and we already treat nearbyint as not setting errno.  This too has been
clarified in later versions of POSIX:

        http://pubs.opengroup.org/onlinepubs/9699919799/functions/nearbyint.html

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/
	* builtins.def (BUILTIN_RINT, BUILTIN_RINTF, BUILTIN_RINTL): Use
	ATTR_MATHFN_FPROUNDING rather than ATTR_MATHFN_FPROUNDING_ERRNO.

From-SVN: r229918
2015-11-07 10:00:31 +00:00
Richard Sandiford 02b7230d3c Add -fno-math-errno to gcc.dg/lto/20110201-1_0.c
At the moment the ECF_* flags for a gimple call to a built-in
function are derived from the function decl, which in turn is
derived from the global command-line options.  So if the compiler
is run with -fno-math-errno, we always assume functions don't set
errno, regardless of local optimization options.  Similarly if the
compiler is run with -fmath-errno, we always assume functions set errno.

This shows up in gcc.dg/lto/20110201-1_0.c, where we compile
the file with -O0 and use -O2 -ffast-math for a specific function.
-O2 -ffast-math is enough for us to convert cabs to sqrt as hoped,
but because of the global -fmath-errno setting, we assume that the
call to sqrt is not pure or const and create vops for it.  This makes
it appear to the gimple code that a simple sqrt optab isn't enough.

Later patches move more decisions about maths functions to gimple
and think that in this case we should use:

        y = sqrt (x);
        if (!(x >= 0))
            sqrt (x); // to set errno.

This is being tracked as PR68235.  For now the patch adds
-fno-math-errno to the dg-options for this test.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/testsuite/
	PR tree-optimization/68235
	* gcc.dg/lto/20110201-1_0.c: Add -fno-math-errno.

From-SVN: r229917
2015-11-07 09:58:32 +00:00
Richard Sandiford f127ea514d Try to update dominance info in tree-call-cdce.c
The pass would free the dominance info after making a change, but it
should be pretty easy to keep the information up-to-date when the call
has no EH edges.

Tested on x86_64-linux-gnu, arm-linux-gnueabi and aarch64-linux-gnu.

gcc/
	* tree-call-cdce.c (shrink_wrap_one_built_in_call): Try to update
	the dominance info; free it if we can't.
	(pass_call_cdce::execute): Don't free the dominance info here.

From-SVN: r229916
2015-11-07 09:56:04 +00:00
Jeff Law 88419b5295 [PATCH] Remove more backedge threading support
* tree-ssa-threadedge.c (dummy_simplify): Remove.
	(thread_around_empty_blocks): Remove backedge_seen_p argument.
	If we thread to a backedge, then return false.  Update recursive
	call to eliminate backedge_seen_p argument.
	(thread_through_normal_block): Remove backedge_seen_p argument.
	Remove backedge_seen_p argument from calls to
	thread_around_empty_blocks.  Remove checks on backedge_seen_p.
	If we thread to a backedge, then return 0.
	(thread_across_edge): Remove bookkeeping for backedge_seen.  Don't
	pass it to thread_through_normal_block or thread_through_empty_blocks.
	For joiner handling, if we see a backedge, do not try normal
	threading.

From-SVN: r229911
2015-11-06 23:31:14 -07:00