Joseph Myers [Wed, 21 Mar 2018 22:29:37 +0000 (22:29 +0000)]
Adjust __builtin_tgmath handling of integer arguments to _FloatN narrowing macros.
When adding __builtin_tgmath to support a better tgmath.h
implementation, I noted that further changes might be needed regarding
the TS 18661 functions that round their results to a narrower type,
because of unresolved issues with how the corresponding type-generic
macros are defined in TS 18661.
The resolution of those issues is still in flux, but the latest
version does indeed require something slightly different from
__builtin_tgmath. It specifies that integer arguments to type-generic
macros such as f32xadd are treated as _Float64 not double - which was
also present in earlier versions of the resolution - but then it also
specifies different handling for _Float64 arguments and double
arguments, which wasn't in earlier versions. Specifically, in the
latest version
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2213.pdf>, f32xadd
with _Float64 arguments would call f32xaddf64, while f32xadd with
double arguments would call f32xaddf64x. Since integer arguments are
converted directly to the argument type of the selected function (not
to double / _Float64x unless that ends up as the argument type), this
is a user-visible difference in semantics that means __builtin_tgmath
actually needs to implement treating integer arguments as _Float64 in
this case (the rest of the latest semantics can then be implemented in
the header, with a few inline functions there).
To avoid releasing with the older version of the __builtin_tgmath
semantics that doesn't work with the latest proposed DR#13 resolution,
this patch implements a rule in __builtin_tgmath that maps integer
types to _Float64 (respectively _Complex _Float64 for complex integer
types) where all the specified functions return the same _FloatN or
_FloatNx type. This does not affect any existing uses of
__builtin_tgmath in glibc's or GCC's tgmath.h since I haven't yet
added any of these type-generic macros to glibc when adding the
corresponding narrowing functions.
Bootstrapped with no regressions on x86_64-pc-linux-gnu.
* doc/extend.texi (__builtin_tgmath): Document when complex
integer types are treated as _Complex _Float64.
gcc/c:
* c-parser.c (c_parser_postfix_expression): For __builtin_tgmath
where all functions return the same _FloatN or _FloatNx type,
treat integer types as _Float64 instead of double.
gcc/testsuite:
* gcc.dg/builtin-tgmath-3.c: New test.
Alexandre Oliva [Wed, 21 Mar 2018 22:08:34 +0000 (22:08 +0000)]
[PR c++/71965] silence multi-dim array init sorry without tf_error
We shouldn't substitute templates into short-circuited-out concepts
constraints, but we do, and to add insult to injury, we issue a
sorry() error when a concept that shouldn't even have been substituted
attempts to perform a multi-dimensional array initialization with a
new{} expression.
Although fixing the requirements short-circuiting is probably too
risky at this point, we can get closer to the intended effect by
silencing that sorry just as we silence other errors.
for gcc/cp/ChangeLog
PR c++/71965
* init.c (build_vec_init): Silence error, former sorry,
without tf_error.
Alexandre Oliva [Wed, 21 Mar 2018 22:08:19 +0000 (22:08 +0000)]
[PR c++/84610,84642] recover from implicit template parms gracefully
If we get a parse error during an attempted fully implicit function
template parse, and need to skip to the end of the statement or block,
we may discard the function parms scope rather than the enclosing
injected implicit template parms scope. If we rollback a tentative
parse and try something else, we'll no longer be in a function parms
scope, but rather in a template parms scope, but we may still attempt
to synthesize implicit template parms and then fail the assert that
checks we're in a function parms scope.
This patch introduces an alternative to
finish_fully_implicit_template_p, to be used during error recovery,
that floats the implicit template parm scope to the top so that it
gets discarded as we finish and discard the failed implicit template
data, while other scopes are retained as expected. It also clears the
implicit template parser data as we finish the template, so that it
doesn't linger on referencing discarded or used scopes and parms.
for gcc/cp/ChangeLog
PR c++/84610
PR c++/84642
* parser.c (abort_fully_implicit_template_p): New.
(cp_parser_skip_to_end_of_statement): Use it.
(cp_parser_skip_to_end_of_block_or_statement): Likewise.
(finish_fully_implicit_template_p): Clear
implicit_template_parms and implicit_template_scope.
Jakub Jelinek [Wed, 21 Mar 2018 20:53:16 +0000 (21:53 +0100)]
re PR tree-optimization/84960 (ICE in GIMPLE pass: isolate-paths)
PR tree-optimization/84960
* tree-cfg.c (remove_bb): Don't move forced labels into bb->prev_bb
if it is ENTRY block, move them into single succ of ENTRY in that case.
This patch fixes incorrect results for HOST_WIDE_INT positions
at opposite extremes when used with HOST_WIDE_INT sizes. It also
fixes UB when comparing such positions with unsigned HOST_WIDE_INT
sizes (although the results in that case were wrapv-correct).
2018-03-20 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
PR tree-optimization/84811
* poly-int.h (poly_span_traits): Remove the T3 parameter and
promote HOST_WIDE_INT T2 - T1 results to unsigned HOST_WIDE_INT.
(maybe_in_range_p, known_in_range_p, ranges_known_overlap_p):
(known_subrange_p): Update accordingly. Cast each value involved
in the size comparison, rather than casting the result of the
subtraction.
gcc/testsuite/
PR tree-optimization/84811
* gcc.dg/torture/pr84811.c: New test.
Jakub Jelinek [Wed, 21 Mar 2018 20:20:40 +0000 (21:20 +0100)]
re PR tree-optimization/84982 (logically inverting bools into local array results in bitwise negation)
PR tree-optimization/84982
* gimple-ssa-store-merging.c (invert_op): Handle boolean inversion
by flipping the least significant bit rather than all bits from
bitpos to bitpos + bitsize - 1.
Jakub Jelinek [Wed, 21 Mar 2018 20:19:33 +0000 (21:19 +0100)]
re PR c++/84961 (ICE error: SSA_NAME_DEF_STMT is wrong)
PR c++/84961
* cp-tree.h (genericize_compound_lvalue): Declare.
* typeck.c (genericize_compound_lvalue): New function.
(unary_complex_lvalue, cp_build_modify_expr): Use it.
* semantics.c (finish_asm_stmt): Replace MODIFY_EXPR, PREINCREMENT_EXPR
and PREDECREMENT_EXPR in output and "m" constrained input operands with
COMPOUND_EXPR. Call cxx_mark_addressable on the rightmost
COMPOUND_EXPR operand.
* c-c++-common/pr43690.c: Don't expect errors on "m" (--x) and
"m" (++x) in C++.
* g++.dg/torture/pr84961-1.C: New test.
* g++.dg/torture/pr84961-2.C: New test.
Janne Blomqvist [Wed, 21 Mar 2018 18:46:44 +0000 (20:46 +0200)]
PR 84615 Regressions due to type mismatch with character functions
Since the kind of the hidden character length variable is not part of
the character variable definition, we must ensure that character
lengths are always of the same kind in interfaces, regardless of how
they were declared in the source. This patch ensures this when calling
a procedure.
Regtested on x86_64-pc-linux-gnu and i686-pc-linux-gnu.
gcc/fortran/ChangeLog:
2018-03-21 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/84615
* trans-expr.c (gfc_conv_procedure_call): Convert charlen to
gfc_charlen_type_node when calling procedure.
gcc/testsuite/ChangeLog:
2018-03-21 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/84615
* gfortran.dg/char_result_17.f90: New test.
David Malcolm [Wed, 21 Mar 2018 18:21:39 +0000 (18:21 +0000)]
C++: show private field accessor hints with -g and optimization (PR c++/84994)
gcc/cp/ChangeLog:
PR c++/84994
* constexpr.c (constexpr_fn_retval): Make non-"static".
* cp-tree.h (constexpr_fn_retval): New decl.
* search.c (direct_accessor_p): Update leading comment.
(reference_accessor_p): Likewise.
(field_accessor_p): Replace check that function body is a
RETURN_EXPR with a call to constexpr_fn_retval. Fix
indentation of "field_type" decl.
Sudakshina Das [Wed, 21 Mar 2018 17:14:48 +0000 (17:14 +0000)]
[ARM] Fix test pr82989.c for big endian and mthumb
The test pr82989.c which was added in one of previous commits is failing for
mthumb and big-endian configurations. The aim of this test was to check that
NEON instructions are not being used for simple shift operations. The scanning
of lsl and lsr instructions and checking its counts were just too restrictive
for different configurations. So I have now simplified the test to only check
for the absence of NEON instructions.
Martin Sebor [Wed, 21 Mar 2018 15:14:02 +0000 (15:14 +0000)]
PR c++/84850 - -Wclass-memaccess on a memcpy in a copy assignment operator with no nontrivial bases or members
gcc/cp/ChangeLog:
PR c++/84850
* call.c (first_non_public_field): New template and function.
(first_non_trivial_field): New function.
(maybe_warn_class_memaccess): Call them.
gcc/testsuite/ChangeLog:
PR c++/84850
* g++.dg/Wclass-memaccess-3.C: New test.
* g++.dg/Wclass-memaccess-4.C: New test.
David Malcolm [Wed, 21 Mar 2018 13:09:09 +0000 (13:09 +0000)]
C++: show private field accessor hints for const accesses (PR c++/84892)
gcc/cp/ChangeLog:
PR c++/84892
* search.c (field_accessor_p): Use class_of_this_parm rather than
type_of_this_parm, to check that "this" is a "const T *", rather
than a "T *const".
Nathan Sidwell [Wed, 21 Mar 2018 12:39:05 +0000 (12:39 +0000)]
MAINTAINERS with no port
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg01093.html
* MAINTAINERS: Move maintainers of now-removed picochip and score
ports to write after approval.
Jonathan Wakely [Wed, 21 Mar 2018 12:32:14 +0000 (12:32 +0000)]
Fix some libstdc++ testsuite failures
* testsuite/20_util/function_objects/comparisons_pointer.cc: Use
VERIFY instead of assert.
* testsuite/20_util/hash/84998.cc: New test.
* testsuite/23_containers/vector/cons/destructible_debug_neg.cc: New
copy of test adjusted for Debug Mode.
* testsuite/23_containers/vector/cons/destructible_neg.cc: Do not run
test in Debug Mode.
Nathan Sidwell [Wed, 21 Mar 2018 11:04:36 +0000 (11:04 +0000)]
Deprecate some C++ extensions
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00995.html
* doc/extend.texi (Deprecated Features): Update deprecared flags,
mention anon-struct/union members and trailing attributes.
cp/
* class.c (finish_struct_anon_r): Refactor, deprecate anything
other than public non-static data members.
* parser.c (cp_parser_init_declarator): Deprecate attributes after
parenthesized initializer.
Bin Cheng [Wed, 21 Mar 2018 10:42:34 +0000 (10:42 +0000)]
re PR tree-optimization/84969 (Wrong code with -ftree-loop-distribute-patterns)
PR tree-optimization/84969
* tree-loop-distribution.c (fuse_memset_builtins): Don't reorder
builtin memset partitions if they set different rhs values.
gcc/testsuite
* gcc.dg/tree-ssa/pr84969.c: New test.
Steven G. Kargl [Wed, 21 Mar 2018 01:07:43 +0000 (01:07 +0000)]
re PR fortran/85001 (ICE in gfc_build_array_type, at fortran/trans-types.c:1420)
2018-03-20 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/85001
* interface.c (symbol_rank): Remove bogus null pointer check that
crept in when translating a ternary operator into an if-else
constructor.
2018-03-20 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/85001
* gfortran.dg/interface_41.f90: New test.
Kyrylo Tkachov [Tue, 20 Mar 2018 17:13:16 +0000 (17:13 +0000)]
This PR shows that we get the load/store_lanes logic wrong for arm big-endian.
It is tricky to get right. Aarch64 does it by adding the appropriate lane-swapping
operations during expansion.
I'd like to do the same on arm eventually, but we'd need to port and validate the VTBL-generating
code and add it to all the right places and I'm not comfortable enough doing it for GCC 8, but I am keen
in getting the wrong-code fixed.
As I say in the PR, vectorisation on armeb is already severely restricted (we disable many patterns on BYTES_BIG_ENDIAN)
and the load/store_lanes patterns really were not working properly at all, so disabling them is not
a radical approach.
The way to do that is to return false in ARRAY_MODE_SUPPORTED_P for BYTES_BIG_ENDIAN.
Bootstrapped and tested on arm-none-linux-gnueabihf.
Also tested on armeb-none-eabi.
PR target/82518
* config/arm/arm.c (arm_array_mode_supported_p): Return false for
BYTES_BIG_ENDIAN.
* lib/target-supports.exp (check_effective_target_vect_load_lanes):
Disable for armeb targets.
* gcc.target/arm/pr82518.c: New test.
Nathan Sidwell [Tue, 20 Mar 2018 16:01:08 +0000 (16:01 +0000)]
[PR c++/84962] ICE with anon-struct member
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00961.html
PR c++/84962
* name-lookup.c (pushdecl_class_level): Push anon-struct's
member_vec, if there is one.
Martin Liska [Tue, 20 Mar 2018 14:14:17 +0000 (15:14 +0100)]
Handle -fno-guess-branch-probability properly in predict.c (PR ipa/84825).
2018-03-20 Martin Liska <mliska@suse.cz>
PR ipa/84825
* predict.c (rebuild_frequencies): Handle case when we have
PROFILE_ABSENT, but flag_guess_branch_prob is false.
2018-03-20 Martin Liska <mliska@suse.cz>
Jakub Jelinek [Tue, 20 Mar 2018 10:59:26 +0000 (11:59 +0100)]
re PR target/84845 (ICE: in extract_insn, at recog.c:2304: unrecognizable insn at -O2 and above at aarch64)
PR target/84845
* config/aarch64/aarch64.md (*aarch64_reg_<mode>3_neg_mask2): Rename
to ...
(*aarch64_<optab>_reg_<mode>3_neg_mask2): ... this. If pseudos can't
be created, use lowpart_subreg of operands[0] rather than operands[0]
itself.
(*aarch64_reg_<mode>3_minus_mask): Rename to ...
(*aarch64_ashl_reg_<mode>3_minus_mask): ... this.
(*aarch64_<optab>_reg_di3_mask2): Use const_int_operand predicate
and n constraint instead of aarch64_shift_imm_di and Usd.
(*aarch64_reg_<optab>_minus<mode>3): Rename to ...
(*aarch64_<optab>_reg_minus<mode>3): ... this.
Sudakshina Das [Tue, 20 Mar 2018 10:54:42 +0000 (10:54 +0000)]
[ARM][PR82989] Fix unexpected use of NEON instructions for shifts
This patch fixes PR82989 so that we avoid NEON instructions when
-mneon-for-64bits is not enabled. This is more of a short term fix
for the real deeper problem of making an early decision of choosing
or rejecting NEON instructions. There is now a new ticket PR84467 to
deal with the longer term solution.
(Please refer to the discussion in the bug report for more details).
Sudi
*** gcc/ChangeLog ***
2018-03-20 Sudakshina Das <sudi.das@arm.com>
PR target/82989
* config/arm/neon.md (ashldi3_neon): Update ?s for constraints
to favor GPR over NEON registers.
(<shift>di3_neon): Likewise.
*** gcc/testsuite/ChangeLog ***
2018-03-20 Sudakshina Das <sudi.das@arm.com>
PR target/82989
* gcc.target/arm/pr82989.c: New test.
Jakub Jelinek [Tue, 20 Mar 2018 08:14:42 +0000 (09:14 +0100)]
re PR target/84945 (UBSAN: gcc/config/i386/i386.c:33312:22: runtime error: shift exponent 32 is too large for 32-bit type 'int')
PR target/84945
* config/i386/i386.c (fold_builtin_cpu): For features above 31
use __cpu_features2 variable instead of __cpu_model.__cpu_features[0].
Use 1U instead of 1. Formatting fixes.
* gcc.target/i386/pr84945.c: New test.
* config/i386/cpuinfo.h (__cpu_features2): Declare.
* config/i386/cpuinfo.c (__cpu_features2): New variable for
ifndef SHARED only.
(set_feature): Define.
(get_available_features): Use set_feature macro. Set __cpu_features2
to the second word of features ifndef SHARED.
Jakub Jelinek [Mon, 19 Mar 2018 20:49:57 +0000 (21:49 +0100)]
re PR tree-optimization/84946 (UBSAN: in mem_valid_for_store_merging ../../gcc/gimple-ssa-store-merging.c:3951)
PR tree-optimization/84946
* gimple-ssa-store-merging.c (mem_valid_for_store_merging): Compute
bitsize + bitsize in poly_uint64 rather than poly_int64.
Jakub Jelinek [Mon, 19 Mar 2018 20:48:39 +0000 (21:48 +0100)]
re PR sanitizer/78651 (Incorrect exception handling when catch clause uses local class and PIC and sanitizer are active)
PR sanitizer/78651
* dwarf2asm.c: Include fold-const.c.
(dw2_output_indirect_constant_1): Set DECL_INITIAL (decl) to ADDR_EXPR
of decl rather than decl itself.
Jakub Jelinek [Mon, 19 Mar 2018 20:47:29 +0000 (21:47 +0100)]
re PR sanitizer/84761 (AddressSanitizer is not compatible with glibc 2.27 on x86)
PR sanitizer/84761
* sanitizer_common/sanitizer_linux_libcdep.cc (__GLIBC_PREREQ):
Define if not defined.
(DL_INTERNAL_FUNCTION): Don't define.
(InitTlsSize): For __i386__ if not compiled against glibc 2.27+
determine at runtime whether to use regparm(3), stdcall calling
convention for older glibcs or normal calling convention for
newer glibcs for call to _dl_get_tls_static_info.
Nathan Sidwell [Mon, 19 Mar 2018 18:56:22 +0000 (18:56 +0000)]
[PR c++/84835] ICE with generic lambda in extern "C"
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00890.html
PR c++/84835
* lambda.c (maybe_add_lambda_conv_op): Force C++ linkage.
* pt.c (build_template_decl): Propagate language linkage.
Sudakshina Das [Mon, 19 Mar 2018 18:50:32 +0000 (18:50 +0000)]
[PR81647][AARCH64] Fix handling of Unordered Comparisons in aarch64-simd.md
This patch fixes the inconsistent behavior observed at -O3 for the unordered
comparisons. According to the online docs (https://gcc.gnu.org/onlinedocs
/gcc-7.2.0/gccint/Unary-and-Binary-Expressions.html), all of the following
should not raise an FP exception:
- UNGE_EXPR
- UNGT_EXPR
- UNLE_EXPR
- UNLT_EXPR
- UNEQ_EXPR
Also ORDERED_EXPR and UNORDERED_EXPR should only return zero or one.
The aarch64-simd.md handling of these were generating exception raising
instructions such as fcmgt. This patch changes the instructions that are
emitted in order to not give out the exceptions. We first check each
operand for NaNs and force any elements containing NaN to zero before using
them in the compare.
Example: UN<cc> (a, b) -> UNORDERED (a, b)
| (cm<cc> (isnan (a) ? 0.0 : a, isnan (b) ? 0.0 : b))
The ORDERED_EXPR is now handled as (cmeq (a, a) & cmeq (b, b)) and
UNORDERED_EXPR as ~ORDERED_EXPR and UNEQ as (~ORDERED_EXPR | cmeq (a,b)).
ChangeLog Entries:
*** gcc/ChangeLog ***
2018-03-19 Sudakshina Das <sudi.das@arm.com>
PR target/81647
* config/aarch64/aarch64-simd.md (vec_cmp<mode><v_int_equiv>): Modify
instructions for UNLT, UNLE, UNGT, UNGE, UNEQ, UNORDERED and ORDERED.
Jim Wilson [Mon, 19 Mar 2018 18:08:24 +0000 (18:08 +0000)]
RISC-V: Fix bootstrap failure.
gcc/
PR bootstrap/84856
* config/riscv/riscv.c (riscv_function_arg_boundary): Use
PREFERRED_STACK_BOUNDARY instead of STACK_BOUNDARY.
(riscv_first_stack_step): Likewise.
(riscv_option_override): Use STACK_BOUNDARY instead of
MIN_STACK_BOUNDARY.
* config/riscv/riscv.h (STACK_BOUNDARY): Renamed from
MIN_STACK_BOUNDARY.
(BIGGEST_ALIGNMENT): Set to 128.
(PREFERRED_STACK_BOUNDARY): Renamed from STACK_BOUNDARY.
(RISCV_STACK_ALIGN): Use PREFERRED_STACK_BOUNDARY instead of
STACK_BOUNDARY.
Richard Biener [Mon, 19 Mar 2018 14:11:05 +0000 (14:11 +0000)]
re PR tree-optimization/84933 (ICE in set_value_range, at tree-vrp.c:288 since r257852)
2018-03-19 Richard Biener <rguenther@suse.de>
PR tree-optimization/84933
* tree-vrp.c (set_and_canonicalize_value_range): Treat out-of-bound
values as -INF/INF when canonicalizing an ANTI_RANGE to a RANGE.
Richard Biener [Mon, 19 Mar 2018 14:08:58 +0000 (14:08 +0000)]
re PR tree-optimization/84859 (bogus -Warray-bounds on a memcpy in a loop)
2018-03-19 Richard Biener <rguenther@suse.de>
PR tree-optimization/84859
* tree-ssa-phiopt.c (single_trailing_store_in_bb): New function.
(cond_if_else_store_replacement): Perform sinking operation on
single-store BBs regardless of MAX_STORES_TO_SINK setting.
Generalize what a BB with a single eligible store is.
Richard Biener [Mon, 19 Mar 2018 12:49:30 +0000 (12:49 +0000)]
re PR tree-optimization/84929 (ICE at -O3 on valid code on x86_64-linux-gnu: tree check: expected polynomial_chrec, have nop_expr in analyze_siv_subscript_cst_affine, at tree-data-ref.c:3018)
2018-03-19 Richard Biener <rguenther@suse.de>
PR tree-optimization/84929
* tree-data-ref.c (analyze_siv_subscript_cst_affine): Guard
chrec_is_positive against non-chrec arg.
Steven G. Kargl [Sun, 18 Mar 2018 17:51:57 +0000 (17:51 +0000)]
re PR fortran/77414 (ICE in create_function_arglist, at fortran/trans-decl.c:2410)
2018-03-18 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77414
* decl.c (get_proc_name): Check for a subroutine re-defined in
the contain portion of a subroutine. Change language of existing
error message to better describe the issue. While here fix whitespace
issues.
Don't try to vectorise COND_EXPR reduction chains (PR 84913)
The testcase ICEd for both SVE and AVX512 because we were trying
to vectorise a chain of COND_EXPRs as a reduction and getting
confused by reduc_index == -1.
2018-03-18 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
PR tree-optimization/84913
* tree-vect-loop.c (vectorizable_reduction): Don't try to
vectorize chains of COND_EXPRs.
gcc/testsuite/
PR tree-optimization/84913
* gfortran.dg/vect/pr84913.f90: New test.
Jakub Jelinek [Sat, 17 Mar 2018 11:12:00 +0000 (12:12 +0100)]
re PR target/84902 (549.fotonik3d_r from SPEC2017 fails verification with -Ofast -march=native on Zen since r258518)
PR target/84902
* config/i386/i386.c (initial_ix86_tune_features,
initial_ix86_arch_features): Use unsigned HOST_WIDE_INT rather than
unsigned long long.
(set_ix86_tune_features): Change ix86_tune_mask from unsigned int
to unsigned HOST_WIDE_INT, initialize to HOST_WIDE_INT_1U << ix86_tune
rather than 1u << ix86_tune. Formatting fix.
(ix86_option_override_internal): Change ix86_arch_mask from
unsigned int to unsigned HOST_WIDE_INT, initialize to
HOST_WIDE_INT_1U << ix86_arch rather than 1u << ix86_arch.
(ix86_function_specific_restore): Likewise.