PR target/82981
* internal-fn.c: Include gimple-ssa.h, tree-phinodes.h and
ssa-iterators.h.
(can_widen_mult_without_libcall): New function.
(expand_mul_overflow): If only checking unsigned mul overflow,
not result, and can do efficiently MULT_HIGHPART_EXPR, emit that.
Don't use WIDEN_MULT_EXPR if it would involve a libcall, unless
no other way works. Add MULT_HIGHPART_EXPR + MULT_EXPR support.
(expand_DIVMOD): Formatting fix.
* expmed.h (expand_mult): Add NO_LIBCALL argument.
* expmed.c (expand_mult): Likewise. Use OPTAB_WIDEN rather
than OPTAB_LIB_WIDEN if NO_LIBCALL is true, and allow it to fail.
* gcc.target/mips/pr82981.c: New test.
From-SVN: r254758
PR tree-optimization/82977
* tree-ssa-strlen.c (strlen_optimize_stmt): Pass a reference to a copy
constructed temporary to strlen_to_stridx.put.
From-SVN: r254757
2017-11-15 Martin Liska <mliska@suse.cz>
* decl.c (begin_destructor_body): In case of VPTR sanitization
(with disabled recovery), zero vptr in order to catch virtual calls
after lifetime of an object.
2017-11-15 Martin Liska <mliska@suse.cz>
* g++.dg/ubsan/vptr-12.C: New test.
From-SVN: r254754
* explow.c (anti_adjust_stack_and_probe_stack_clash): Avoid probing
the red zone for stack_clash_protection_final_dynamic_probe targets
when the total dynamic stack size is zero bytes.
From-SVN: r254753
for gcc/ChangeLog
* dumpfile.h (TDF_COMPARE_DEBUG): New.
* final.c (rest_of_clean_state): Set it for the
-fcompare-debug dump.
* tree-pretty-print.c (dump_generic_node): Omit OBJ_TYPE_REF
class when TDF_COMPARE_DEBUG is set.
From-SVN: r254751
Unlike bootstrap-debug, bootstrap-debug-lean used to pass compare using
the traditional compare command, because it compiled both stage2 and
stage3 with options that used to generate identical output
(-fcompare-debug= in stage2 vs -fcompare-debug in stage3).
Since we started adding relevant command-line flags to DW_AT_producer,
this is no longer the case, and stages 2 and 3 object files that differ
in nothing but the DW_AT_producer strings.
-fcompare-debug is short for -fcompare-debug=-gtoggle, so stage3
compiles twice, once with the normal options, once with toggled -g, to
then compare the temporary final dumps. When enabled, both compilations
get from the driver an additional -frandom-seed flag (if none is given
explicitly).
-fcompare-debug= is short for -fno-compare-debug, disabling the second
compilation.
The difference between the DW_AT_producer lines are the different
-fcompare-debug flags, and the presence of the -frandom-seed flag in the
stage3 compilation.
It is easy and sensible enough to filter the -fcompare-debug flags out
of the DW_AT_producer string. This option should never affect the
compilation output, it just determines whether or not to perform an
additional compilation that should produce the same executable output.
However, dropping -frandom-seed is not quite correct, in that it might
have other consequences on the compilation. So, it makes little sense
to make the effort to drop it when it's implicit; for those comparing
compiler output differences, it might even hint at what causes, and
could fix, difficult to explain differences, namely, explicitly
supplying -frandom-seed options.
They don't seem to matter for compiler bootstraps, though, at least
for now, so we can safely refrain from issuing -frandom-seed (or maybe
we already issue it where needed :-), and then, for
bootstrap-debug-lean, use the compare-debug script, that strips out
debug information before comparing the object files.
for config/ChangeLog
* bootstrap-debug-lean.mk (do-compare): Use the
contrib/compare-debug script.
for gcc/ChangeLog
* dwarf2out.c (gen_producer_string): Discard
OPT_fcompare_debug.
From-SVN: r254750
Various implementations of C99/C11 <tgmath.h> have the property that
their macro expansions contain many copies of the macro arguments, so
resulting in exponential blowup of the size of macro expansions where
a call to such a macro contains other such calls in the macro
arguments.
This patch adds a (C-only) language feature __builtin_tgmath designed
to avoid this problem by implementing the <tgmath.h> function
selection rules directly in the compiler. The effect is that
type-generic macros can be defined simply as
#define pow(a, b) __builtin_tgmath (powf, pow, powl, \
cpowf, cpow, cpowl, a, b)
as in the example added to the manual, with each macro argument
expanded exactly once. The details of __builtin_tgmath are as
described in the manual. This is C-only since C++ uses function
overloading and just defines <ctgmath> to include <ccomplex> and
<cmath>.
__builtin_tgmath handles C99/C11 type-generic macros, and _FloatN,
_FloatNx and decimal floating-point types (following the proposed
resolution to the floating-point TS DR#9 that makes the rules for
finding a common type from arguments to a type-generic macro follow
the usual arithmetic conversions after adjustment of integer arguments
to _Decimal64 or double - or to _Complex double in the case of GNU
complex integer arguments).
Type-generic macros for functions from TS 18661 that round their
results to a narrower type are handled, but there are still some
unresolved questions regarding such macros so further changes in that
regard may be needed in future. The current implementation follows an
older version of the DR#13 resolution (allowing a function for a
wide-enough argument type to be selected if no exactly-matching
function is available), but with appropriate calls to __builtin_tgmath
is still fully compatible with the latest version of the resolution
(not yet in the DR log), and allowing such not-exactly-matching
argument types to be chosen in that case avoids needing another
special case to treat integers as _Float64 instead of double in
certain cases.
Regarding other possible language/library features, not currently
implemented in GCC:
* Imaginary types could be naturally supported by allowing cases where
the type-generic type is an imaginary type T and arguments or return
types may be T (as at present), or the corresponding real type to T
(as at present), or (new) the corresponding real type if T is real
or imaginary but T if T is complex. (tgmath.h would need a series
of functions such as
static inline _Imaginary double
__sin_imag (_Imaginary double __x)
{
return _Imaginary_I * sinh (__imag__ __x);
}
to be used in __builtin_tgmath calls.)
* __builtin_tgmath would use the constant rounding direction in the
presence of support for the FENV_ROUND / FENV_DEC_ROUND pragmas.
Support for those would also require a new __builtin_<something> to
cause a non-type-generic call to use the constant rounding
direction (it seems cleaner to add a new __builtin_<something> when
required than to make __builtin_tgmath handle a non-type-generic
case with only one function argument).
* TS 18661-5 __STDC_TGMATH_OPERATOR_EVALUATION__ would require new
__builtin_<something> that evaluates with excess range and precision
like arithmetic operators do.
* The proposed C bindings for IEEE 754-2018 augmented arithmetic
operations involve struct return types. As currently implemented
__builtin_tgmath does not handle those, but support could be added.
There are many error cases that the implementation diagnoses. I've
tried to ensure reasonable error messages for erroneous uses of
__builtin_tgmath, but the errors for erroneous uses of the resulting
type-generic macros (that is, when the non-function arguments have
inappropriate types) are more important as they are more likely to be
seen by users.
GCC's own tgmath.h, as used for some targets, is updated in this
patch. I've tested those changes minimally, via adjusting
gcc.dg/c99-tgmath-* locally to use that tgmath.h version. I've also
run the glibc testsuite (which has much more thorough tests of
correctness of tgmath.h function selection) with a glibc patch to use
__builtin_tgmath in glibc's tgmath.h.
Bootstrapped with no regressions on x86_64-pc-linux-gnu.
PR c/81156
gcc:
* doc/extend.texi (Other Builtins): Document __builtin_tgmath.
* ginclude/tgmath.h (__tg_cplx, __tg_ldbl, __tg_dbl, __tg_choose)
(__tg_choose_2, __tg_choose_3, __TGMATH_REAL_1_2)
(__TGMATH_REAL_2_3): Remove macros.
(__TGMATH_CPLX, __TGMATH_CPLX_2, __TGMATH_REAL, __TGMATH_REAL_2)
(__TGMATH_REAL_3, __TGMATH_CPLX_ONLY): Define using
__builtin_tgmath.
(frexp, ldexp, nexttoward, scalbn, scalbln): Define using
__TGMATH_REAL_2.
(remquo): Define using __TGMATH_REAL_3.
gcc/c:
* c-parser.c (check_tgmath_function): New function.
(enum tgmath_parm_kind): New enum.
(c_parser_postfix_expression): Handle __builtin_tgmath.
gcc/c-family:
* c-common.c (c_common_reswords): Add __builtin_tgmath.
* c-common.h (enum rid): Add RID_BUILTIN_TGMATH.
gcc/testsuite:
* gcc.dg/builtin-tgmath-1.c, gcc.dg/builtin-tgmath-2.c,
gcc.dg/builtin-tgmath-err-1.c, gcc.dg/builtin-tgmath-err-2.c,
gcc.dg/dfp/builtin-tgmath-dfp-err.c,
gcc.dg/dfp/builtin-tgmath-dfp.c: New tests.
From-SVN: r254749
Remove the code that determined LHS/RHS context for var expressions
(was needed previously for some instances of the back end). LHS/RHS
context is computed by the back end in all cases, so no need to have
this code in the front end any more.
Reviewed-on: https://go-review.googlesource.com/77510
* go-gcc.cc (var_expression): Remove Varexpr_context parameter.
From-SVN: r254748
2017-11-14 Michael Meissner <meissner@linux.vnet.ibm.com>
* config/rs6000/rs6000.md (bswapdi2): On 32-bit ISA 3.0, don't
generate the XXBRD instruction.
From-SVN: r254742
[gcc]
2017-11-14 Michael Meissner <meissner@linux.vnet.ibm.com>
* config/rs6000/rs6000-c.c (is_float128_p): New helper function.
(rs6000_builtin_type_compatible): Treat _Float128 and long double
as being compatible if -mabi=ieeelongdouble.
* config/rs6000/rs6000-builtin.def (BU_FLOAT128_HW_1): New macros
to setup float128 built-ins with hardware support.
(BU_FLOAT128_HW_2): Likewise.
(BU_FLOAT128_HW_3): Likewise.
(BU_FLOAT128_HW_VSX_1): Likewise.
(BU_FLOAT128_HW_VSX_2): Likewise.
(scalar_extract_expq): Change float128 built-in functions to
accommodate having both KFmode and TFmode functions. Use the
KFmode variant as the default.
(scalar_extract_sigq): Likewise.
(scalar_test_neg_qp): Likewise.
(scalar_insert_exp_q): Likewise.
(scalar_insert_exp_qp): Likewise.
(scalar_test_data_class_qp): Likewise.
(sqrtf128_round_to_odd): Delete processing the round to odd
built-in functions as special built-in functions, and define them
as float128 built-ins. Use the KFmode variant as the default.
(truncf128_round_to_odd): Likewise.
(addf128_round_to_odd): Likewise.
(subf128_round_to_odd): Likewise.
(mulf128_round_to_odd): Likewise.
(divf128_round_to_odd): Likewise.
(fmaf128_round_to_odd): Likewise.
* config/rs6000/rs6000.c (rs6000_expand_binop_builtin): Add
support for KFmode and TFmode xststdcqp calls.
(rs6000_expand_builtin): If long double is IEEE 128-bit floating
point, switch the built-in handlers for the get/set float128
exponent, get float128 mantissa, float128 test built-ins, and the
float128 round to odd built-in functions. Eliminate creating the
float128 round to odd built-in functions as special built-ins.
(rs6000_init_builtins): Eliminate special creation of the float128
round to odd built-in functions.
* config/rs6000/vsx.md (xsxexpqp_<mode>): Change float128 built-in
function insns to support both TFmode and KFmode variants.
(xsxsigqp_<mode>): Likewise.
(xsiexpqpf_<mode>): Likewise.
(xsiexpqp_<mode>): Likewise.
(xststdcqp_<mode>): Likewise.
(xststdcnegqp_<mode>): Likewise.
(xststdcqp_<mode>): Likewise.
[gcc/testsuite]
2017-11-14 Michael Meissner <meissner@linux.vnet.ibm.com>
* gcc.target/powerpc/float128-hw4.c: New test.
From-SVN: r254740
* tree-ssa-threadupdate.c (compute_path_counts): Remove
unused path_in_freq_ptr parameter.
(ssa_fix_duplicate_block_edges): Do not pass around path_in_freq
From-SVN: r254739
2017-11-14 Richard Biener <rguenther@suse.de>
* tree-cfgcleanup.c (cleanup_control_expr_graph): Remove first_p
paramter and handling.
(cleanup_control_flow_bb): Likewise.
(cleanup_control_flow_pre): New helper performing a DFS walk
to call cleanup_control_flow_bb in PRE order.
(cleanup_tree_cfg_1): Do the first phase of cleanup_control_flow_bb
via cleanup_control_flow_pre.
From-SVN: r254730
With the change in the Solaris release model (no more major releases
like Solaris 12 but only minor ones like 11.4), the Solaris 12
references in GCC need to be adapted.
Patch by Rainer Orth.
Reviewed-on: https://go-review.googlesource.com/77490
From-SVN: r254729
Turn aarch64_simd_bsldi_internal in to an insn_and_split that
knows to split back to integer operations if the register allocation
falls that way. Do this to avoid having to move between integer and
Advanced SIMD register files just for a single BSL.
---
gcc/
* config/aarch64/aarch64-simd.md
(aarch64_simd_bsl<mode>_internal): Remove DImode.
(*aarch64_simd_bsl<mode>_alt): Likewise.
(aarch64_simd_bsldi_internal): New.
(aarch64_simd_bsldi_alt): Likewise.
gcc/testsuite/
* gcc.target/aarch64/bsl-idiom.c: New.
* gcc.target/aarch64/copysign-bsl.c: New.
From-SVN: r254727
* tracer.c (better_p): Do not compare frequencies.
* reg-stack.c (better_edge): Likewise.
* shrink-wrap.c (try_shrink_wrapping): Do not convert to gcov counts
and back.
From-SVN: r254726
* auto-profile.c (afdo_annotate_cfg): Use update_max_bb_count.
* cgraphunit.c (cgraph_node::expand_thunk): Use update_max_bb_count.
* ipa-utils.c (ipa_merge_profiles): Use update_max_bb_count.
* lto-streamer-in.c (input_function): Use update_max_bb_count.
* omp-expand.c (expand_omp_taskreg): Use update_max_bb_count.
* predict.c (maybe_hot_frequency_p): Inline to ...
(maybe_hot_count_p): ... here; rewrite to counts.
(counts_to_freqs): Rename to ...
(update_max_bb_count): ... this one.
(expensive_function_p): Use counts.
(estimate_bb_frequencies): Update.
(rebuild_frequencies): Update.
* predict.h (counts_to_freqs): Rename to ...
(update_max_bb_count): ... this one.
* profile.c (compute_branch_probabilities): Add debug info
* tree-inline.c (expand_call_inline): Update debug info.
(optimize_inline_calls): Use update_max_bb_count..
(tree_function_versioning): Use update_max_bb_count..
* value-prof.c (gimple_value_profile_transformations):
Do not use update_max_bb_count.
From-SVN: r254725
2017-11-14 Tom de Vries <tom@codesourcery.com>
* testsuite/libgomp.oacc-c-c++-common/asyncwait-1.c: Allow to run for
non-nvidia devices.
From-SVN: r254723
* bb-reorder.c: Remove frequencies from comments.
(better_edge_p): Use profile counts.
(find_traces): Dump profile counts.
(rotate_loop): Use profile counts.
(find_traces_1_round): Likewise.
(connect_better_edge_p): Use counts instead of probabilities for
reverse walk.
(copy_bb_p): Drop early check for non-0 frequency.
(sanitize_hot_paths): Update comments.
From-SVN: r254721
* ipa-split.c (struct split_point): Add count.
(consider_split): Do not compute incoming frequency; compute incoming
count and store it to split_point.
(split_function): Set count of the call to split part correctly.
* testsuite/gcc.dg/tree-ssa/fnsplit-2.c: New testcase.
From-SVN: r254720
2017-11-13 Fritz Reese <fritzoreese@gmail.com>
PR fortran/78240
gcc/fortran/ChangeLog:
PR fortran/78240
* decl.c (match_clist_expr): Replace gcc_assert with proper
handling of bad result from spec_size().
* resolve.c (check_data_variable): Avoid NULL dereference when passing
locus to gfc_error.
gcc/testsuite/ChangeLog:
PR fortran/78240
* gfortran.dg/dec_structure_23.f90: New.
* gfortran.dg/pr78240.f90: New.
From-SVN: r254718
gcc/ChangeLog:
2017-11-13 Carl Love <cel@us.ibm.com>
* config/rs6000/altivec.md (altivec_vsumsws_be): Add define_expand.
gcc/testsuite/ChangeLog:
2017-11-13 Carl Love <cel@us.ibm.com>
* gcc.target/powerpc/builtin-vec-sums-be-int.c: New test file.
From-SVN: r254714
This implements __VA_OPT__, a new preprocessor feature added in C++2A.
The paper can be found here:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0306r4.html
gcc/ChangeLog
* doc/cpp.texi (Variadic Macros): Document __VA_OPT__.
gcc/testsuite/ChangeLog
* c-c++-common/cpp/va-opt-pedantic.c: New file.
* c-c++-common/cpp/va-opt.c: New file.
* c-c++-common/cpp/va-opt-error.c: New file.
libcpp/ChangeLog
* pch.c (cpp_read_state): Set n__VA_OPT__.
* macro.c (vaopt_state): New class.
(_cpp_arguments_ok): Check va_opt flag.
(replace_args, create_iso_definition): Use vaopt_state.
* lex.c (lex_identifier_intern): Possibly issue errors for
__VA_OPT__.
(lex_identifier): Likewise.
(maybe_va_opt_error): New function.
* internal.h (struct lexer_state) <va_args_ok>: Update comment.
(struct spec_nodes) <n__VA_OPT__>: New field.
* init.c (struct lang_flags) <va_opt>: New field.
(lang_defaults): Add entries for C++2A. Update all entries for
va_opt.
(cpp_set_lang): Initialize va_opt.
* include/cpplib.h (struct cpp_options) <va_opt>: New field.
* identifiers.c (_cpp_init_hashtable): Initialize n__VA_OPT__.
From-SVN: r254707
The description of our 1-based column-numbering convention was in
a non-obvious place withn line-map.h; this patch moves it to the top
of that header.
libcpp/ChangeLog:
* include/line-map.h (linenum_type): Move this typedef and the
comment describing column numbering to near the top of the file.
From-SVN: r254703
[gcc]
2017-11-13 Michael Meissner <meissner@linux.vnet.ibm.com>
* match.pd: Convert fminf<N>, fminf<N>x, fmax<N>, and fmax<N>x
into the min/max operations for _Float<N> and _Float<N>X types.
[gcc/testsuite]
2017-11-13 Michael Meissner <meissner@linux.vnet.ibm.com>
* gcc.target/powerpc/float128-minmax.c: New test.
From-SVN: r254702
PR lto/81351
* dwarf2out.c (do_eh_frame): New static variable.
(dwarf2out_begin_prologue): Set it.
(dwarf2out_frame_finish): Test it instead of dwarf2out_do_eh_frame.
From-SVN: r254700