Iain Buclaw [Sun, 31 Oct 2021 15:49:33 +0000 (16:49 +0100)]
d: Fix pr96435.d failing on SPARC and HPPA
The value used to initialize the integer field in the union didn't
account for BigEndian targets running this code.
PR d/102959
gcc/testsuite/ChangeLog:
* gdc.dg/torture/pr96435.d: Adjust for BigEndian.
Bernhard Reutner-Fischer [Sun, 31 Oct 2021 16:17:56 +0000 (17:17 +0100)]
Fortran: Silence -Wmaybe-uninitialized warning
gcc/fortran/ChangeLog:
* resolve.c (resolve_fl_procedure): Initialize
allocatable_or_pointer.
GCC Administrator [Sun, 31 Oct 2021 00:16:24 +0000 (00:16 +0000)]
Daily bump.
Tobias Burnus [Sat, 30 Oct 2021 21:45:32 +0000 (23:45 +0200)]
OpenMP: Add strictly nested API call check [PR102972]
The teams construct only permits omp_get_num_teams and omp_get_team_num
as API call in strictly nested regions - check for it.
Additionally, for Fortran, using DECL_NAME does not show the mangled
name, hence, DECL_ASSEMBLER_NAME had to be used to.
Finally, 'target device(ancestor:1)' wrongly rejected non-API calls
as well.
PR middle-end/102972
gcc/ChangeLog:
* omp-low.c (omp_runtime_api_call): Use DECL_ASSEMBLER_NAME to get
internal Fortran name; new permit_num_teams arg to permit
omp_get_num_teams and omp_get_team_num.
(scan_omp_1_stmt): Update call to it, add missing call for
reverse offload, and check for strictly nested API calls in teams.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/target-device-ancestor-3.c: Add non-API
routine test.
* gfortran.dg/gomp/order-6.f90: Add missing bind(C).
* c-c++-common/gomp/teams-3.c: New test.
* gfortran.dg/gomp/teams-3.f90: New test.
* gfortran.dg/gomp/teams-4.f90: New test.
libgomp/ChangeLog:
* testsuite/libgomp.c-c++-common/icv-3.c: Nest API calls inside
parallel construct.
* testsuite/libgomp.c-c++-common/icv-4.c: Likewise.
* testsuite/libgomp.c/target-3.c: Likewise.
* testsuite/libgomp.c/target-5.c: Likewise.
* testsuite/libgomp.c/target-6.c: Likewise.
* testsuite/libgomp.c/target-teams-1.c: Likewise.
* testsuite/libgomp.c/teams-1.c: Likewise.
* testsuite/libgomp.c/thread-limit-2.c: Likewise.
* testsuite/libgomp.c/thread-limit-3.c: Likewise.
* testsuite/libgomp.c/thread-limit-4.c: Likewise.
* testsuite/libgomp.c/thread-limit-5.c: Likewise.
* testsuite/libgomp.fortran/icv-3.f90: Likewise.
* testsuite/libgomp.fortran/icv-4.f90: Likewise.
* testsuite/libgomp.fortran/teams1.f90: Likewise.
Harald Anlauf [Sat, 30 Oct 2021 18:16:32 +0000 (20:16 +0200)]
Fortran: remove descriptions of SHORT and LONG in intrinsic.texi
2021-10-30 Manfred Schwarb <manfred99@gmx.ch>
gcc/fortran/ChangeLog:
* intrinsic.texi: Remove entries for SHORT and LONG intrinsics.
Harald Anlauf [Sat, 30 Oct 2021 18:09:10 +0000 (20:09 +0200)]
Fortran: non-standard intrinsics SHORT and LONG have been removed
2021-10-30 Manfred Schwarb <manfred99@gmx.ch>
gcc/fortran/ChangeLog:
* check.c (gfc_check_intconv): Change error message.
gcc/testsuite/ChangeLog:
* gfortran.dg/intrinsic_short-long.f90: New test.
Harald Anlauf [Sat, 30 Oct 2021 17:29:57 +0000 (19:29 +0200)]
Fortran: fix descriptions in intrinsic.texi
2021-10-30 Manfred Schwarb <manfred99@gmx.ch>
gcc/fortran/ChangeLog:
* intrinsic.texi (REAL): Fix entries in Specific names table.
Harald Anlauf [Sat, 30 Oct 2021 17:14:34 +0000 (19:14 +0200)]
Fortran: improve formatting of tables in intrinsic.texi
2021-10-30 Manfred Schwarb <manfred99@gmx.ch>
gcc/fortran/ChangeLog:
* intrinsic.texi: Adjust @columnfractions commands to improve
appearance for narrow 80 character terminals.
Bernhard Reutner-Fischer [Sun, 21 Oct 2018 13:55:40 +0000 (15:55 +0200)]
Fix memory leak of gsymbol
We did not free global symbols. For a simplified abstract_type_3.f90
valgrind reports:
96 bytes in 1 blocks are still reachable in loss record 461 of 602
at 0x48377D5: calloc (vg_replace_malloc.c:711)
by 0x21257C3: xcalloc (xmalloc.c:162)
by 0x98611B: gfc_get_gsymbol(char const*) (symbol.c:4341)
by 0x932C58: parse_module() (parse.c:5912)
by 0x9336F8: gfc_parse_file() (parse.c:6236)
by 0x991449: gfc_be_parse_file() (f95-lang.c:204)
by 0x11D8EDE: compile_file() (toplev.c:455)
by 0x11DB9C3: do_compile() (toplev.c:2170)
by 0x11DBCAF: toplev::main(int, char**) (toplev.c:2305)
by 0x2045D37: main (main.c:39)
This patch reduces this to
LEAK SUMMARY:
definitely lost: 344 bytes in 1 blocks
indirectly lost: 3,024 bytes in 4 blocks
possibly lost: 0 bytes in 0 blocks
- still reachable: 1,576,174 bytes in 2,277 blocks
+ still reachable: 1,576,078 bytes in 2,276 blocks
suppressed: 0 bytes in 0 blocks
gcc/fortran/ChangeLog:
2018-10-21 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
* parse.c (clean_up_modules): Free gsym.
Harald Anlauf [Sat, 30 Oct 2021 16:30:33 +0000 (18:30 +0200)]
Fortran: update gfortran.texi list of frequent reporters
gcc/fortran/ChangeLog:
* gfortran.texi (bug reports): credit Gerhard Steinmetz for
numerous bug reports.
Steve Kargl [Sat, 30 Oct 2021 16:22:19 +0000 (18:22 +0200)]
Fortran: generate regular error on invalid conversions of CASE expressions
gcc/fortran/ChangeLog:
PR fortran/99853
* resolve.c (resolve_select): Generate regular gfc_error on
invalid conversions instead of an gfc_internal_error.
gcc/testsuite/ChangeLog:
PR fortran/99853
* gfortran.dg/pr99853.f90: New test.
Alexandre Oliva [Sat, 30 Oct 2021 09:36:05 +0000 (06:36 -0300)]
Implied compares in Ada Harded Conditionals documentation
Improve the wording on optimizations that prevent compare hardening,
so as to also cover cases in which explicit compares get combined into
operations with implied compares.
for gcc/ada/ChangeLog
* doc/gnat_rm/security_hardening_features.rst: Mention
optimization to operations with implied compares.
Jakub Jelinek [Sat, 30 Oct 2021 06:58:08 +0000 (08:58 +0200)]
openmp: Diagnose threadprivate OpenMP loop iterators
We weren't diagnosing the
The loop iteration variable may not appear in a threadprivate directive.
restriction which used to be in 5.0 just among the Worksharing-Loop
restrictions but in 5.1 it is among Canonical Loop Nest Form restrictions.
This patch diagnoses those.
2021-10-30 Jakub Jelinek <jakub@redhat.com>
* gimplify.c (gimplify_omp_for): Diagnose threadprivate iterators.
* c-c++-common/gomp/loop-10.c: New test.
GCC Administrator [Sat, 30 Oct 2021 00:16:25 +0000 (00:16 +0000)]
Daily bump.
Tamar Christina [Fri, 29 Oct 2021 21:12:35 +0000 (22:12 +0100)]
testsuite: Don't expect a complex FMA
The sharing of the COMPLEX_MUL node makes it so it's
more efficient to not generate both a MUL and FMA
in this node.
Because the shape for a normal FMA is not different
the FMA is no longer detected here which results in
better codegen so update the testcase.
gcc/testsuite/ChangeLog:
* g++.dg/vect/pr99149.cc: Update case.
Tobias Burnus [Fri, 29 Oct 2021 20:55:32 +0000 (22:55 +0200)]
libcpp: Fix _Pragma expansion [PR102409]
Both #pragma and _Pragma ended up as CPP_PRAGMA. Presumably since
r131819 (2008, GCC 4.3) for PR34692, pragmas are not expanded in
macro arguments but are output as is before. From the old bug report,
that was to fix usage like
FOO (
#pragma GCC diagnostic
)
However, that change also affected _Pragma such that
BAR (
"1";
_Pragma("omp ..."); )
yielded
#pragma omp ...
followed by what BAR expanded too, possibly including '"1";'.
This commit adds a flag, PRAGMA_OP, to tokens to make the two
distinguishable - and include again _Pragma in the expanded arguments.
libcpp/ChangeLog:
PR c++/102409
* directives.c (destringize_and_run): Add PRAGMA_OP to the
CPP_PRAGMA token's flags to mark is as coming from _Pragma.
* include/cpplib.h (PRAGMA_OP): #define, to be used with token flags.
* macro.c (collect_args): Only handle CPP_PRAGMA special if PRAGMA_OP
is set.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/pragma-1.c: New test.
* c-c++-common/gomp/pragma-2.c: New test.
David Malcolm [Mon, 25 Oct 2021 21:16:07 +0000 (17:16 -0400)]
assert_streq: add newlines to failure message
Adding newlines so that the two strings line up makes string equality
failures considerably easier to read.
gcc/ChangeLog:
* selftest.c (assert_streq): Add newlines when emitting non-equal
non-NULL strings.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Mon, 18 Oct 2021 22:45:17 +0000 (18:45 -0400)]
gcc/Makefile.in: fix bug in gengtype link rule
gcc/ChangeLog:
* Makefile.in: Fix syntax for reference to LIBDEPS in
gengtype link rule.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Jonathan Wakely [Fri, 29 Oct 2021 20:34:16 +0000 (21:34 +0100)]
libstdc++: Fix typo in std::stack test
libstdc++-v3/ChangeLog:
* testsuite/23_containers/stack/deduction.cc: Fix typo.
Bernhard Reutner-Fischer [Wed, 6 Dec 2017 21:55:10 +0000 (22:55 +0100)]
Fortran: Free type-bound procedure structs
compiling gfortran.dg/typebound_proc_31.f90 leaked the type-bound
structs:
56 bytes in 1 blocks are definitely lost.
at 0x4C2CC05: calloc (vg_replace_malloc.c:711)
by 0x151EA90: xcalloc (xmalloc.c:162)
by 0x8E3E4F: gfc_get_typebound_proc(gfc_typebound_proc*) (symbol.c:4945)
by 0x84C095: match_procedure_in_type (decl.c:10486)
by 0x84C095: gfc_match_procedure() (decl.c:6696)
...
gcc/fortran/ChangeLog:
2017-12-06 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
* symbol.c (free_tb_tree): Free type-bound procedure struct.
(gfc_get_typebound_proc): Use explicit memcpy for clarity.
Bernhard Reutner-Fischer [Fri, 29 Oct 2021 00:32:43 +0000 (02:32 +0200)]
doc: Bump required minimum DejaGnu version to 1.5.3
Bump required DejaGnu version to 1.5.3 (or later).
Ok for trunk?
gcc/ChangeLog:
* doc/install.texi: Bump required minimum DejaGnu version.
Aldy Hernandez [Fri, 29 Oct 2021 14:25:47 +0000 (16:25 +0200)]
path oracle: Do not look back to the root oracle for killing defs.
Since registering a kill means removing all references to it from the
path oracle list, make sure we don't look back to the root oracle
either.
Tested on x86-64 Linux.
Co-authored-by: Andrew MacLeod <amacleod@redhat.com>
gcc/ChangeLog:
* value-relation.cc (path_oracle::killing_def): Add a
self-equivalence so we don't look to the root oracle.
Aldy Hernandez [Thu, 28 Oct 2021 13:35:21 +0000 (15:35 +0200)]
Remove VRP threader passes in exchange for better threading pre-VRP.
This patch upgrades the pre-VRP threading passes to fully resolving
backward threaders, and removes the post-VRP threading passes altogether.
With it, we reduce the number of threaders in our pipeline from 9 to 7.
This will leave DOM as the only forward threader client. When the ranger
can handle floats, we should be able to upgrade the pre-DOM threaders to
fully resolving threaders and kill the embedded DOM threader.
The numbers are as follows:
prev: # threads in backward + vrp-threaders = 92624
now: # threads in backward threaders = 94275
Gain: +1.78%
prev: # total threads: 189495
now: # total threads: 193714
Gain: +2.22%
The numbers are not as great as my initial proposal, but I've
recently pushed all the work that got us to this point ;-).
And... the compilation improves by 1.32%!
There's a regression on uninit-pred-7_a.c that I've yet to look at. I
want to make sure it's not a missing thread. If it is, I'll create a PR
and own it.
Also, the tree-ssa/phi_on_compare-*.c tests have all regressed. This
seems to be some special case the forward threader handles that the
backward threader does not (edge_forwards_cmp_to_conditional_jump*).
I haven't dug deep to see if this is solveable within our
infrastructure, but a cursory look shows that even though the VRP
threader threads this, the *.optimized dump ends with more conditional
jumps than without the optimization. I'd like to punt on this for
now, because DOM actually catches this through its lone use of the
forward threader (I've adjusted the tests). However, we will need to
address this sooner or later, if indeed it's still improving the final
assembly.
gcc/ChangeLog:
* passes.def: Replace the pass_thread_jumps before VRP* with
pass_thread_jumps_full. Remove all pass_vrp_threader instances.
* tree-ssa-threadbackward.c (pass_data_thread_jumps_full):
Remove hyphen from "thread-full" name.
libgomp/ChangeLog:
* testsuite/libgomp.graphite/force-parallel-4.c: Adjust for threading changes.
* testsuite/libgomp.graphite/force-parallel-8.c: Same.
gcc/testsuite/ChangeLog:
* gcc.dg/loop-unswitch-2.c: Adjust for threading changes.
* gcc.dg/old-style-asm-1.c: Same.
* gcc.dg/tree-ssa/phi_on_compare-1.c: Same.
* gcc.dg/tree-ssa/phi_on_compare-2.c: Same.
* gcc.dg/tree-ssa/phi_on_compare-3.c: Same.
* gcc.dg/tree-ssa/phi_on_compare-4.c: Same.
* gcc.dg/tree-ssa/pr20701.c: Same.
* gcc.dg/tree-ssa/pr21001.c: Same.
* gcc.dg/tree-ssa/pr21294.c: Same.
* gcc.dg/tree-ssa/pr21417.c: Same.
* gcc.dg/tree-ssa/pr21559.c: Same.
* gcc.dg/tree-ssa/pr21563.c: Same.
* gcc.dg/tree-ssa/pr49039.c: Same.
* gcc.dg/tree-ssa/pr59597.c: Same.
* gcc.dg/tree-ssa/pr61839_1.c: Same.
* gcc.dg/tree-ssa/pr61839_3.c: Same.
* gcc.dg/tree-ssa/pr66752-3.c: Same.
* gcc.dg/tree-ssa/pr68198.c: Same.
* gcc.dg/tree-ssa/pr77445-2.c: Same.
* gcc.dg/tree-ssa/pr77445.c: Same.
* gcc.dg/tree-ssa/ranger-threader-1.c: Same.
* gcc.dg/tree-ssa/ranger-threader-2.c: Same.
* gcc.dg/tree-ssa/ranger-threader-4.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-1.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-11.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-12.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-14.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-16.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-2b.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Same.
* gcc.dg/tree-ssa/ssa-thread-14.c: Same.
* gcc.dg/tree-ssa/ssa-thread-backedge.c: Same.
* gcc.dg/tree-ssa/ssa-vrp-thread-1.c: Same.
* gcc.dg/tree-ssa/vrp02.c: Same.
* gcc.dg/tree-ssa/vrp03.c: Same.
* gcc.dg/tree-ssa/vrp05.c: Same.
* gcc.dg/tree-ssa/vrp06.c: Same.
* gcc.dg/tree-ssa/vrp07.c: Same.
* gcc.dg/tree-ssa/vrp08.c: Same.
* gcc.dg/tree-ssa/vrp09.c: Same.
* gcc.dg/tree-ssa/vrp33.c: Same.
* gcc.dg/uninit-pred-9_b.c: Same.
* gcc.dg/uninit-pred-7_a.c: xfail.
Jeff Law [Fri, 29 Oct 2021 15:30:15 +0000 (11:30 -0400)]
Avoid overly-greedy match in dejagnu regexp.
Occasionally I've been seeing failures with the multi-line diagnostics. It's never been clear what's causing the spurious failures, though I have long suspected a greedy regexp match.
It happened again yesterday with a local change that in no way should affect diagnostics, so I finally went searching and found that sure enough the multi-line diagnostics had a ".*" in their regexp. According to the comments, the .* is primarily to catch any dg directives that may appear -- ie it should eat to EOL, but not multiple lines. But a .* can indeed match a newline and cause it to eat multiple lines.
The fix is simple. [^\r\n]* will eat to EOL, but not further.
Regression tested on x86_64 and on our internal target.
gcc/testsuite
* lib/multiline.exp (_build_multiline_regex): Use a better
regexp than .* to match up to EOL.
Andrew MacLeod [Thu, 28 Oct 2021 17:31:17 +0000 (13:31 -0400)]
Perform on-entry propagation after range_of_stmt on a gcond.
Propagation is automatically done by the temporal cache when defs are
out of date from the names on the RHS, but a gcond has no LHS, and any
updates on the RHS are never propagated. Always propagate them.
gcc/
PR tree-optimization/102983
* gimple-range-cache.h (propagate_updated_value): Make public.
* gimple-range.cc (gimple_ranger::range_of_stmt): Propagate exports
when processing gcond stmts.
gcc/testsuite/
* gcc.dg/pr102983.c: New.
Jan Hubicka [Fri, 29 Oct 2021 14:01:51 +0000 (16:01 +0200)]
handle retslot in modref
Extend modref and tree-ssa-structalias to handle retslot flags.
Since retslot it essentially a hidden argument that is known to be write-only
we can do pretty much the same stuff as we do for regular parameters.
I plan to add static chain handling similar way.
We do not handle IPA propagation of retslot flags (where return slot is
initialized via return slot of other function). For this ipa-prop needs
to be extended to understand retslot as well.
Bootstrapped/regtested x86_64-linux, OK for the gimple bits?
Honza
gcc/ChangeLog:
* gimple.c (gimple_call_retslot_flags): New function.
* gimple.h (gimple_call_retslot_flags): Declare.
* ipa-modref.c: Include tree-cfg.h.
(struct escape_entry): Turn parm_index to signed.
(modref_summary_lto::modref_summary_lto): Add retslot_flags.
(modref_summary::modref_summary): Initialize retslot_flags.
(struct modref_summary_lto): Likewise.
(modref_summary::useful_p): Check retslot_flags.
(modref_summary_lto::useful_p): Likewise.
(modref_summary::dump): Dump retslot_flags.
(modref_summary_lto::dump): Likewise.
(struct escape_point): Add hidden_args enum.
(analyze_ssa_name_flags): Ignore return slot return;
use gimple_call_retslot_flags.
(record_escape_points): Break out from ...
(analyze_parms): ... here; handle retslot_flags.
(modref_summaries::duplicate): Duplicate retslot_flags.
(modref_summaries_lto::duplicate): Likewise.
(modref_write_escape_summary): Stream parm_index as signed.
(modref_read_escape_summary): Likewise.
(modref_write): Stream retslot_flags.
(read_section): Likewise.
(struct escape_map): Fix typo in comment.
(update_escape_summary_1): Fix whitespace.
(ipa_merge_modref_summary_after_inlining): Drop retslot_flags.
(modref_merge_call_site_flags): Merge retslot_flags.
* ipa-modref.h (struct modref_summary): Add retslot_flags.
* tree-ssa-structalias.c (handle_rhs_call): Handle retslot_flags.
Tamar Christina [Fri, 29 Oct 2021 11:47:39 +0000 (12:47 +0100)]
middle-end: Add target independent tests for Arm complex numbers vectorization.
This beefs up the complex numbers vectorization testsuite
and adds target independent checks next to the target
dependent ones.
This allows regressions to the detection code to be found
when running on any target, not just aarch64.
gcc/testsuite/ChangeLog:
PR tree-optimization/102977
* gcc.dg/vect/complex/bb-slp-complex-add-pattern-int.c: Updated.
* gcc.dg/vect/complex/bb-slp-complex-add-pattern-long.c: Updated.
* gcc.dg/vect/complex/bb-slp-complex-add-pattern-short.c: Updated.
* gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-int.c:
Updated.
* gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-long.c:
Updated.
* gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-short.c:
Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-add-double.c:
* gcc.dg/vect/complex/fast-math-bb-slp-complex-add-float.c: Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-add-half-float.c:
Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-double.c:
Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-float.c:
Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-half-float.c:
Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-double.c:
Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-float.c: Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-half-float.c:
Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-double.c:
Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-float.c: Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-half-float.c:
Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-double.c: Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-float.c: Updated.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-half-float.c:
Updated.
* gcc.dg/vect/complex/fast-math-complex-add-double.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-add-float.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-add-half-float.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-add-pattern-double.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-add-pattern-float.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-add-pattern-half-float.c:
Updated.
* gcc.dg/vect/complex/fast-math-complex-mla-double.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-mla-float.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-mla-half-float.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-mls-double.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-mls-float.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-mls-half-float.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-mul-double.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-mul-float.c: Updated.
* gcc.dg/vect/complex/fast-math-complex-mul-half-float.c: Updated.
* gcc.dg/vect/complex/vect-complex-add-pattern-byte.c: Updated.
* gcc.dg/vect/complex/vect-complex-add-pattern-int.c: Updated.
* gcc.dg/vect/complex/vect-complex-add-pattern-long.c: Updated.
* gcc.dg/vect/complex/vect-complex-add-pattern-short.c: Updated.
* gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-byte.c:
Updated.
* gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-int.c:
Updated.
* gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-long.c:
Updated.
* gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-short.c:
Updated.
* gcc.dg/vect/complex/bb-slp-complex-add-pattern-byte.c: Removed.
* gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-byte.c:
Removed.
Tamar Christina [Fri, 29 Oct 2021 11:45:41 +0000 (12:45 +0100)]
middle-end: Update the Arm complex numbers auto-vec detection to the new format of the SLP tree.
The layout of the SLP tree has changed in GCC 12 which
broke the detection of complex FMA and FMS.
This patch updates the detection to the new tree shape
and by necessity merges the complex MUL and FMA detection
into one.
This does not yet address the wrong code-gen PR which I
will fix in a different patch as that needs backporting.
gcc/ChangeLog:
PR tree-optimization/102977
* tree-vect-slp-patterns.c (vect_match_call_p): Remove.
(vect_detect_pair_op): Add crosslane check.
(vect_match_call_complex_mla): Remove.
(class complex_mul_pattern): Update comment.
(complex_mul_pattern::matches): Update detection.
(class complex_fma_pattern): Remove.
(complex_fma_pattern::matches): Remove.
(complex_fma_pattern::recognize): Remove.
(complex_fma_pattern::build): Remove.
(class complex_fms_pattern): Update comment.
(complex_fms_pattern::matches): Remove.
(complex_operations_pattern::recognize): Remove complex_fma_pattern
Jakub Jelinek [Fri, 29 Oct 2021 08:20:29 +0000 (10:20 +0200)]
gimple-fold: Preserve location in gimple_fold_builtin_memset
As mentioned yesterday, gimple_fold_builtin_memset doesn't preserve
locus which means e.g. the -Wstringop-overflow warnings are emitted as:
In function 'test_max':
cc1: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
The function emits up to 2 new statements, but the latter (asgn) is added
through gsi_replace and therefore the locus is copied over from the call.
But store is emitted before the call and optionally the call removed
afterwards, so locus needs to be copied over manually.
2021-10-29 Jakub Jelinek <jakub@redhat.com>
* gimple-fold.c (gimple_fold_builtin_memset): Copy over location from
call to store.
* gcc.dg/Wstringop-overflow-62.c: Adjust expected diagnostics.
Richard Biener [Fri, 29 Oct 2021 07:44:39 +0000 (09:44 +0200)]
Force -fexcess-precision=standard for fp-uint64-convert-double-1.c
This forces -fexcess-precision=standard since the testcase is
otherwise prone to fail with x87 math.
2021-10-29 Richard Biener <rguenther@suse.de>
* gcc.dg/torture/fp-uint64-convert-double-1.c: Add
-fexcess-precision=standard.
Jakub Jelinek [Fri, 29 Oct 2021 07:28:32 +0000 (09:28 +0200)]
c++: Implement DR2351 - void{} [PR102820]
Here is an implementation of DR2351 - void{} - where void{} after
pack expansion is considered valid and the same thing as void().
For templates, if CONSTRUCTOR_NELTS is 0, the CONSTRUCTOR is not dependent
and we can return void_node right away, if it is dependent and contains
only packs, then it is potentially zero element and so we need to build
CONSTRUCTOR_IS_DEPENDENT CONSTRUCTOR, while if it contains any non-pack
elts, we can diagnose it right away.
2021-10-29 Jakub Jelinek <jakub@redhat.com>
PR c++/102820
* semantics.c (maybe_zero_constructor_nelts): New function.
(finish_compound_literal): Implement DR2351 - void{}.
If type is cv void and compound_literal has no elements, return
void_node. If type is cv void and compound_literal might have no
elements after expansion, handle it like other dependent compound
literals.
* g++.dg/cpp0x/dr2351.C: New test.
Xionghu Luo [Fri, 29 Oct 2021 02:28:43 +0000 (21:28 -0500)]
rs6000: Optimize __builtin_shuffle when it's used to zero the upper bits [PR102868]
If the second operand of __builtin_shuffle is const vector 0, and with
specific mask, it can be optimized to vspltisw+xxpermdi instead of lxv.
gcc/ChangeLog:
PR target/102868
* config/rs6000/rs6000.c (altivec_expand_vec_perm_const): Add
patterns match and emit for VSX xxpermdi.
gcc/testsuite/ChangeLog:
PR target/102868
* gcc.target/powerpc/pr102868.c: New test.
liuhongt [Mon, 25 Oct 2021 07:20:35 +0000 (15:20 +0800)]
Enable vectorization for _Float16 floor/ceil/trunc/nearbyint/rint operations.
gcc/ChangeLog:
PR target/102464
* config/i386/i386-builtin-types.def (V8HF_FTYPE_V8HF): New
function type.
(V16HF_FTYPE_V16HF): Ditto.
(V32HF_FTYPE_V32HF): Ditto.
(V8HF_FTYPE_V8HF_ROUND): Ditto.
(V16HF_FTYPE_V16HF_ROUND): Ditto.
(V32HF_FTYPE_V32HF_ROUND): Ditto.
* config/i386/i386-builtin.def ( IX86_BUILTIN_FLOORPH,
IX86_BUILTIN_CEILPH, IX86_BUILTIN_TRUNCPH,
IX86_BUILTIN_FLOORPH256, IX86_BUILTIN_CEILPH256,
IX86_BUILTIN_TRUNCPH256, IX86_BUILTIN_FLOORPH512,
IX86_BUILTIN_CEILPH512, IX86_BUILTIN_TRUNCPH512): New builtin.
* config/i386/i386-builtins.c
(ix86_builtin_vectorized_function): Enable vectorization for
HFmode FLOOR/CEIL/TRUNC operation.
* config/i386/i386-expand.c (ix86_expand_args_builtin): Handle
new builtins.
* config/i386/sse.md (rint<mode>2, nearbyint<mode>2): Extend
to vector HFmodes.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr102464-vrndscaleph.c: New test.
GCC Administrator [Fri, 29 Oct 2021 00:16:37 +0000 (00:16 +0000)]
Daily bump.
Aldy Hernandez [Thu, 28 Oct 2021 13:54:27 +0000 (15:54 +0200)]
path relation oracle: Remove SSA's being killed from the equivalence list.
Same thing as the relational change. Walk any equivalences that have
been registered on the path, and remove the name being killed. The
only reason we had added the equivalence with itself earlier is so we
wouldn't search any further in the equivalency list. So if we are
removing all references to it, then we no longer need to add a "kill"
record.
Will push pending tests on x86-64 Linux.
Co-authored-by: Andrew MacLeod <amacleod@redhat.com>
gcc/ChangeLog:
* value-relation.cc (path_oracle::killing_def): Walk the
equivalency list and remove SSA from any equivalencies.
Stafford Horne [Wed, 27 Oct 2021 21:54:05 +0000 (06:54 +0900)]
or1k: Add return address argument to _mcount call
This fixes an issue in the glibc port I am working on where the build
fails due to the warning:
error: calling ‘__builtin_return_address’ with a nonzero argument is unsafe [-Werror=frame-address]
This is due to how the current implementation of _mcount in glibc uses
__builtin_return_address with a count argument of 1.
Fix that by passing the value of LR_REGNUM to the _mcount function,
effectivtly providing the value _mcount is after.
This is an ABI change, but I think it's OK because the glibc port for
or1k is not yet upstreamed. Also, I think just adding an argument
should not break anything anyway.
gcc/ChangeLog:
* config/or1k/or1k.h (PROFILE_HOOK): Add return address argument
to _mcount.
Jakub Jelinek [Thu, 28 Oct 2021 18:10:15 +0000 (20:10 +0200)]
match.pd: Optimize MIN_EXPR <addr1, addr2> etc. addr1 < addr2 would be simplified [PR102951]
This patch outlines the decision whether address comparison can be folded
or not from the match.pd simple comparison simplification and uses it
both there and in a new minmax simplification, such that we fold e.g.
MAX (&a[2], &a[1]) etc.
Some of the Wstringop-overflow-62.c changes might look weird, but that
seems to be mainly due to gimple_fold_builtin_memset not bothering to
copy over location, will fix that incrementally.
2021-10-28 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/102951
* fold-const.h (address_compare): Declare.
* fold-const.c (address_compare): New function.
* match.pd (cmp (convert1?@2 addr@0) (convert2? addr@1)): Use
address_compare helper.
(minmax cmp (convert1?@2 addr@0) (convert2?@3 addr@1)): New
simplification.
* gcc.dg/tree-ssa/pr102951.c: New test.
* gcc.dg/Wstringop-overflow-62.c: Adjust expected diagnostics.
Andrew MacLeod [Mon, 25 Oct 2021 17:34:36 +0000 (13:34 -0400)]
Fix ifcvt-4.c to not depend on VRP2 asserts.
The testcase fails if VRP2 is replaced with a non-assert based VRP because it
accidentally depends on specific IL changes when the asserts are removed. This
removes that dependency.
gcc/testsuite/
* gcc.dg/ifcvt-4.c: Adjust.
Andrew MacLeod [Tue, 26 Oct 2021 17:19:05 +0000 (13:19 -0400)]
Unify EVRP and VRP folding predicate message.
EVRP issues a message fior folding predicates in a different format than
VRP does, this patch unifies the messaging.
gcc/
* vr-values.c (simplify_using_ranges::fold_cond): Change fold message.
gcc/testsuite/
* gcc.dg/tree-ssa/evrp9.c: Adjust message scanned for.
* gcc.dg/tree-ssa/pr21458-2.c: Ditto.
Andrew MacLeod [Tue, 26 Oct 2021 18:43:33 +0000 (14:43 -0400)]
Reset scev before invoking array_checker.
Before invoking the array_checker, we need to reset scev so it will not try to
access any ssa_names that the substitute and fold engine has freed.
PR tree-optimization/102940
* tree-vrp.c (execute_ranger_vrp): Reset scev.
Patrick Palka [Thu, 28 Oct 2021 14:46:46 +0000 (10:46 -0400)]
c++: CTAD within template argument [PR102933]
Here when checking for erroneous occurrences of 'auto' inside a template
argument (which is allowed by the concepts TS for class templates),
extract_autos_r picks up the CTAD placeholder for X{T{0}} which causes
check_auto_in_tmpl_args to reject this valid template argument. This
patch fixes this by making extract_autos_r ignore CTAD placeholders.
However, it seems we don't need to call check_auto_in_tmpl_args at all
outside of the concepts TS since using 'auto' as a type-id is otherwise
rejected more generally at parse time. So this patch makes the function
just exit early if !flag_concepts_ts.
Similarly, I think the concepts code paths in do_auto_deduction and
type_uses_auto are only necessary for the concepts TS, so this patch
also restricts these code paths accordingly.
PR c++/102933
gcc/cp/ChangeLog:
* parser.c (cp_parser_simple_type_specifier): Adjust diagnostic
for using auto in parameter declaration.
* pt.c (extract_autos_r): Ignore CTAD placeholders.
(extract_autos): Use range-based for.
(do_auto_deduction): Use extract_autos only for the concepts TS
and not also for standard concepts.
(type_uses_auto): Likewise with for_each_template_parm.
(check_auto_in_tmpl_args): Just return false outside of the
concepts TS. Simplify.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/nontype-class50.C: New test.
* g++.dg/cpp2a/nontype-class50a.C: New test.
Richard Purdie [Thu, 28 Oct 2021 14:45:10 +0000 (10:45 -0400)]
[PATCH 4/5] gcc/nios2: Define the musl linker
Add a definition of the musl linker used on the nios2 platform.
2021-10-26 Richard Purdie <richard.purdie@linuxfoundation.org>
gcc/ChangeLog:
* config/nios2/linux.h (MUSL_DYNAMIC_LINKER): Add musl linker
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Richard Purdie [Thu, 28 Oct 2021 14:41:25 +0000 (10:41 -0400)]
[PATCH 1/5] Makefile.in: Ensure build CPP/CPPFLAGS is used for build targets
During cross compiling, CPP is being set to the target compiler even for
build targets. As an example, when building a cross compiler targetting
mingw, the config.log for libiberty in
build.x86_64-pokysdk-mingw32.i586-poky-linux/build-x86_64-linux/libiberty/config.log
shows:
configure:3786: checking how to run the C preprocessor
configure:3856: result: x86_64-pokysdk-mingw32-gcc -E --sysroot=[sysroot]/x86_64-nativesdk-mingw32-pokysdk-mingw32
configure:3876: x86_64-pokysdk-mingw32-gcc -E --sysroot=[sysroot]/x86_64-nativesdk-mingw32-pokysdk-mingw32 conftest.c
configure:3876: $? = 0
This is libiberty being built for the build environment, not the target one
(i.e. in build-x86_64-linux). As such it should be using the build environment's
gcc and not the target one. In the mingw case the system headers are quite
different leading to build failures related to not being able to include a
process.h file for pem-unix.c.
Further analysis shows the same issue occuring for CPPFLAGS too.
Fix this by adding support for CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD which
for example, avoids mixing the mingw headers for host binaries on linux
systems.
2021-10-27 Richard Purdie <richard.purdie@linuxfoundation.org>
ChangeLog:
* Makefile.tpl: Add CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD support
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Add CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD support
gcc/ChangeLog:
* configure: Regenerate.
* configure.ac: Use CPPFLAGS_FOR_BUILD for GMPINC
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Patrick Palka [Thu, 28 Oct 2021 14:05:14 +0000 (10:05 -0400)]
c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]
In the testcase below the two left fold expressions each expand into a
constant logical expression with 1024 terms, for which potential_const_expr
takes more than a minute to return true. This happens because p_c_e_1
performs trial evaluation of the first operand of a &&/|| in order to
determine whether to consider the potentiality of the second operand.
And because the expanded expression is left-associated, this trial
evaluation causes p_c_e_1 to be quadratic in the number of terms of the
expression.
This patch fixes this quadratic behavior by making p_c_e_1 preemptively
compute potentiality of the second operand of a &&/||, and perform trial
evaluation of the first operand only if the second operand isn't
potentially constant. We must be careful to avoid emitting bogus
diagnostics during the preemptive computation; to that end, we perform
this shortcut only when tf_error is cleared, and when tf_error is set we
now first check potentiality of the whole expression quietly and replay
the check noisily for diagnostics.
Apart from fixing the quadraticness for left-associated logical exprs,
this change also reduces compile time for the libstdc++ testcase
20_util/variant/87619.cc by about 15% even though our <variant> uses
right folds instead of left folds. Likewise for the testcase in the PR,
for which compile time is reduced by 30%. The reason for these speedups
is that p_c_e_1 no longer performs expensive trial evaluation of each term
of large constant logical expressions when determining their potentiality.
PR c++/102780
gcc/cp/ChangeLog:
* constexpr.c (potential_constant_expression_1) <case TRUTH_*_EXPR>:
When tf_error isn't set, preemptively check potentiality of the
second operand before performing trial evaluation of the first
operand.
(potential_constant_expression_1): When tf_error is set, first check
potentiality quietly and return true if successful, otherwise
proceed noisily to give errors.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/fold13.C: New test.
Eric Botcazou [Thu, 28 Oct 2021 13:51:14 +0000 (15:51 +0200)]
Update documentation of %X spec
%X
Output the accumulated linker options specified by -Wl or a ‘%x’ spec string
The part about -Wl has been obsolete for 27 years, since this change:
Author: Torbjorn Granlund <tege@gnu.org>
Date: Thu Oct 27 18:04:25 1994 +0000
(process_command): Handle -Wl, and -Xlinker similar to -l,
i.e., preserve their order with respect to linker input files.
Technically speaking, the arguments of -l, -Wl and -Xlinker are input files.
gcc/
* doc/invoke.texi (%X): Remove obsolete reference to -Wl.
Richard Biener [Thu, 28 Oct 2021 09:38:32 +0000 (11:38 +0200)]
middle-end/84407 - honor -frounding-math for int to float conversion
This makes us honor -frounding-math for integer to float conversions
and avoid constant folding when such conversion is not exact.
2021-10-28 Richard Biener <rguenther@suse.de>
PR middle-end/84407
* fold-const.c (fold_convert_const): Avoid int to float
constant folding with -frounding-math and inexact result.
* simplify-rtx.c (simplify_const_unary_operation): Likewise
for both float and unsigned_float.
* gcc.dg/torture/fp-uint64-convert-double-1.c: New testcase.
* gcc.dg/torture/fp-uint64-convert-double-2.c: Likewise.
Aldy Hernandez [Thu, 28 Oct 2021 09:44:13 +0000 (11:44 +0200)]
Improve backward threading with switches.
We've been essentially using find_taken_edge_switch_expr() in the
backward threader, but this is suboptimal because said function only
works with singletons. VRP has a much smarter find_case_label_range
that works with ranges.
Tested on x86-64 Linux with:
a) Bootstrap & regtests.
b) Verifying we get more threads than before.
c) Asserting that the new code catches everything the old one
code caught (over a set of bootstrap .ii files).
gcc/ChangeLog:
* tree-ssa-threadbackward.c
(back_threader::find_taken_edge_switch): Use find_case_label_range
instead of find_taken_edge.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/vrp106.c: Adjust for threading.
* gcc.dg/tree-ssa/vrp113.c: Same.
Aldy Hernandez [Wed, 27 Oct 2021 19:31:35 +0000 (21:31 +0200)]
Make back_threader_registry inherit from back_jt_path_registry.
When a class's only purpose is to expose the methods of its only
member, it's really a derived class ;-).
Tested on x86-64 Linux.
gcc/ChangeLog:
* tree-ssa-threadbackward.c (class back_threader_registry):
Inherit from back_jt_path_registry.
(back_threader_registry::thread_through_all_blocks): Remove.
(back_threader_registry::register_path): Remove
m_lowlevel_registry prefix.
Richard Biener [Wed, 27 Oct 2021 12:27:40 +0000 (14:27 +0200)]
middle-end/57245 - honor -frounding-math in real truncation
The following honors -frounding-math when converting a FP constant
to another FP type.
2021-10-27 Richard Biener <rguenther@suse.de>
PR middle-end/57245
* fold-const.c (fold_convert_const_real_from_real): Honor
-frounding-math if the conversion is not exact.
* simplify-rtx.c (simplify_const_unary_operation): Do not
simplify FLOAT_TRUNCATE with sign dependent rounding.
* gcc.dg/torture/fp-double-convert-float-1.c: New testcase.
Richard Biener [Thu, 28 Oct 2021 08:07:40 +0000 (10:07 +0200)]
tree-optimization/102949 - fix base object alignment
This fixes fallout of g:
4703182a06b831a9 where we now silently fail
to force alignment of a base object. The fix is to look at the
dr_info of the group leader to be consistent with alignment analysis.
2021-10-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/102949
* tree-vect-stmts.c (ensure_base_align): Look at the
dr_info of a group leader and assert we are looking at
one with analyzed alignment.
Kewen Lin [Thu, 28 Oct 2021 06:11:56 +0000 (01:11 -0500)]
rs6000: Fix ICE of vect cost related to V1TI [PR102767]
As PR102767 shows, the commit r12-3482 exposed one ICE in function
rs6000_builtin_vectorization_cost. We claims V1TI supports
movmisalign on rs6000 (See define_expand "movmisalign<mode>"), so
it return true in rs6000_builtin_support_vector_misalignment for
misalign 8. Later in the cost querying function
rs6000_builtin_vectorization_cost, we don't have the arms to handle
the V1TI input under (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN).
The proposed fix is to add the consideration for V1TI, simply make
it as the cost for doubleword which is apparently bigger than the
cost of scalar, won't have the vectorization to happen, just to
keep consistency and avoid ICE. Another thought is to not support
movmisalign for V1TI, but it sounds like a bad idea since it doesn't
match the reality.
Note that this patch also fixes up the wrong indentations around.
gcc/ChangeLog:
PR target/102767
* config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost): Consider
V1T1 mode for unaligned load and store.
gcc/testsuite/ChangeLog:
PR target/102767
* gcc.target/powerpc/ppc-fortran/pr102767.f90: New file.
Kito Cheng [Wed, 27 Oct 2021 16:27:39 +0000 (00:27 +0800)]
RISC-V: Fix wrong predicator for zero_extendsidi2_internal pattern
We're wrongly guard zero_extendsidi2_internal pattern both ZBA and ZBB,
only ZBA provide zero_extendsidi2 instruction.
gcc/ChangeLog
* config/riscv/riscv.md (zero_extendsidi2_internal): Allow ZBB
use this pattern.
Kito Cheng [Wed, 27 Oct 2021 15:41:17 +0000 (23:41 +0800)]
RISC-V: Handle zi* extension correctly for arch-canonicalize script
Canonical order for z-prefixed extension are rely on the canonical order of
single letter extension, however we didn't put i into the list before,
so when we put zicsr or zifencei it will got exception.
gcc/ChangeLog:
* config/riscv/arch-canonicalize (CANONICAL_ORDER): Add `i` to
CANONICAL_ORDER.
Alexandre Oliva [Thu, 28 Oct 2021 03:51:02 +0000 (00:51 -0300)]
hardened conditionals
This patch introduces optional passes to harden conditionals used in
branches, and in computing boolean expressions, by adding redundant
tests of the reversed conditions, and trapping in case of unexpected
results. Though in abstract machines the redundant tests should never
fail, CPUs may be led to misbehave under certain kinds of attacks,
such as of power deprivation, and these tests reduce the likelihood of
going too far down an unexpected execution path.
for gcc/ChangeLog
* common.opt (fharden-compares): New.
(fharden-conditional-branches): New.
* doc/invoke.texi: Document new options.
* gimple-harden-conditionals.cc: New.
* Makefile.in (OBJS): Build it.
* passes.def: Add new passes.
* tree-pass.h (make_pass_harden_compares): Declare.
(make_pass_harden_conditional_branches): Declare.
for gcc/ada/ChangeLog
* doc/gnat_rm/security_hardening_features.rst
(Hardened Conditionals): New.
for gcc/testsuite/ChangeLog
* c-c++-common/torture/harden-comp.c: New.
* c-c++-common/torture/harden-cond.c: New.
Xionghu Luo [Thu, 28 Oct 2021 02:22:39 +0000 (21:22 -0500)]
rs6000: Fold xxsel to vsel since they have same semantics
Fold xxsel to vsel like xxperm/vperm to avoid duplicate code.
gcc/ChangeLog:
2021-10-28 Xionghu Luo <luoxhu@linux.ibm.com>
PR target/94613
* config/rs6000/altivec.md: Add vsx register constraints.
* config/rs6000/vsx.md (vsx_xxsel<mode>): Delete.
(vsx_xxsel<mode>2): Likewise.
(vsx_xxsel<mode>3): Likewise.
(vsx_xxsel<mode>4): Likewise.
gcc/testsuite/ChangeLog:
2021-10-28 Xionghu Luo <luoxhu@linux.ibm.com>
* gcc.target/powerpc/builtins-1.c: Adjust.
Xionghu Luo [Thu, 28 Oct 2021 02:21:20 +0000 (21:21 -0500)]
rs6000: Fix wrong code generation for vec_sel [PR94613]
The vsel instruction is a bit-wise select instruction. Using an
IF_THEN_ELSE to express it in RTL is wrong and leads to wrong code
being generated in the combine pass. Per element selection is a
subset of per bit-wise selection,with the patch the pattern is
written using bit operations. But there are 8 different patterns
to define "op0 := (op1 & ~op3) | (op2 & op3)":
(~op3&op1) | (op3&op2),
(~op3&op1) | (op2&op3),
(op3&op2) | (~op3&op1),
(op2&op3) | (~op3&op1),
(op1&~op3) | (op3&op2),
(op1&~op3) | (op2&op3),
(op3&op2) | (op1&~op3),
(op2&op3) | (op1&~op3),
The latter 4 cases does not follow canonicalisation rules, non-canonical
RTL is invalid RTL in vregs pass. Secondly, combine pass will swap
(op1&~op3) to (~op3&op1) by commutative canonical, which could reduce
it to the FIRST 4 patterns, but it won't swap (op2&op3) | (~op3&op1) to
(~op3&op1) | (op2&op3), so this patch handles it with 4 patterns with
different NOT op3 position and check equality inside it.
Tested pass on P7, P8 and P9.
gcc/ChangeLog:
2021-10-28 Xionghu Luo <luoxhu@linux.ibm.com>
PR target/94613
* config/rs6000/altivec.md (*altivec_vsel<mode>): Change to ...
(altivec_vsel<mode>): ... this and update define.
(*altivec_vsel<mode>_uns): Delete.
(altivec_vsel<mode>2): New define_insn.
(altivec_vsel<mode>3): Likewise.
(altivec_vsel<mode>4): Likewise.
* config/rs6000/rs6000-call.c (altivec_expand_vec_sel_builtin): New.
(altivec_expand_builtin): Call altivec_expand_vec_sel_builtin to expand
vel_sel.
* config/rs6000/rs6000.c (rs6000_emit_vector_cond_expr): Use bit-wise
selection instead of per element.
* config/rs6000/vector.md:
* config/rs6000/vsx.md (*vsx_xxsel<mode>): Change to ...
(vsx_xxsel<mode>): ... this and update define.
(*vsx_xxsel<mode>_uns): Delete.
(vsx_xxsel<mode>2): New define_insn.
(vsx_xxsel<mode>3): Likewise.
(vsx_xxsel<mode>4): Likewise.
gcc/testsuite/ChangeLog:
2021-10-28 Xionghu Luo <luoxhu@linux.ibm.com>
PR target/94613
* gcc.target/powerpc/pr94613.c: New test.
Hongyu Wang [Mon, 25 Oct 2021 09:00:46 +0000 (17:00 +0800)]
AVX512FP16: Optimize _Float16 reciprocal for div and sqrt
For _Float16 type, add insn and expanders to optimize x / y to
x * rcp (y), and x / sqrt (y) to x * rsqrt (y).
As Half float only have minor precision difference between div and
mul * rcp, there is no need for Newton-Rhapson approximation.
gcc/ChangeLog:
* config/i386/i386.c (use_rsqrt_p): Add mode parameter, enable
HFmode rsqrt without TARGET_SSE_MATH.
(ix86_optab_supported_p): Refactor rint, adjust floor, ceil,
btrunc condition to be restricted by -ftrapping-math, adjust
use_rsqrt_p function call.
* config/i386/i386.md (rcphf2): New define_insn.
(rsqrthf2): Likewise.
* config/i386/sse.md (div<mode>3): Change VF2H to VF2.
(div<mode>3): New expander for HF mode.
(rsqrt<mode>2): Likewise.
(*avx512fp16_vmrcpv8hf2): New define_insn for rpad pass.
(*avx512fp16_vmrsqrtv8hf2): Likewise.
gcc/testsuite/ChangeLog:
* gcc.target/i386/avx512fp16-recip-1.c: New test.
* gcc.target/i386/avx512fp16-recip-2.c: Ditto.
* gcc.target/i386/pr102464.c: Add -fno-trapping-math.
GCC Administrator [Thu, 28 Oct 2021 00:16:39 +0000 (00:16 +0000)]
Daily bump.
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 22:08:57 +0000 (00:08 +0200)]
Fortran: Delete unused decl in intrinsic.h
gcc/fortran/ChangeLog:
* intrinsic.h (gfc_check_sum, gfc_resolve_atan2d, gfc_resolve_kill,
gfc_resolve_kill_sub): Delete declaration.
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 20:52:00 +0000 (22:52 +0200)]
Fortran: Delete unused decl in trans-types.h
gcc/fortran/ChangeLog:
* trans-types.h (gfc_convert_function_code): Delete.
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 20:43:26 +0000 (22:43 +0200)]
Fortran: Delete unused decl in trans-stmt.h
gcc/fortran/ChangeLog:
* trans-stmt.h (gfc_trans_deallocate_array): Delete.
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 19:57:43 +0000 (21:57 +0200)]
Fortran: make some trans-array functions static
gcc/fortran/ChangeLog:
* trans-array.c (gfc_trans_scalarized_loop_end): Make static.
* trans-array.h (gfc_trans_scalarized_loop_end,
gfc_conv_tmp_ref, gfc_conv_array_transpose): Delete declaration.
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 19:22:11 +0000 (21:22 +0200)]
Fortran: make some constructor* functions static
gfc_constructor_expr_foreach and gfc_constructor_swap were just stubs.
gcc/fortran/ChangeLog:
* constructor.c (gfc_constructor_get_base): Make static.
(gfc_constructor_expr_foreach, gfc_constructor_swap): Delete.
* constructor.h (gfc_constructor_get_base): Remove declaration.
(gfc_constructor_expr_foreach, gfc_constructor_swap): Delete.
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 19:05:35 +0000 (21:05 +0200)]
Fortran: make some match* functions static
gfc_match_small_int_expr was unused, delete it.
gfc_match_gcc_unroll should use gfc_match_small_literal_int and then
gfc_match_small_int can be deleted since it will be unused.
gcc/fortran/ChangeLog:
* decl.c (gfc_match_old_kind_spec, set_com_block_bind_c,
set_verify_bind_c_sym, set_verify_bind_c_com_block,
get_bind_c_idents, gfc_match_suffix, gfc_get_type_attr_spec,
check_extended_derived_type): Make static.
(gfc_match_gcc_unroll): Add comment.
* match.c (gfc_match_small_int_expr): Delete definition.
* match.h (gfc_match_small_int_expr): Delete declaration.
(gfc_match_name_C, gfc_match_old_kind_spec, set_com_block_bind_c,
set_verify_bind_c_sym, set_verify_bind_c_com_block,
get_bind_c_idents, gfc_match_suffix,
gfc_get_type_attr_spec): Delete declaration.
Bernhard Reutner-Fischer [Sun, 24 Oct 2021 19:04:44 +0000 (21:04 +0200)]
Fortran: make some trans* functions static
This makes some trans* functions static and deletes declarations of
functions that either do not exist anymore like gfc_get_function_decl
or that are unused like gfc_check_any_c_kind.
gcc/fortran/ChangeLog:
* expr.c (is_non_empty_structure_constructor): Make static.
* gfortran.h (gfc_check_any_c_kind): Delete.
* match.c (gfc_match_label): Make static.
* match.h (gfc_match_label): Delete declaration.
* scanner.c (file_changes_cur, file_changes_count,
file_changes_allocated): Make static.
* trans-expr.c (gfc_get_character_len): Make static.
(gfc_class_len_or_zero_get): Make static.
(VTAB_GET_FIELD_GEN): Undefine.
(gfc_get_class_array_ref): Make static.
(gfc_finish_interface_mapping): Make static.
* trans-types.c (gfc_check_any_c_kind): Delete.
(pfunc_type_node, dtype_type_node, gfc_get_ppc_type): Make static.
* trans-types.h (gfc_get_ppc_type): Delete declaration.
* trans.c (gfc_msg_wrong_return): Delete.
* trans.h (gfc_class_len_or_zero_get, gfc_class_vtab_extends_get,
gfc_vptr_extends_get, gfc_get_class_array_ref, gfc_get_character_len,
gfc_finish_interface_mapping, gfc_msg_wrong_return,
gfc_get_function_decl): Delete declaration.
H.J. Lu [Wed, 27 Oct 2021 18:40:50 +0000 (11:40 -0700)]
libffi: Update LOCAL_PATCHES
Add
commit
90205f67e465ae7dfcf733c2b2b177ca7ff68da0
Author: Segher Boessenkool <segher@kernel.crashing.org>
Date: Mon Oct 25 23:29:26 2021 +0000
rs6000: Fix bootstrap (libffi)
This fixes bootstrap for the current problems building libffi.
to LOCAL_PATCHES.
* LOCAL_PATCHES: Add commit
90454a90082.
Saagar Jha [Tue, 15 Jun 2021 11:08:23 +0000 (04:08 -0700)]
Darwin, config: Amend for Darwin 21 / macOS 12.
It seems that the OS major version is now tracking the kernel
major version - 9. Minor version has been set to kerne
min - 1.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Signed-off-by: Saagar Jha <saagar@saagarjha.com>
gcc/ChangeLog:
* config.gcc: Adjust for Darwin21.
* config/darwin-c.c (macosx_version_as_macro): Likewise.
* config/darwin-driver.c (validate_macosx_version_min):
Likewise.
(darwin_find_version_from_kernel): Likewise.
Aldy Hernandez [Wed, 27 Oct 2021 16:22:16 +0000 (18:22 +0200)]
Kill known equivalences before a new assignment in the path solver.
Every time we have a killing statement, we must also kill the relations
seen so far. This is similar to what we did for the equivs inherent in
PHIs along a path.
Tested on x86-64 and ppc64le Linux.
gcc/ChangeLog:
* gimple-range-path.cc
(path_range_query::range_defined_in_block): Call killing_def.
Aldy Hernandez [Wed, 27 Oct 2021 16:22:29 +0000 (18:22 +0200)]
Reorder relation calculating code in the path solver.
Enabling the fully resolving threader triggers various relation
ordering issues that have previously been dormant because the VRP
hybrid threader (forward threader based) never gives us long enough
paths for this to matter. The new threader spares no punches in
finding non-obvious paths, so getting the relations right is
paramount.
This patch fixes a couple oversights that have gone undetected.
First, some background. There are 3 types of relations along a path:
a) Relations inherent in a PHI.
b) Relations as a side-effect of evaluating a statement.
c) Outgoing relations between blocks in a path.
We must calculate these in their proper order, otherwise we can run
into ordering issues. The current ordering is wrong, as we
precalculate PHIs for _all_ blocks before anything else, and then
proceed to register the relations throughout the path. Also, we fail
to realize that a PHI whose argument is also defined in the PHIs block
cannot be registered as an equivalence without causing more ordering
issues.
This patch fixes all the problems described above. With it we get a
handful more net threads, but most importantly, we disallow some
threads that were wrong.
Tested on x86-64 and ppc64le Linux on the usual regstrap, plus by
comparing the different thread counts before and after this patch.
gcc/ChangeLog:
* gimple-range-fold.cc (fold_using_range::range_of_range_op): Dump
operands as well as relation.
* gimple-range-path.cc
(path_range_query::compute_ranges_in_block): Compute PHI relations
first. Compute outgoing relations at the end.
(path_range_query::compute_ranges): Remove call to compute_relations.
(path_range_query::compute_relations): Remove.
(path_range_query::maybe_register_phi_relation): New.
(path_range_query::compute_phi_relations): Abstract out
registering one PHI relation to...
(path_range_query::compute_outgoing_relations): ...here.
* gimple-range-path.h (class path_range_query): Remove
compute_relations.
Add maybe_register_phi_relation.
Aldy Hernandez [Wed, 27 Oct 2021 14:24:53 +0000 (16:24 +0200)]
Kill second order relations in the path solver.
My upcoming work replacing the VRP threaders with a fully resolving
backward threader has tripped over various corner cases in the path
sensitive relation oracle. This patch kills second order relations when
we kill a relation.
Tested on x86-64 and ppc64le Linux.
Co-authored-by: Andrew MacLeod <amacleod@redhat.com>
gcc/ChangeLog:
* value-relation.cc (path_oracle::killing_def): Kill second
order relations.
John David Anglin [Wed, 27 Oct 2021 18:00:36 +0000 (18:00 +0000)]
Fix warnings building linux-atomic.c and fptr.c on hppa64-linux
The file fptr.c is specific to 32-bit hppa-linux and should not be
included in LIB2ADD on hppa64-linux.
There is a builtin type mismatch in linux-atomic.c using the type
long long unsigned int for 64-bit atomic operations on hppa64-linux.
2021-10-27 John David Anglin <danglin@gcc.gnu.org>
libgcc/ChangeLog:
* config.host (hppa*64*-*-linux*): Don't add pa/t-linux to
tmake_file.
* config/pa/linux-atomic.c: Define u8, u16 and u64 types.
Use them in FETCH_AND_OP_2, OP_AND_FETCH_2, COMPARE_AND_SWAP_2,
SYNC_LOCK_TEST_AND_SET_2 and SYNC_LOCK_RELEASE_1 macros.
* config/pa/t-linux64 (LIB1ASMSRC): New define.
(LIB1ASMFUNCS): Revise.
(HOST_LIBGCC2_CFLAGS): Add "-DLINUX=1".
Martin Sebor [Wed, 27 Oct 2021 15:39:03 +0000 (09:39 -0600)]
Fix a typo.
gcc/testsuite/ChangeLog:
* gcc.dg/Warray-bounds-90.c: Fix a typo.
Martin Jambor [Wed, 27 Oct 2021 12:49:02 +0000 (14:49 +0200)]
ipa-cp: Use profile counters (or not) based on local availability
This is a follow-up small patch to address Honza's review of my
previous patch to select saner profile count to base heuristics on.
Currently the IPA-CP heuristics switch to PGO-mode only if there are
PGO counters available for any part of the call graph. This change
makes it to switch to the PGO mode only if any of the incoming edges
bringing in the constant in question had any ipa-quality counts on
them. Consequently, if a part of the program is built with
-fprofile-use and another part without, IPA-CP will use
estimated-frequency-based heuristics for the latter.
I still wonder whether this should only happen with
flag_profile_partial_training on. It seems like we're behaving as if
it was always on.
gcc/ChangeLog:
2021-10-18 Martin Jambor <mjambor@suse.cz>
* ipa-cp.c (good_cloning_opportunity_p): Decide whether to use
profile feedback depending on their local availability.
Martin Jambor [Wed, 27 Oct 2021 12:49:01 +0000 (14:49 +0200)]
ipa-cp: Select saner profile count to base heuristics on
When profile feedback is available, IPA-CP takes the count of the
hottest node and then evaluates all call contexts relative to it.
This means that typically almost no clones for specialized contexts
are ever created because the maximum is some special function, called
from everywhere (that is likely to get inlined anyway) and all the
examined edges look cold compared to it.
This patch changes the selection. It simply sorts counts of all edges
eligible for cloning in a vector and then picks the count in 90th
percentile (the actual number is configurable via a parameter).
I also tried more complex approaches which were summing the counts and
picking the edge which together with all hotter edges accounted for a
given portion of the total sum of all edge counts. But first it was
not apparently clear to me that they make more logical sense that the
simple method and practically I always also had to ignore a few
percent of the hottest edges with really extreme counts (looking at
bash and python). And when I had to do that anyway, it seemed simpler
to just "ignore" more and take the first non-ignored count as the
base.
Nevertheless, if people think some more sophisticated method should be
used anyway, I am willing to be persuaded. But this patch is a clear
improvement over the current situation.
gcc/ChangeLog:
2021-10-26 Martin Jambor <mjambor@suse.cz>
* params.opt (param_ipa_cp_profile_count_base): New parameter.
* doc/invoke.texi (Optimize Options): Add entry for
ipa-cp-profile-count-base.
* ipa-cp.c (max_count): Replace with base_count, replace all
occurrences too, unless otherwise stated.
(ipcp_cloning_candidate_p): identify mostly-directly called
functions based on their counts, not max_count.
(compare_edge_profile_counts): New function.
(ipcp_propagate_stage): Instead of setting max_count, find the
appropriate edge count in a sorted vector of counts of eligible
edges and make it the base_count.
Martin Jambor [Wed, 27 Oct 2021 12:49:01 +0000 (14:49 +0200)]
ipa-cp: Fix updating of profile counts and self-gen value evaluation
IPA-CP does not do a reasonable job when it is updating profile counts
after it has created clones of recursive functions. This patch
addresses that by:
1. Only updating counts for special-context clones. When a clone is
created for all contexts, the original is going to be dead and the
cgraph machinery has copied counts to the new node which is the right
thing to do. Therefore updating counts has been moved from
create_specialized_node to decide_about_value and
decide_whether_version_node.
2. The current profile updating code artificially increased the assumed
old count when the sum of counts of incoming edges to both the
original and new node were bigger than the count of the original
node. This always happened when self-recursive edge from the clone
was also redirected to the clone because both the original edge and
its clone had original high counts. This clutch was removed and
replaced by the next point.
3. When cloning also redirects a self-recursive clone to the clone
itself, new logic has been added to divide the counts brought by such
recursive edges between the original node and the clone. This is
impossible to do well without special knowledge about the function and
which non-recursive entry calls are responsible for what portion of
recursion depth, so the approach taken is rather crude.
For local nodes, we detect the case when the original node is never
called (in the training run at least) with another value and if so,
steal all its counts like if it was dead. If that is not the case, we
try to divide the count brought by recursive edges (or rather not
brought by direct edges) proportionally to the counts brought by
non-recursive edges - but with artificial limits in place so that we
do not take too many or too few, because that was happening with
detrimental effect in mcf_r.
4. When cloning creates extra clones for values brought by a formerly
self-recursive edge with an arithmetic pass-through jump function on
it, such as it does in exchange2_r, all such clones are processed at
once rather than one after another. The counts of all such nodes are
distributed evenly (modulo even-formerly-non-recursive-edges) and the
whole situation is then fixed up so that the edge counts fit. This is
what new function update_counts_for_self_gen_clones does.
5. When values brought by a formerly self-recursive edge with an
arithmetic pass-through jump function on it are evaluated by
heuristics which assumes vast majority of node counts are result of
recursive calls and so we simply divide those with the number of
clones there would be if we created another one.
6. The mechanisms in init_caller_stats and gather_caller_stats and
get_info_about_necessary_edges was enhanced to gather data required
for the above and a missing check not to count dead incoming edges was
also added.
gcc/ChangeLog:
2021-10-15 Martin Jambor <mjambor@suse.cz>
* ipa-cp.c (struct caller_statistics): New fields rec_count_sum,
n_nonrec_calls and itself, document all fields.
(init_caller_stats): Initialize the above new fields.
(gather_caller_stats): Gather self-recursive counts and calls number.
(get_info_about_necessary_edges): Gather counts of self-recursive and
other edges bringing in the requested value separately.
(dump_profile_updates): Rework to dump info about a single node only.
(lenient_count_portion_handling): New function.
(struct gather_other_count_struct): New type.
(gather_count_of_non_rec_edges): New function.
(struct desc_incoming_count_struct): New type.
(analyze_clone_icoming_counts): New function.
(adjust_clone_incoming_counts): Likewise.
(update_counts_for_self_gen_clones): Likewise.
(update_profiling_info): Rewritten.
(update_specialized_profile): Adjust call to dump_profile_updates.
(create_specialized_node): Do not update profiling info.
(decide_about_value): New parameter self_gen_clones, either push new
clones into it or updat their profile counts. For self-recursively
generated values, use a portion of the node count instead of count
from self-recursive edges to estimate goodness.
(decide_whether_version_node): Gather clones for self-generated values
in a new vector, update their profiles at once at the end.
Richard Biener [Wed, 27 Oct 2021 08:35:24 +0000 (10:35 +0200)]
Refactor try_vectorize_loop_1
This refactors epilogue loop handling in try_vectorize_loop_1 to not
suggest we're analyzing those there by splitting out the transform
phase which then can handle the epilogues.
2021-10-27 Richard Biener <rguenther@suse.de>
* tree-vectorizer.c (vect_transform_loops): New function,
split out from ...
(try_vectorize_loop_1): ... here. Simplify as epilogues
are now fully handled in the split part.
Tobias Burnus [Wed, 27 Oct 2021 08:59:27 +0000 (10:59 +0200)]
Fortran: Fix 'select rank' for allocatables/pointers
gcc/fortran/ChangeLog:
* trans-stmt.c (gfc_trans_select_rank_cases): Fix condition
for allocatables/pointers.
gcc/testsuite/ChangeLog:
* gfortran.dg/PR93963.f90: Extend testcase by scan-tree-dump test.
Jakub Jelinek [Wed, 27 Oct 2021 07:41:38 +0000 (09:41 +0200)]
testsuite: Fix up gcc.dg/pr102897.c testcase [PR102897]
The testcase FAILs on i686-linux due to:
FAIL: gcc.dg/pr102897.c (test for excess errors)
Excess errors:
.../gcc/gcc/testsuite/gcc.dg/pr102897.c:11:1: warning: MMX vector return without MMX enabled changes the ABI [-Wpsabi]
.../gcc/gcc/testsuite/gcc.dg/pr102897.c:10:10: warning: MMX vector argument without MMX enabled changes the ABI [-Wpsabi]
Fixed by adding -Wno-psabi.
2021-10-27 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/102897
* gcc.dg/pr102897.c: Add -Wno-psabi to dg-options.
Jakub Jelinek [Wed, 27 Oct 2021 07:24:46 +0000 (09:24 +0200)]
openmp: Document that non-rect loops are not supported in Fortran yet
I've found we claim to support non-rectangular loops, but don't actually
support those in Fortran, as can be seen on:
integer i, j
!$omp parallel do collapse(2)
do i = 0, 10
do j = 0, i
end do
end do
end
To support this, the Fortran FE needs to allow the valid forms of
non-rectangular loops and disallow others, so mainly it needs its
updated version of c-omp.c c_omp_check_loop_iv etc., plus for non-rectangular
lb or ub expressions emit a TREE_VEC instead of normal expression as the C/C++ FE
do, plus testsuite coverage.
2021-10-27 Jakub Jelinek <jakub@redhat.com>
* libgomp.texi (OpenMP 5.0): Mention that Non-rectangular loop nests
aren't implemented for Fortran yet.
Jakub Jelinek [Wed, 27 Oct 2021 07:22:07 +0000 (09:22 +0200)]
openmp: Allow non-rectangular loops with pointer iterators
This patch handles pointer iterators for non-rectangular loops. They are
more limited than integral iterators of non-rectangular loops, in particular
only var-outer, var-outer + a2, a2 + var-outer or var-outer - a2 can appear
in lb or ub where a2 is some integral loop invariant expression, so no e.g.
multiplication etc.
2021-10-27 Jakub Jelinek <jakub@redhat.com>
gcc/
* omp-expand.c (expand_omp_for_init_counts): Handle non-rectangular
iterators with pointer types.
(expand_omp_for_init_vars, extract_omp_for_update_vars): Likewise.
gcc/c-family/
* c-omp.c (c_omp_check_loop_iv_r): Don't clear 3rd bit for
POINTER_PLUS_EXPR.
(c_omp_check_nonrect_loop_iv): Handle POINTER_PLUS_EXPR.
(c_omp_check_loop_iv): Set kind even if the iterator is non-integral.
gcc/testsuite/
* c-c++-common/gomp/loop-8.c: New test.
* c-c++-common/gomp/loop-9.c: New test.
libgomp/
* testsuite/libgomp.c/loop-26.c: New test.
* testsuite/libgomp.c/loop-27.c: New test.
Jakub Jelinek [Wed, 27 Oct 2021 07:16:48 +0000 (09:16 +0200)]
openmp: Don't reject some valid initializers or conditions of non-rectangular loops [PR102854]
In C++, if an iterator has or might have (e.g. dependent type) class type we
remember the original init expressions and check those separately for presence
of iterators, because for class iterators we turn those into expressions that
always do contain reference to the current iterator. But this resulted in
rejecting valid non-rectangular loop where the dependent type is later instantiated
to an integral type.
Non-rectangular loops with class random access iterators remain broken, that is something
to be fixed incrementally.
2021-10-27 Jakub Jelinek <jakub@redhat.com>
PR c++/102854
gcc/c-family/
* c-common.h (c_omp_check_loop_iv_exprs): Add enum tree_code argument.
* c-omp.c (c_omp_check_loop_iv_r): For trees other than decls,
TREE_VEC, PLUS_EXPR, MINUS_EXPR, MULT_EXPR, POINTER_PLUS_EXPR or
conversions temporarily clear the 3rd bit from d->kind while walking
subtrees.
(c_omp_check_loop_iv_exprs): Add CODE argument. Or in 4 into data.kind
if possibly non-rectangular.
gcc/cp/
* semantics.c (handle_omp_for_class_iterator,
finish_omp_for): Adjust c_omp_check_loop_iv_exprs caller.
gcc/testsuite/
* g++.dg/gomp/loop-3.C: Don't expect some errors.
* g++.dg/gomp/loop-7.C: New test.
Jakub Jelinek [Wed, 27 Oct 2021 07:08:19 +0000 (09:08 +0200)]
c++: Reject addresses of immediate functions in constexpr vars inside of immediate functions or consteval if [PR102753]
Another thing that wasn't in the previous patch, but I'm wondering whether we don't
handle it incorrectly. constexpr.c has:
/* Check that immediate invocation does not return an expression referencing
any immediate function decls. They need to be allowed while parsing
immediate functions, but can't leak outside of them. */
if (is_consteval
&& t != r
&& (current_function_decl == NULL_TREE
|| !DECL_IMMEDIATE_FUNCTION_P (current_function_decl)))
as condition for the discovery of embedded immediate FUNCTION_DECLs
(or now PTRMEM_CSTs). If I remove the && (current... ..._decl))
then g++.dg/cpp2a/consteval7.C's
struct S { int b; int (*c) (); };
consteval S baz () { return { 5, foo }; }
consteval int qux () { S s = baz (); return s.b + s.c (); }
consteval int quux () { constexpr S s = baz (); return s.b + s.c (); }
quux line fails, but based on
http://eel.is/c++draft/expr.const#11
I wonder if it shouldn't fail (clang++ -std=c++20 rejects it),
and be only accepted without the constexpr keyword before S s.
Also wonder about e.g.
consteval int foo () { return 42; }
consteval int
bar ()
{
auto fn1 = foo; // This must be ok
constexpr auto fn2 = foo; // Isn't this an error?
return fn1 () + fn2 ();
}
constexpr int
baz ()
{
if consteval {
auto fn1 = foo; // This must be ok
constexpr auto fn2 = foo; // Isn't this an error?
return fn1 () + fn2 ();
}
return 0;
}
auto a = bar ();
static_assert (bar () == 84);
static_assert (baz () == 84);
(again, clang++ -std=c++20 rejects the fn2 = foo; case,
but doesn't implement consteval if, so can't test the other one).
For taking address of an immediate function or method if it is taken
outside of immediate function context we already have diagnostics
about it, but shouldn't the immediate FUNCTION_DECL discovery in
cxx_eval_outermost_constant_expression be instead guarded with something
like
if (is_consteval || in_immediate_context ())
and be done regardless of whether t != r?
2021-10-27 Jakub Jelinek <jakub@redhat.com>
PR c++/102753
* constexpr.c (cxx_eval_outermost_constant_expr): Perform
find_immediate_fndecl discovery if is_consteval or
in_immediate_context () rather than if is_consteval, t != r
and not in immediate function's body.
* g++.dg/cpp2a/consteval7.C: Expect diagnostics on quux.
* g++.dg/cpp2a/consteval24.C: New test.
* g++.dg/cpp23/consteval-if12.C: New test.
Jakub Jelinek [Wed, 27 Oct 2021 07:03:28 +0000 (09:03 +0200)]
c++: Diagnose taking address of an immediate member function [PR102753]
The consteval20.C testcase ICEs, because while we have in cp_build_addr_expr_1
diagnostics for taking address of an immediate function (and as an exception
deal with build_address from immediate invocation), I forgot to diagnose
taking address of a member function which is done in a different place.
I hope (s.*&S::foo) () is not an immediate invocation like
(*&foo) () is not, so this patch just diagnoses taking address of a member
function when not in immediate context.
On Mon, Oct 18, 2021 at 12:42:00PM -0400, Jason Merrill wrote:
> > --- gcc/cp/typeck.c.jj 2021-10-05 09:53:55.
382734051 +0200
> > +++ gcc/cp/typeck.c 2021-10-15 19:28:38.
034213437 +0200
> > @@ -6773,9 +6773,21 @@ cp_build_addr_expr_1 (tree arg, bool str
> > return error_mark_node;
> > }
> > + if (TREE_CODE (t) == FUNCTION_DECL
> > + && DECL_IMMEDIATE_FUNCTION_P (t)
> > + && cp_unevaluated_operand == 0
> > + && (current_function_decl == NULL_TREE
> > + || !DECL_IMMEDIATE_FUNCTION_P (current_function_decl)))
>
> This doesn't cover some of the other cases of immediate context; we should
> probably factor most of immediate_invocation_p out into a function called
> something like in_immediate_context and use it here, and in several other
> places as well.
You're right, I've done that for the two spots in cp_build_addr_expr_1
and added testsuite coverage for where it changed behavior.
While doing that I've discovered further issues.
One is that we weren't diagnosing PMFs referring to immediate methods
returned from immediate functions (either directly or embedded in
aggregates). I'm not sure if it can only appear as PTRMEM_CST which
I've handled (cp_walk_subtree only walks the type and not the
PTRMEM_CST_MEMBER) or something else.
Another issue is that while default arg in immediate function
containing &immediate_fn works properly, if it is immediate_fn
instead, we were incorrectly rejecting it.
I've handled this in build_over_call, though with this usage
in_consteval_if_p is slightly misnamed, it stands for in consteval
if or some other reason why we are currently in immediate function context.
Though, that flag alone can't be all the reasons for being in immediate
function contexts, as I've tried the other reasons can't be handled in such
a bool and need to be tested too.
2021-10-27 Jakub Jelinek <jakub@redhat.com>
PR c++/102753
* cp-tree.h (saved_scope): Document that consteval_if_p member
is also set while processing immediate invocation.
(in_immediate_context): Declare.
* call.c (in_immediate_context): New function.
(immediate_invocation_p): Use it.
(struct in_consteval_if_p_temp_override): New class.
(build_over_call): Temporarily set in_consteval_if_p for processing
immediate invocation arguments.
* typeck.c (cp_build_addr_expr_1): Diagnose taking address of
an immediate method. Use t instead of TREE_OPERAND (arg, 1).
Use in_immediate_context function.
* constexpr.c (find_immediate_fndecl): Handle PTRMEM_CST
which refers to immediate function decl.
* g++.dg/cpp2a/consteval13.C: Don't expect errors.
* g++.dg/cpp2a/consteval20.C: New test.
* g++.dg/cpp2a/consteval21.C: New test.
* g++.dg/cpp2a/consteval22.C: New test.
* g++.dg/cpp2a/consteval23.C: New test.
* g++.dg/cpp23/consteval-if11.C: New test.
GCC Administrator [Wed, 27 Oct 2021 00:16:33 +0000 (00:16 +0000)]
Daily bump.
Ian Lance Taylor [Tue, 26 Oct 2021 17:50:40 +0000 (10:50 -0700)]
compiler: permit compiler directives in parenthesized groups
The original compiler directive support was only for //line at the
start of a line and for //go: comments before function declarations.
When support was added for //go:notinheap for types and //go:embed for
variables the code did not adapt to permit spaces before the comment
or to permit the comments in var() or type() groups. This change
corrects those omissions.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/358699
Martin Sebor [Tue, 26 Oct 2021 20:40:33 +0000 (14:40 -0600)]
Improve/correct detection of overlapping aggregates [PR102238, PR102919].
Resolves:
PR tree-optimization/102238 - alias_offset in gimple-ssa-sprintf.c is broken
PR tree-optimization/102919 - spurious -Wrestrict warning for sprintf into the same member array as argument plus offset
gcc/ChangeLog:
PR tree-optimization/102238
PR tree-optimization/102919
* gimple-ssa-sprintf.c (get_string_length): Add an argument.
(array_elt_at_offset): Move to pointer-query.
(set_aggregate_size_and_offset): New function.
(field_at_offset): Move to pointer-query.
(get_origin_and_offset): Rename...
(get_origin_and_offset_r): this. Add an argument. Make aggregate
handling more robust.
(get_origin_and_offset): New.
(alias_offset): Add an argument.
(format_string): Use subobject size determined by get_origin_and_offset.
* pointer-query.cc (field_at_offset): Move from gimple-ssa-sprintf.c.
Improve/correct handling of aggregates.
(array_elt_at_offset): Same.
* pointer-query.h (field_at_offset): Declare.
(array_elt_at_offset): Declare.
gcc/testsuite/ChangeLog:
PR tree-optimization/102238
PR tree-optimization/102919
* gcc.dg/tree-ssa/builtin-sprintf-warn-23.c: Remove warnings.
* gcc.dg/Wrestrict-23.c: New test.
Martin Sebor [Tue, 26 Oct 2021 20:38:11 +0000 (14:38 -0600)]
Make full use of context-sensitive ranges in access warnings.
gcc/ChangeLog:
* builtins.c (check_strncat_sizes): Pass access_data ctor additional
arguments.
(expand_builtin_memcmp): Move code to gimple-ssa-warn-access.cc.
(expand_builtin_fork_or_exec): Same.
* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref): Pass
compute_objsize additional arguments.
(inbounds_memaccess_p): Same.
(array_bounds_checker::check_array_bounds): Add an assert. Stash
statement in a member.
(check_array_bounds_dom_walker::before_dom_children): Same.
* gimple-array-bounds.h (array_bounds_checker::m_stmt): New member.
* gimple-ssa-sprintf.c (get_destination_size): Add an argument.
(handle_printf_call): Pass a new argument.
* gimple-ssa-warn-access.cc (get_size_range): Add an argument.
(check_access): Add an argument and pass it along to callees.
(check_read_access): Make a member function.
(pass_waccess::check_strcat): Pass access_data ctor additional
arguments.
(pass_waccess::check_strncat): Same.
(pass_waccess::check_stxcpy): Same.
(pass_waccess::check_stxncpy): Same.
(pass_waccess::check_strncmp): Same.
(pass_waccess::check_read_access): Same.
(pass_waccess::check_builtin): Same.
(pass_waccess::maybe_check_access_sizes): Same.
(pass_waccess::maybe_check_dealloc_call): Same.
* gimple-ssa-warn-access.h (check_read_access): Declare a new
member function.
* pointer-query.cc (compute_objsize_r): Add an argument.
(gimple_call_return_array): Same.
(gimple_call_alloc_size): Same.
(access_ref::access_ref): Same.
(access_ref::get_ref): Same.
(pointer_query::get_ref): Same.
(handle_min_max_size): Pass an arguments to callees.
(handle_array_ref): Add an argument.
(handle_mem_ref): Same.
(compute_objsize): Same.
* pointer-query.h (struct access_ref): Adjust signatures.
(struct access_data): Same.
(gimple_call_alloc_size): Add an argument.
(gimple_parm_array_size): Same.
(compute_objsize): Same.
* tree-ssa-strlen.c (strlen_pass::adjust_last_stmt): Pass an additional
argument to compute_objsize.
(strlen_pass::maybe_warn_overflow): Same.
(maybe_diag_stxncpy_trunc): Same.
gcc/testsuite/ChangeLog:
* gcc.dg/Wstringop-overflow-22.c: Correct typos.
* gcc.dg/Wstringop-overflow-81.c: New test.
libstdc++-v3/ChangeLog:
* testsuite/21_strings/basic_string/capacity/1.cc: Also suppress
-Wstringop-overread.
* testsuite/27_io/filesystem/path/factory/u8path-char8_t.cc: Same.
Martin Sebor [Tue, 26 Oct 2021 20:34:16 +0000 (14:34 -0600)]
Detect overflow by atomic functions [PR102453].
Resolves:
PR middle-end/102453 - buffer overflow by atomic built-ins not diagnosed
gcc/ChangeLog:
PR middle-end/102453
* gimple-ssa-warn-access.cc (pass_waccess::check_atomic_builtin): New.
(pass_waccess::check_atomic_builtin): Call it.
gcc/testsuite/ChangeLog:
PR middle-end/102453
* gcc.dg/Warray-bounds-90.c: New test.
* gcc.dg/Wstringop-overflow-77.c: New test.
* gcc.dg/Wstringop-overflow-78.c: New test.
* gcc.dg/Wstringop-overflow-79.c: New test.
* gcc.dg/Wstringop-overflow-80.c: New test.
* c-c++-common/gomp/atomic-4.c: Avoid an out-of-bounds access.
Jeff Law [Tue, 26 Oct 2021 20:27:02 +0000 (16:27 -0400)]
Fixup MAINTAINERS file
/
* MAINTAINERS: Fix up Maciej's entries.
Harald Anlauf [Tue, 26 Oct 2021 20:22:36 +0000 (22:22 +0200)]
Fortran: error recovery on invalid code with SELECT TYPE
gcc/testsuite/ChangeLog:
PR fortran/86551
* gfortran.dg/pr86551.f90: New test to verify that PR86551 remains
fixed.
Harald Anlauf [Tue, 26 Oct 2021 20:14:19 +0000 (22:14 +0200)]
Fortran: [PDT] KIND and LEN type parameters are mutually exclusive
gcc/fortran/ChangeLog:
PR fortran/102956
* symbol.c (gfc_check_conflict): Add conflict check for PDT KIND
and LEN type parameters.
gcc/testsuite/ChangeLog:
PR fortran/102956
* gfortran.dg/pdt_32.f03: New test.
Vladimir N. Makarov [Tue, 26 Oct 2021 18:03:42 +0000 (14:03 -0400)]
[PR102842] Consider all outputs in generation of matching reloads
Without considering all output insn operands (not only processed
before), in rare cases LRA can use the same hard register for
different outputs of the insn on different assignment subpasses. The
patch fixes the problem.
gcc/ChangeLog:
PR rtl-optimization/102842
* lra-constraints.c (match_reload): Ignore out in checking values
of outs.
(curr_insn_transform): Collect outputs before doing reloads of operands.
gcc/testsuite/ChangeLog:
PR rtl-optimization/102842
* g++.target/arm/pr102842.C: New test.
Harald Anlauf [Tue, 26 Oct 2021 18:54:41 +0000 (20:54 +0200)]
Fortran: do not restrict PDT KIND and LEN type parameters to default integer
gcc/fortran/ChangeLog:
PR fortran/102917
* decl.c (match_attr_spec): Remove invalid integer kind checks on
KIND and LEN attributes of PDTs.
gcc/testsuite/ChangeLog:
PR fortran/102917
* gfortran.dg/pdt_4.f03: Adjust testcase.
Harald Anlauf [Tue, 26 Oct 2021 18:51:46 +0000 (20:51 +0200)]
Fortran: error recovery on initializing invalid derived type array component
gcc/fortran/ChangeLog:
PR fortran/102816
* resolve.c (resolve_structure_cons): Reject invalid array spec of
a DT component referenced in a structure constructor.
gcc/testsuite/ChangeLog:
PR fortran/102816
* gfortran.dg/pr102816.f90: New test.
Jonathan Wakely [Thu, 21 Oct 2021 21:32:23 +0000 (22:32 +0100)]
c++tools: Fix memory leak
The allocated memory is not freed when returning early due to an error.
c++tools/ChangeLog:
* resolver.cc (module_resolver::read_tuple_file): Use unique_ptr
to ensure memory is freed before returning.
Paul A. Clarke [Mon, 25 Oct 2021 20:18:33 +0000 (15:18 -0500)]
rs6000: Fixes for tests including only <x86intrin.h>
Tests which only include <x86intrin.h> expect many other include files
to be brought in, but not enough are.
Try to increase compatibility with x86 headers by:
- Create new immintrin.h, including the analogous subset of intrinsics
headers available for powerpc.
- Create new x86gprintrin.h, serving exclusively as the umbrella for
bmiintrin.h and bmi2intrin.h.
- Modify x86intrin.h:
- Include new immintrin.h.
- Remove mmintrin.h, xmmintrin.h, emmintrin.h, now included indirectly
from immintrin.h.
- Remove bmiintrin.h, bmi2intrin.h, now included indirectly from
x86gprintrin.h (which is now included from immintrin.h).
Add the new files to gcc/config.gcc.
Also, fix up the testcase that provoked PR102719, which requires
Power8 vector support.
Fixes commit
29fb1e831bf1c25e4574bf2f98a9f534e5c67665.
2021-10-25 Paul A. Clarke <pc@us.ibm.com>
gcc
PR target/102719
* config/rs6000/x86intrin.h: Move some included headers to new
headers. Include new immintrin.h instead of those headers.
* config/rs6000/immintrin.h: New.
* config/rs6000/x86gprintrin.h: New.
* config.gcc (powerpc*-*-*): Add new headers to extra_headers.
gcc/testsuite
* gcc.target/powerpc/pr78102.c: Fix dg directives to require Power8
vector support. Also, add -DNO_WARN_X86_INTRINSICS.
Marek Polacek [Thu, 21 Oct 2021 15:10:02 +0000 (11:10 -0400)]
c++: P2360R0: Extend init-stmt to allow alias-decl [PR102617]
The following patch implements C++23 P2360R0. This proposal merely
extends init-statement to contain alias-declaration. init-statement
is used in if/for/switch. It also removes the unsightly duplication
of code by calling cp_parser_init_statement twice.
PR c++/102617
gcc/cp/ChangeLog:
* parser.c (cp_parser_for): Maybe call cp_parser_init_statement
twice. Warn about range-based for loops with initializer here.
(cp_parser_init_statement): Don't duplicate code. Allow
alias-declaration in init-statement.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/init-stmt1.C: New test.
* g++.dg/cpp23/init-stmt2.C: New test.
Maciej W. Rozycki [Tue, 26 Oct 2021 15:17:25 +0000 (16:17 +0100)]
MAINTAINERS: Add myself as a VAX port maintainer
* MAINTAINERS (CPU Port Maintainers): Add myself as a VAX port
maintainer.
Sandra Loosemore [Mon, 25 Oct 2021 18:08:28 +0000 (11:08 -0700)]
Fix broken use of alloca in C interoperability testcase
2021-10-25 Sandra Loosemore <sandra@codesourcery.com>
gcc/testsuite/
PR testsuite/102910
* gfortran.dg/c-interop/cf-descriptor-5-c.c: Use a static buffer
instead of alloca.
Rainer Orth [Tue, 26 Oct 2021 12:30:07 +0000 (14:30 +0200)]
testsuite: i386: Fix gcc.target/i386/avx512f-pr96891-3.c on Solaris [PR102834]
gcc.target/i386/avx512f-pr96891-3.c currently FAILs on 32-bit Solaris/x86:
FAIL: gcc.target/i386/avx512f-pr96891-3.c scan-assembler-times
(?n)vpcmp[bwdq][ \\\\t]*\\\\\$7 4
There are only 3 instances of the expected pattern because Solaris/x86
defaults to -mno-stv. Fixed by compiling with -mstv and
-mno-stackrealign. Tested on i386-pc-solaris2.11 and
x86_64-pc-linux-gnu.
2021-10-20 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
gcc/testsuite:
PR testsuite/102834
* gcc.target/i386/avx512f-pr96891-3.c: Add -mstv -mno-stackrealign
to dg-options.