The popcount expansion uses SIMD instructions acting on 64-bit values.
As a result a popcount of a 32-bit integer requires zero-extension before
moving the zero-extended value into an FP register. This patch adds
support for zero-extended int->FP moves to avoid the redundant uxtw.
Similarly, add support for 32-bit zero-extending load->FP register
and 32-bit zero-extending FP->FP and FP->int moves.
Add a missing 'fp' arch attribute to the related 8/16-bit pattern and
fix an incorrect type attribute.
To complete zero-extended load support, add a new alternative to
load_pair_zero_extendsidi2_aarch64 to support LDP into FP registers too.
int f (int a)
{
return __builtin_popcount (a);
}
Before:
uxtw x0, w0
fmov d0, x0
cnt v0.8b, v0.8b
addv b0, v0.8b
fmov w0, s0
ret
After:
fmov s0, w0
cnt v0.8b, v0.8b
addv b0, v0.8b
fmov w0, s0
ret
Passes regress & bootstrap on AArch64.
gcc/
* config/aarch64/aarch64.md (zero_extendsidi2_aarch64): Add alternatives
to zero-extend between int and floating-point registers.
(load_pair_zero_extendsidi2_aarch64): Add alternative for zero-extended
ldp into floating-point registers. Add type and arch attributes.
(zero_extend<SHORT:mode><GPI:mode>2_aarch64): Add arch attribute.
Use f_loads for type attribute.
testsuite/
* gcc.target/aarch64/popcnt.c: Test zero-extended popcount.
* gcc.target/aarch64/vec_zeroextend.c: Test zero-extended vectors.
From-SVN: r265079
PR c++/87364
* c-pretty-print.h (pp_c_type_cast): Prototype.
(pp_c_integer_constant): Likewise.
* c-pretty-print.c (pp_c_type_cast): No longer static.
(pp_c_integer_constant): Likewise.
(pp_c_enumeration_constant): Fix loop termination when finding
name of constant. No longer returns a value. Call
pp_c_integer_constant.
(c_pretty_printer::constant): Update for changes to
pp_c_enumeration_constant.
PR c++/87364
* cxx-pretty-print.c (pp_cxx_enumeration_constant): New function.
(cxx_pretty_printer::constant): Use it.
From-SVN: r265077
It's not safe to assume that malloc(n) returns memory aligned to more
than n, so when relying on the guaranteed alignment of malloc ensure
that the number of bytes allocated is at least as large as the
alignment.
PR libstdc++/77691
* include/experimental/memory_resource (__resource_adaptor_imp): Do
not allocate sizes smaller than alignment when relying on guaranteed
alignment.
* testsuite/experimental/memory_resource/new_delete_resource.cc:
Adjust expected number of bytes allocated for alignof(max_align_t).
From-SVN: r265068
[gcc]
2018-10-09 Will Schmidt <will_schmidt@vnet.ibm.com>
* config/rs6000/rs6000.c (map_to_integral_tree_type): New helper
function.
(fold_mergeeo_helper): New helper function.
(rs6000_gimple_fold_builtin): Add hooks for vec_mergee and vec_mergeo
intrinsics. Correct some whitespace indentation issues.
From-SVN: r265063
As mentioned in PR87511, the shift used in aarch64_mask_and_shift_for_ubfiz_p
should be evaluated as a HOST_WIDE_INT rather than int.
Passes bootstrap & regress.
gcc/
PR target/87511
* config/aarch64/aarch64.c (aarch64_mask_and_shift_for_ubfiz_p):
Use HOST_WIDE_INT_1U for shift.
testsuite/
PR target/87511
* gcc.target/aarch64/pr87511.c: Add new test.
From-SVN: r265058
PR c++/84993 identifies a problem with our suggestions for
misspelled member names in the C++ FE for the case where the
member is private.
For example, given:
class foo
{
public:
double get_ratio() const { return m_ratio; }
private:
double m_ratio;
};
void test(foo *ptr)
{
if (ptr->ratio >= 0.5)
;// etc
}
...we currently emit this suggestion:
<source>: In function 'void test(foo*)':
<source>:12:12: error: 'class foo' has no member named 'ratio'; did you mean 'm_ratio'?
if (ptr->ratio >= 0.5)
^~~~~
m_ratio
...but if the user follows this suggestion, they get:
<source>: In function 'void test(foo*)':
<source>:12:12: error: 'double foo::m_ratio' is private within this context
if (ptr->m_ratio >= 0.5)
^~~~~~~
<source>:7:10: note: declared private here
double m_ratio;
^~~~~~~
<source>:12:12: note: field 'double foo::m_ratio' can be accessed via 'double foo::get_ratio() const'
if (ptr->m_ratio >= 0.5)
^~~~~~~
get_ratio()
It feels wrong to be emitting a fix-it hint that doesn't compile, so this
patch adds the accessor fix-it hint logic to this case, so that we directly
offer a valid suggestion:
<source>: In function 'void test(foo*)':
<source>:12:12: error: 'class foo' has no member named 'ratio'; did you mean
'double foo::m_ratio'? (accessible via 'double foo::get_ratio() const')
if (ptr->ratio >= 0.5)
^~~~~
get_ratio()
gcc/cp/ChangeLog:
PR c++/84993
* call.c (enforce_access): Move diagnostics to...
(complain_about_access): ...this new function.
* cp-tree.h (class access_failure_info): Rename split out field
"m_field_decl" into "m_decl" and "m_diag_decl".
(access_failure_info::record_access_failure): Add tree param.
(access_failure_info::was_inaccessible_p): New accessor.
(access_failure_info::get_decl): New accessor.
(access_failure_info::get_diag_decl): New accessor.
(access_failure_info::get_any_accessor): New member function.
(access_failure_info::add_fixit_hint): New static member function.
(complain_about_access): New decl.
* typeck.c (access_failure_info::record_access_failure): Update
for change to fields.
(access_failure_info::maybe_suggest_accessor): Split out into...
(access_failure_info::get_any_accessor): ...this new function...
(access_failure_info::add_fixit_hint): ...and this new function.
(finish_class_member_access_expr): Split out "has no member named"
error-handling into...
(complain_about_unrecognized_member): ...this new function, and
check that the guessed name is accessible along the access path.
Only provide a spell-correction fix-it hint if it is; otherwise,
attempt to issue an accessor fix-it hint.
gcc/testsuite/ChangeLog:
PR c++/84993
* g++.dg/torture/accessor-fixits-9.C: New test.
From-SVN: r265056
Mismatched dg-{begin|end}-multiline-output directives are currently
silently ignored, leading to difficult-to-diagnose test failures
involving excess output.
This patch makes multiline.exp complain about them.
gcc/testsuite/ChangeLog:
* lib/multiline.exp (dg-begin-multiline-output): Issue an error if
there hasn't been a dg-end-multiline-output since the last
dg-begin-multiline-output.
(dg-end-multiline-output): Issue an error if there hasn't been a
dg-begin-multiline-output. Reset _multiline_last_beginning_line
as soon possible. Rename "line" to "last_line".
From-SVN: r265046
Avoid a system call when no sleep is required. Sleep in a loop (actually
two loops) to handle interruption by signals.
PR libstdc++/80538
* src/c++11/thread.cc (this_thread::__sleep_for)
[_GLIBCXX_HAVE_SLEEP]: Only call sleep for non-zero values.
Loop while sleep call is interrupted and until steady_clock
shows requested duration has elapsed.
(!_GLIBCXX_HAVE_USLEEP]: Use the _GLIBCXX_HAVE_SLEEP code path, but
avoiding the usleep call.
* testsuite/30_threads/this_thread/60421.cc: Test repeated
signal interruptions.
From-SVN: r265044
GCN's 64-lane vectors tend to make RTL dumps very long. This patch makes them
far more bearable by eliding long sequences of the same element into "repeated"
messages.
This also takes care of reading repeated sequences in the RTL front-end.
There are self tests for both reading and writing.
2018-10-11 Andrew Stubbs <ams@codesourcery.com>
Jan Hubicka <jh@suse.cz>
Martin Jambor <mjambor@suse.cz>
gcc/
* print-rtl.c (print_rtx_operand_codes_E_and_V): Print how many times
the same elements are repeated rather than printing all of them.
* read-rtl.c (rtx_reader::read_rtx_operand): Recognize and expand
"repeated" elements.
* read-rtl-function.c (test_loading_repeat): New function.
(read_rtl_function_c_tests): Call test_loading_repeat.
* rtl-tests.c (test_dumping_repeat): New function.
(rtl_tests_c_tests): Call test_dumping_repeat.
gcc/testsuite/
* selftests/repeat.rtl: New file.
Co-Authored-By: Jan Hubicka <jh@suse.cz>
Co-Authored-By: Martin Jambor <mjambor@suse.cz>
From-SVN: r265042
PR c++/87582
* typeck.c (maybe_warn_about_returning_address_of_local): If
whats_returned is a structured binding identifier and the structured
binding is a reference, recurse on its initializer.
* g++.dg/cpp1z/decomp48.C: New test.
From-SVN: r265041
Consider:
demo.c: In function 'test':
demo.c:5:40: error: macro "LOG_2" requires 3 arguments, but only 2 given
5 | LOG_2 ("loading file: %s\n", filename);
| ^
This patch adds a note showing the definition of the macro in
question, giving:
demo.c: In function 'test':
demo.c:5:40: error: macro "LOG_2" requires 3 arguments, but only 2 given
5 | LOG_2 ("loading file: %s\n", filename);
| ^
In file included from demo.c:1:
logging.h:1: note: macro "LOG_2" defined here
1 | #define LOG_2(FMT, ARG0, ARG1) do { fprintf (stderr, (FMT), (ARG0), (ARG1)); }
|
gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/macro-arg-count.C: Move to...
* c-c++-common/cpp/macro-arg-count-1.c: ...here, generalizing
output for C vs C++. Expect notes showing the definitions of the
macros.
* c-c++-common/cpp/macro-arg-count-2.c: New test, adapted from the
above.
libcpp/ChangeLog:
* macro.c (_cpp_arguments_ok): If the argument count is wrong, add
a note showing the definition of the macro.
From-SVN: r265040
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00623.html
* include/line-map.h (LINEMAPS_MACRO_LOWEST_LOCATION): Fix
off-by-one error.
* line-map.c (linemap_enter_macro): Use RAII. Clear all of the
macro_locations.
From-SVN: r265037
The Allocator requirements include the ability to compare different
specializations of the same allocator class template. This did not work
for __gnu_cxx::new_allocator and other extension allocators. This patch
replaces the equality operators for those allocators with inline friends
that support heterogeneous comparisons. (I'm not changing all ext
allocators because some are bit-rotted already).
Additionally, the equality operators for comparing two std::allocator
objects of the same type are now defined as inline friends. Those
overloads don't need to be declared at namespace scope, because they
aren't specified in the standard (but they're needed in this
implementation to avoid ambiguities caused by the extra overloads
defined for the base allocator type).
* include/bits/allocator.h
(operator==(const allocator<_Tp>&, const allocator<_Tp>))
(operator!=(const allocator<_Tp>&, const allocator<_Tp>)): Replace
with inline friends.
* include/ext/debug_allocator.h (operator==, operator!=): Replace
with inline friend functions that compare to rebound allocators.
* include/ext/malloc_allocator.h (operator==, operator!=): Likewise.
* include/ext/new_allocator.h (operator==, operator!=): Likewise.
* testsuite/ext/debug_allocator/eq.cc: New test.
* testsuite/ext/ext_pointer/alloc_eq.cc: New test.
* testsuite/ext/malloc_allocator/eq.cc: New test.
* testsuite/ext/new_allocator/eq.cc: New test.
From-SVN: r265036
2018-10-11 Martin Jambor <mjambor@suse.cz>
testsuite/
* gcc.dg/warn-abs-1.c: Guard tests assuming size of long double is
greater that the size of double by target large_long double.
From-SVN: r265035
The C++17 standard requires the default implementation for
allocator_traits::max_size to return SIZE_MAX / sizeof(value_type).
That causes GCC to warn because the value could be larger than can
sensibly be passed to malloc. This patch changes the new_allocator and
malloc_allocator max_size() members to use PTRDIFF_MAX instead of
SIZE_MAX (and because they define it, the allocator_traits default isn't
used). This also changes vector::max_size to impose a sensible limit
using PTRDIFF_MAX for cases where the value from the allocator or
allocator_traits is not sensible.
PR libstdc++/87544
* include/bits/stl_vector.h (vector::_S_max_size): Limit size to
PTRDIFF_MAX / sizeof(value_type).
* include/ext/malloc_allocator.h (malloc_allocator::max_size):
Likewise.
* include/ext/new_allocator.h (new_allocator::max_size): Likewise.
* testsuite/23_containers/vector/allocator/minimal.cc: Adjust
expected value for max_size().
* testsuite/23_containers/vector/capacity/87544.cc: New test.
From-SVN: r265021
gcc/testsuite/ChangeLog:
* gcc.c-torture/execute/memchr-1.c: Avoid assuming 4-byte wchar_t.
Add a test for 2-byte wchar_t.
* gcc.dg/builtin-memchr.c: New test.
From-SVN: r265020
PR target/87550
* config/i386/i386-builtin.def (IX86_BUILTIN_RDPMC): Move from args set
to special_args set.
* gcc.target/i386/pr87550.c: New test.
From-SVN: r265007
2018-10-10 Richard Biener <rguenther@suse.de>
* config/i386/sse.md (reduc_plus_scal_v8df, reduc_plus_scal_v4df,
reduc_plus_scal_v2df, reduc_plus_scal_v16sf, reduc_plus_scal_v8sf,
reduc_plus_scal_v4sf): Merge into pattern reducing to half width
and recursing and pattern terminating the recursion on SSE
vector width using ix86_expand_reduc.
(reduc_sminmax_scal_<mode>): Split into part reducing to half
width and recursing and SSE2 vector variant doing the final
reduction with ix86_expand_reduc.
(reduc_uminmax_scal_<mode>): Likewise for the AVX512 variants
with terminating the recursion at AVX level, splitting that
to SSE there.
From-SVN: r265004
This patch renames the "error" callback within libcpp
to "diagnostic", and uses the pair of enums in cpplib.h, rather
than passing two different kinds of "int" around.
gcc/c-family/ChangeLog:
* c-common.c (c_option_controlling_cpp_error): Rename to...
(c_option_controlling_cpp_diagnostic): ...this, and convert
"reason" from int to enum.
(c_cpp_error): Rename to...
(c_cpp_diagnostic): ...this, converting level and reason to enums.
* c-common.h (c_cpp_error): Rename to...
(c_cpp_diagnostic): ...this, converting level and reason to enums.
* c-opts.c (c_common_init_options): Update for renaming.
gcc/fortran/ChangeLog:
* cpp.c (gfc_cpp_init_0): Update for renamings.
(cb_cpp_error): Rename to...
(cb_cpp_diagnostic): ...this, converting level and reason to
enums.
gcc/ChangeLog:
* genmatch.c (error_cb): Rename to...
(diagnostic_cb): ...this, converting int params to enums.
(fatal_at): Update for renaming.
(warning_at): Likewise.
(main): Likewise.
* input.c (selftest::ebcdic_execution_charset::apply):
Update for renaming of...
(selftest::ebcdic_execution_charset::on_error): ...this, renaming
to...
(selftest::ebcdic_execution_charset::on_diagnostic): ...this,
converting level and reason to enums.
(class selftest::lexer_error_sink): Rename to...
(class selftest::lexer_test_options): ...this, renaming field
"m_errors" to "m_diagnostics".
(selftest::lexer_test_options::apply): Update for renaming of...
(selftest::lexer_test_options::on_error): ...this, renaming to...
(selftest::lexer_test_options::on_diagnostic): ...this
converting level and reason to enums.
(selftest::test_lexer_string_locations_raw_string_unterminated):
Update for renamings.
* opth-gen.awk (struct cpp_reason_option_codes_t): Use enum for
"reason".
libcpp/ChangeLog:
* charset.c (noop_error_cb): Rename to...
(noop_diagnostic_cb): ...this, converting params to enums.
(cpp_interpret_string_ranges): Update for renaming and enums.
* directives.c (check_eol_1): Convert reason to enum.
(do_diagnostic): Convert code and reason to enum.
(do_error): Use CPP_W_NONE rather than 0.
(do_pragma_dependency): Likewise.
* errors.c (cpp_diagnostic_at): Convert level and reason to enums.
Update for renaming.
(cpp_diagnostic): Convert level and reason to enums.
(cpp_error): Convert level to enum.
(cpp_warning): Convert reason to enums.
(cpp_pedwarning): Likewise.
(cpp_warning_syshdr): Likewise.
(cpp_diagnostic_with_line): Convert level and reason to enums.
Update for renaming.
(cpp_error_with_line): Convert level to enum.
(cpp_warning_with_line): Convert reason to enums.
(cpp_pedwarning_with_line): Likewise.
(cpp_warning_with_line_syshdr): Likewise.
(cpp_error_at): Convert level to enum.
(cpp_errno): Likewise.
(cpp_errno_filename): Likewise.
* include/cpplib.h (enum cpp_diagnostic_level): Name this enum,
and move to before struct cpp_callbacks.
(enum cpp_warning_reason): Likewise.
(cpp_callbacks::diagnostic): Convert params from int to enums.
(cpp_error): Convert int param to enum cpp_diagnostic_level.
(cpp_warning): Convert int param to enum cpp_warning_reason.
(cpp_pedwarning): Likewise.
(cpp_warning_syshdr): Likewise.
(cpp_errno): Convert int param to enum cpp_diagnostic_level.
(cpp_errno_filename): Likewise.
(cpp_error_with_line): Likewise.
(cpp_warning_with_line): Convert int param to enum
cpp_warning_reason.
(cpp_pedwarning_with_line): Likewise.
(cpp_warning_with_line_syshdr): Likewise.
(cpp_error_at): Convert int param to enum cpp_diagnostic_level.
* macro.c (create_iso_definition): Convert int to enum.
(_cpp_create_definition): Likewise.
From-SVN: r264999
/cp
2018-10-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84423
* pt.c (convert_template_argument): Immediately return error_mark_node
if the second argument is erroneous.
* parser.c (cp_parser_type_id): Add location_t * parameter.
(cp_parser_type_id_1): Likewise.
(cp_parser_alias_declaration): Adjust cp_parser_type_id call,
obtain the location of the type and save it.
(cp_parser_template_type_arg): Adjust.
(cp_parser_trailing_type_id): Likewise.
* decl.c (grokdeclarator): Improve error message for 'auto' in
alias declaration.
/testsuite
2018-10-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84423
* g++.dg/concepts/pr84423-1.C: New.
* g++.dg/concepts/pr84423-2.C: Likewise.
* g++.dg/cpp0x/auto39.C: Test location too.
* g++.dg/cpp0x/auto9.C: Likewise.
* g++.dg/cpp1y/pr60384.C: Likewise.
From-SVN: r264996