Kewen Lin [Tue, 30 Nov 2021 03:22:27 +0000 (21:22 -0600)]
rs6000: Modify the way for extra penalized cost
This patch follows the discussions here[1][2], where Segher
pointed out the existing way to guard the extra penalized
cost for strided/elementwise loads with a magic bound does
not scale.
The way with nunits * stmt_cost can get one much
exaggerated penalized cost, such as: for V16QI on P8, it's
16 * 20 = 320, that's why we need one bound. To make it
better and more readable, the penalized cost is simplified
as:
unsigned adjusted_cost = (nunits == 2) ? 2 : 1;
unsigned extra_cost = nunits * adjusted_cost;
For V2DI/V2DF, it uses 2 penalized cost for each scalar load
while for the other modes, it uses 1. It's mainly concluded
from the performance evaluations. One thing might be
related is that: More units vector gets constructed, more
instructions are used. It has more chances to schedule them
better (even run in parallelly when enough available units
at that time), so it seems reasonable not to penalize more
for them.
The SPEC2017 evaluations on Power8/Power9/Power10 at option
sets O2-vect and Ofast-unroll show this change is neutral.
[1] https://gcc.gnu.org/pipermail/gcc-patches/2021-September/579121.html
[2] https://gcc.gnu.org/pipermail/gcc-patches/2021-September/580099.html
gcc/ChangeLog:
* config/rs6000/rs6000.c
(rs6000_cost_data::update_target_cost_per_stmt): Adjust the way to
compute extra penalized cost. Remove useless parameter.
(rs6000_cost_data::rs6000_add_stmt_cost): Adjust the call to function
update_target_cost_per_stmt.
Kewen Lin [Tue, 30 Nov 2021 01:26:20 +0000 (19:26 -0600)]
visium: Revert commit r12-5332
This reverts commit
b8ce19bb1a0592051e8f9a4c3252d12ae605b256
(r12-5332) "visium: Fix non-robust split condition in
define_insn_and_split".
Jeff found newlib failed to build for visium port since
r12-5332, as Eric confirmed, those split conditions in the
related define_insn_and_splits are intentional not to join
with insn condition (&&), since insn condition won't hold
after reload and the proposed concatenation will make the
splitting never happen wrongly.
Andrew MacLeod [Tue, 30 Nov 2021 00:53:50 +0000 (19:53 -0500)]
Don't reuse reference after potential resize.
When a new def chain is requested, any existing reference may no longer
be valid, so just use the object directly.
PR tree-optimization/103467
* gimple-range-gori.cc (range_def_chain::register_dependency): Don't
use an object reference after a potential resize.
GCC Administrator [Tue, 30 Nov 2021 00:16:44 +0000 (00:16 +0000)]
Daily bump.
David Malcolm [Mon, 29 Nov 2021 16:47:47 +0000 (11:47 -0500)]
analyzer: further false leak fixes due to overzealous state merging [PR103217]
Commit r12-5424-gf573d35147ca8433c102e1721d8c99fc432cb44b fixed a false
positive from -Wanalyzer-malloc-leak due to overzealous state merging,
erroneously merging two different svalues bound to a particular part
of the store when one has sm-state.
A further case was discovered by the reporter of PR analyzer/103217,
which this patch fixes. In this variant, different states have set
different fields of a struct, and on attempting to merge them, the
states have a different set of binding keys, leading to one state
having an svalue with sm-state, and its peer state having a NULL value
for that binding key. The state merger code was erroneously treating
them as mergeable to "UNKNOWN". This followup patch fixes things by
rejecting such mergers if the non-NULL svalue is not mergeable with
"UNKNOWN".
gcc/analyzer/ChangeLog:
PR analyzer/103217
* store.cc (binding_cluster::can_merge_p): For the "key is bound"
vs "key is not bound" merger case, check that the bound svalue
is mergeable before merging it to "unknown", rejecting the merger
otherwise.
gcc/testsuite/ChangeLog:
PR analyzer/103217
* gcc.dg/analyzer/pr103217-2.c: New test.
* gcc.dg/analyzer/pr103217-3.c: New test.
* gcc.dg/analyzer/pr103217-4.c: New test.
* gcc.dg/analyzer/pr103217-5.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Uros Bizjak [Mon, 29 Nov 2021 21:16:12 +0000 (22:16 +0100)]
i386: Fix and improve movhi_internal and movhf_internal some more.
An (*v,C) alternative can be added to movhi_internal to directly load
HImode constant 0 to xmm register. Also, V4SFmode moves can be used
for xmm->xmm moves instead of TImode moves when optimizing for size.
Fix invalid %vpinsrw insn template, which needs to duplicate %xmm
register for AVX targets.
Optimize GPR moves in movhf_internal in the same way as in movhi_internal.
Fix pinsrw and pextrw templates for AVX targets. Use sselog1
instead of sselog type. Also, handle TARGET_SSE_PARTIAL_REG_DEPENDENCY
and TARGET_SSE_SPLIT_REGS targets.
2021-11-29 Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog:
PR target/102811
* config/i386/i386.md (*movhi_internal): Introduce (*v,C) alternative.
Do not allocate non-GPR registers. Optimize xmm->xmm moves when
optimizing for size. Fix vpinsrw insn template.
(*movhf_internal): Fix pinsrw and pextrw insn templates for
AVX targets. Use sselog1 type instead of sselog. Optimize GPR moves.
Optimize xmm->xmm moves for TARGET_SSE_PARTIAL_REG_DEPENDENCY
and TARGET_SSE_SPLIT_REGS targets.
Martin Sebor [Mon, 29 Nov 2021 20:13:30 +0000 (13:13 -0700)]
Prune out valid -Winfinite-recursion [PR103469].
gcc/testsuite/ChangeLog:
PR testsuite/103469
* c-c++-common/attr-retain-5.c: Prune out valid warning.
* c-c++-common/attr-retain-6.c: Same.
* c-c++-common/attr-retain-9.c: Same.
Eric Gallager [Mon, 29 Nov 2021 19:50:02 +0000 (14:50 -0500)]
Fix autoconf regeneration slip-up.
A stray _AC_FINALIZE somehow snuck into g:909b30a; this should fix it.
gcc/ChangeLog:
* configure: Re-regenerate.
Eric Gallager [Mon, 29 Nov 2021 18:24:12 +0000 (13:24 -0500)]
Make etags path used by build system configurable
This commit allows users to specify a path to their "etags"
executable for use when doing "make tags".
I based this patch off of this one from upstream automake:
https://git.savannah.gnu.org/cgit/automake.git/commit/m4?id=
d2ccbd7eb38d6a4277d6f42b994eb5a29b1edf29
This means that I just supplied variables that the user can override
for the tags programs, rather than having the configure scripts
actually check for them. I handle etags and ctags separately because
the intl subdirectory has separate targets for them. This commit
only affects the subdirectories that use handwritten Makefiles; the
ones that use automake will have to wait until we update the version
of automake used to be 1.16.4 or newer before they'll be fixed.
Addresses #103021
gcc/ChangeLog:
PR other/103021
* Makefile.in: Substitute CTAGS, ETAGS, and CSCOPE
variables. Use ETAGS variable in TAGS target.
* configure: Regenerate.
* configure.ac: Allow CTAGS, ETAGS, and CSCOPE
variables to be overridden.
gcc/ada/ChangeLog:
PR other/103021
* gcc-interface/Make-lang.in: Use ETAGS variable in
TAGS target.
gcc/c/ChangeLog:
PR other/103021
* Make-lang.in: Use ETAGS variable in TAGS target.
gcc/cp/ChangeLog:
PR other/103021
* Make-lang.in: Use ETAGS variable in TAGS target.
gcc/d/ChangeLog:
PR other/103021
* Make-lang.in: Use ETAGS variable in TAGS target.
gcc/fortran/ChangeLog:
PR other/103021
* Make-lang.in: Use ETAGS variable in TAGS target.
gcc/go/ChangeLog:
PR other/103021
* Make-lang.in: Use ETAGS variable in TAGS target.
gcc/objc/ChangeLog:
PR other/103021
* Make-lang.in: Use ETAGS variable in TAGS target.
gcc/objcp/ChangeLog:
PR other/103021
* Make-lang.in: Use ETAGS variable in TAGS target.
intl/ChangeLog:
PR other/103021
* Makefile.in: Use ETAGS variable in TAGS target,
CTAGS variable in CTAGS target, and MKID variable
in ID target.
* configure: Regenerate.
* configure.ac: Allow CTAGS, ETAGS, and MKID
variables to be overridden.
libcpp/ChangeLog:
PR other/103021
* Makefile.in: Use ETAGS variable in TAGS target.
* configure: Regenerate.
* configure.ac: Allow ETAGS variable to be overridden.
libiberty/ChangeLog:
PR other/103021
* Makefile.in: Use ETAGS variable in TAGS target.
* configure: Regenerate.
* configure.ac: Allow ETAGS variable to be overridden.
Paul A. Clarke [Thu, 21 Oct 2021 16:21:01 +0000 (11:21 -0500)]
rs6000: Add Power10 optimization for most _mm_movemask*
Power10 ISA added `vextract*` instructions which are realized in the
`vec_extractm` instrinsic.
Use `vec_extractm` for `_mm_movemask_ps`, `_mm_movemask_pd`, and
`_mm_movemask_epi8` compatibility intrinsics, when `_ARCH_PWR10`.
2021-11-29 Paul A. Clarke <pc@us.ibm.com>
gcc
* config/rs6000/xmmintrin.h (_mm_movemask_ps): Use vec_extractm
when _ARCH_PWR10.
* config/rs6000/emmintrin.h (_mm_movemask_pd): Likewise.
(_mm_movemask_epi8): Likewise.
Richard Biener [Mon, 29 Nov 2021 11:24:30 +0000 (12:24 +0100)]
Fix RTL FE issue with premature return
This fixes an issue discovered by -Wunreachable-code-return
2021-11-29 Richard Biener <rguenther@suse.de>
* read-rtl-function.c (function_reader::read_rtx_operand):
Return only after resetting m_in_call_function_usage.
Patrick Palka [Mon, 29 Nov 2021 12:52:47 +0000 (07:52 -0500)]
c++: redundant explicit 'this' capture before C++20 [PR100493]
As described in detail in the PR, in C++20 implicitly capturing 'this'
via a '=' capture default is deprecated, and in C++17 adding an explicit
'this' capture alongside a '=' capture default is diagnosed as redundant
(and is strictly speaking ill-formed). This means it's impossible to
write, in a forward-compatible way, a C++17 lambda that has a '=' capture
default and that also captures 'this' (implicitly or explicitly):
[=] { this; } // #1 deprecated in C++20, OK in C++17
// GCC issues a -Wdeprecated warning in C++20 mode
[=, this] { } // #2 ill-formed in C++17, OK in C++20
// GCC issues an unconditional warning in C++17 mode
This patch resolves this dilemma by downgrading the warning for #2 into
a -pedantic one. In passing, move it into the -Wc++20-extensions class
of warnings and adjust its wording accordingly.
PR c++/100493
gcc/cp/ChangeLog:
* parser.c (cp_parser_lambda_introducer): In C++17, don't
diagnose a redundant 'this' capture alongside a by-copy
capture default unless -pedantic. Move the diagnostic into
-Wc++20-extensions and adjust wording accordingly.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/lambda-this1.C: Adjust expected diagnostics.
* g++.dg/cpp1z/lambda-this8.C: New test.
* g++.dg/cpp2a/lambda-this3.C: Compile with -pedantic in C++17
to continue to diagnose redundant 'this' captures.
Roger Sayle [Mon, 29 Nov 2021 10:45:11 +0000 (10:45 +0000)]
x86_64: Improved V1TImode rotations by non-constant amounts.
This patch builds on the recent improvements to TImode rotations (and
Jakub's fixes to shldq/shrdq patterns). Now that expanding a TImode
rotation can never fail, it is safe to allow general_operand constraints
on the QImode shift amounts in rotlv1ti3 and rotrv1ti3 patterns.
I've also made an additional tweak to ix86_expand_v1ti_to_ti to use
vec_extract via V2DImode, which avoid using memory and takes advantage
vpextrq on recent hardware.
For the following test case:
typedef unsigned __int128 uv1ti __attribute__ ((__vector_size__ (16)));
uv1ti rotr(uv1ti x, unsigned int i) { return (x >> i) | (x << (128-i)); }
GCC with -O2 -mavx2 would previously generate:
rotr: vmovdqa %xmm0, -24(%rsp)
movq -16(%rsp), %rdx
movl %edi, %ecx
xorl %esi, %esi
movq -24(%rsp), %rax
shrdq %rdx, %rax
shrq %cl, %rdx
testb $64, %dil
cmovne %rdx, %rax
cmovne %rsi, %rdx
negl %ecx
xorl %edi, %edi
andl $127, %ecx
vmovq %rax, %xmm2
movq -24(%rsp), %rax
vpinsrq $1, %rdx, %xmm2, %xmm1
movq -16(%rsp), %rdx
shldq %rax, %rdx
salq %cl, %rax
testb $64, %cl
cmovne %rax, %rdx
cmovne %rdi, %rax
vmovq %rax, %xmm3
vpinsrq $1, %rdx, %xmm3, %xmm0
vpor %xmm1, %xmm0, %xmm0
ret
with this patch, we now generate:
rotr: movl %edi, %ecx
vpextrq $1, %xmm0, %rax
vmovq %xmm0, %rdx
shrdq %rax, %rdx
vmovq %xmm0, %rsi
shrdq %rsi, %rax
andl $64, %ecx
movq %rdx, %rsi
cmovne %rax, %rsi
cmove %rax, %rdx
vmovq %rsi, %xmm0
vpinsrq $1, %rdx, %xmm0, %xmm0
ret
2021-11-29 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/i386/i386-expand.c (ix86_expand_v1ti_to_ti): Perform the
conversion via V2DImode using vec_extractv2didi on TARGET_SSE2.
* config/i386/sse.md (rotlv1ti3, rotrv1ti3): Change constraint
on QImode shift amounts from const_int_operand to general_operand.
gcc/testsuite/ChangeLog
* gcc.target/i386/sse2-v1ti-rotate.c: New test case.
Richard Biener [Wed, 24 Nov 2021 14:57:03 +0000 (15:57 +0100)]
Remove unreachable gcc_unreachable () at the end of functions
It seems to be a style to place gcc_unreachable () after a
switch that handles all cases with every case returning.
Those are unreachable (well, yes!), so they will be elided
at CFG construction time and the middle-end will place
another __builtin_unreachable "after" them to note the
path doesn't lead to a return when the function is not declared
void.
So IMHO those explicit gcc_unreachable () serve no purpose,
if they could be replaced by a comment. But since all cases
cover switches not handling a case or not returning will
likely cause some diagnostic to be emitted which is better
than running into an ICE only at runtime.
2021-11-24 Richard Biener <rguenther@suse.de>
* tree.h (reverse_storage_order_for_component_p): Remove
spurious gcc_unreachable.
* cfganal.c (dfs_find_deadend): Likewise.
* fold-const-call.c (fold_const_logb): Likewise.
(fold_const_significand): Likewise.
* gimple-ssa-store-merging.c (lhs_valid_for_store_merging_p):
Likewise.
gcc/c-family/
* c-format.c (check_format_string): Remove spurious
gcc_unreachable.
Richard Biener [Wed, 24 Nov 2021 14:57:03 +0000 (15:57 +0100)]
Remove unreachable returns
This removes unreachable return statements as diagnosed by
the -Wunreachable-code patch. Some cases are more obviously
an improvement than others - in fact some may get you the idea
to replace them with gcc_unreachable () instead, leading to
cases of the 'Remove unreachable gcc_unreachable () at the end
of functions' patch.
2021-11-25 Richard Biener <rguenther@suse.de>
* vec.c (qsort_chk): Do not return the void return value
from the noreturn qsort_chk_error.
* ccmp.c (expand_ccmp_expr_1): Remove unreachable return.
* df-scan.c (df_ref_equal_p): Likewise.
* dwarf2out.c (is_base_type): Likewise.
(add_const_value_attribute): Likewise.
* fixed-value.c (fixed_arithmetic): Likewise.
* gimple-fold.c (gimple_fold_builtin_fputs): Likewise.
* gimple-ssa-strength-reduction.c (stmt_cost): Likewise.
* graphite-isl-ast-to-gimple.c
(gcc_expression_from_isl_expr_op): Likewise.
(gcc_expression_from_isl_expression): Likewise.
* ipa-fnsummary.c (will_be_nonconstant_expr_predicate):
Likewise.
* lto-streamer-in.c (lto_input_mode_table): Likewise.
gcc/c-family/
* c-opts.c (c_common_post_options): Remove unreachable return.
* c-pragma.c (handle_pragma_target): Likewise.
(handle_pragma_optimize): Likewise.
gcc/c/
* c-typeck.c (c_tree_equal): Remove unreachable return.
* c-parser.c (get_matching_symbol): Likewise.
libgomp/
* oacc-plugin.c (GOMP_PLUGIN_acc_default_dim): Remove unreachable
return.
liuhongt [Mon, 29 Nov 2021 02:01:42 +0000 (10:01 +0800)]
Optimize _Float16 usage for non AVX512FP16.
1. No memory is needed to move HI/HFmode between GPR and SSE registers
under TARGET_SSE2 and above, pinsrw/pextrw are used for them w/o
AVX512FP16.
2. Use gen_sse2_pinsrph/gen_vec_setv4sf_0 to replace
ix86_expand_vector_set in extendhfsf2/truncsfhf2 so that redundant
initialization cound be eliminated.
gcc/ChangeLog:
PR target/102811
* config/i386/i386.c (inline_secondary_memory_needed): HImode
move between GPR and SSE registers is supported under
TARGET_SSE2 and above.
* config/i386/i386.md (extendhfsf2): Optimize expander.
(truncsfhf2): Ditto.
* config/i386/sse.md (sse2p4_1): Adjust attr for V8HFmode to
align with V8HImode.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr102811-2.c: New test.
* gcc.target/i386/avx512vl-vcvtps2ph-pr102811.c: Add new
scan-assembler-times.
liuhongt [Fri, 26 Nov 2021 15:24:20 +0000 (23:24 +0800)]
Fix regression introduced by r12-5536.
There're several failures:
1. unsupported instruction `pextrw` for "pextrw $0, %xmm31, 16(%rax)"
%vpextrw should be used in output templates.
2. ICE in get_attr_memory for movhi_internal since some alternatives
are marked as TYPE_SSELOG.
use TYPE_SSELOG1 instead.
Also this patch fixs a typo and some latent bugs which are related to
moving HImode from/to sse register w/o TARGET_AVX512FP16.
gcc/ChangeLog:
PR target/102811
PR target/103463
* config/i386/i386.c (ix86_secondary_reload): Without
TARGET_SSE4_1, General register is needed to move HImode from
sse register to memory.
* config/i386/sse.md (*vec_extrachf): Use %vpextrw instead of
pextrw in output templates.
* config/i386/i386.md (movhi_internal): Ditto, also fix typo of
MEM_P (operands[1]) and adjust mode/prefix/type attribute for
alternatives related to sse register.
Richard Biener [Mon, 29 Nov 2021 08:15:47 +0000 (09:15 +0100)]
tree-optimization/103458 - avoid creating new loops in CD-DCE
When creating forwarders in CD-DCE we have to avoid creating loops
where we formerly did not consider those because of abnormal
predecessors. At this point simply excuse us when there are any
abnormal predecessors.
2021-11-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/103458
* tree-ssa-dce.c (make_forwarders_with_degenerate_phis): Do not
create forwarders for blocks with abnormal predecessors.
* gcc.dg/torture/pr103458.c: New testcase.
Richard Biener [Fri, 26 Nov 2021 07:50:24 +0000 (08:50 +0100)]
Restore can_be_invalidated_p semantics to before refactoring
This restores the semantics of can_be_invalidated_p to the original
semantics of the function this was split out from tree-ssa-uninit.c.
The current semantics only ever look at the first predicate which
cannot be correct.
2021-11-26 Richard Biener <rguenther@suse.de>
* gimple-predicate-analysis.cc (can_be_invalidated_p):
Restore semantics to the one before the split from
tree-ssa-uninit.c.
Rasmus Villemoes [Mon, 11 Oct 2021 12:37:05 +0000 (14:37 +0200)]
libgcc: remove crt{begin,end}.o from powerpc-wrs-vxworks target
Since commit
78e49fb1bc (Introduce vxworks specific crtstuff support),
the generic crtbegin.o/crtend.o have been unnecessary to build. So
remove them from extra_parts.
This is effectively a revert of commit
9a5b8df70 (libgcc: add
crt{begin,end} for powerpc-wrs-vxworks target).
libgcc/
* config.host (powerpc-wrs-vxworks): Do not add crtbegin.o and
crtend.o to extra_parts.
Kewen Lin [Mon, 29 Nov 2021 01:59:59 +0000 (19:59 -0600)]
rs6000/test: Add emulated gather test case
As verified, the emulated gather capability of vectorizer
(r12-2733) can help to speed up SPEC2017 510.parest_r on
Power8/9/10 by 5% ~ 9% with option sets Ofast unroll and
Ofast lto.
This patch is to add a test case similar to the one in i386
to add testing coverage for 510.parest_r hotspots.
btw, different from the one in i386, this uses unsigned int
as INDEXTYPE since the unpack support for unsigned int
(r12-3134) also matters for the hotspots vectorization.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/vect-gather-1.c: New test.
Andrew Pinski [Sun, 28 Nov 2021 02:16:50 +0000 (18:16 -0800)]
Fix PR 19089: Environment variable TMP may yield gcc: abort
Even though I cannot reproduce the ICE any more, this is still
a bug. We check already to see if we can access the directory
but never check to see if the path is actually a directory.
This adds the check and now we reject the file as not usable
as a tmp directory.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
libiberty/ChangeLog:
* make-temp-file.c (try_dir): Check to see if the dir
is actually a directory.
GCC Administrator [Mon, 29 Nov 2021 00:16:16 +0000 (00:16 +0000)]
Daily bump.
Andrew Pinski [Sun, 28 Nov 2021 01:14:59 +0000 (01:14 +0000)]
Fix PR 62157: disclean in libsanitizer not working
So what is happening is DIST_SUBDIRS contains the conditional
directories which is wrong, so we need to force DIST_SUBDIRS
to be the same as SUBDIRS as recommened by the automake manual.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
Also now make distclean works inside libsanitizer directory.
libsanitizer/ChangeLog:
PR sanitizer/62157
* Makefile.am: Force DIST_SUBDIRS to be SUBDIRS.
* Makefile.in: Regenerate.
* asan/Makefile.in: Likewise.
* hwasan/Makefile.in: Likewise.
* interception/Makefile.in: Likewise.
* libbacktrace/Makefile.in: Likewise.
* lsan/Makefile.in: Likewise.
* sanitizer_common/Makefile.in: Likewise.
* tsan/Makefile.in: Likewise.
* ubsan/Makefile.in: Likewise.
Jan Hubicka [Sun, 28 Nov 2021 18:42:45 +0000 (19:42 +0100)]
Compare guessed and feedback frequencies during profile feedback stream-in
This patch adds simple code to dump and compare frequencies of basic blocks
read from the profile feedback and frequencies guessed statically.
It dumps basic blocks in the order of decreasing frequencies from feedback
along with guessed frequencies and histograms.
It makes it to possible spot basic blocks in hot regions that are considered
cold by guessed profile or vice versa.
I am trying to figure out how realistic our profile estimate is compared to
read one on exchange2 (looking again into PR98782. There IRA now places spills
into hot regions of code while with older (and worse) profile it did not.
Catch is that the function is very large and has 9 nested loops, so it is hard
to figure out how to improve the profile estimate and/or IRA.
gcc/ChangeLog:
2021-11-28 Jan Hubicka <hubicka@ucw.cz>
* profile.c: Include sreal.h
(struct bb_stats): New.
(cmp_stats): New function.
(compute_branch_probabilities): Output bb stats.
Jan Hubicka [Sun, 28 Nov 2021 18:25:33 +0000 (19:25 +0100)]
Improve -fprofile-report
Profile-report was never properly updated after switch to new profile
representation. This patch fixes the way profile mismatches are calculated:
we used to collect separately count and freq mismatches, while now we have
only counts & probabilities. So we verify
- in count: that total count of incomming edges is close to acutal count of
the BB
- out prob: that total sum of outgoing edge edge probabilities is close
to 1 (except for BB containing noreturn calls or EH).
Moreover I added dumping of absolute data which is useful to plot them: with
Martin Liska we plan to setup regular testing so we keep optimizers profie
updates bit under control.
Finally I added both static and dynamic stats about mismatches - static one is
simply number of inconsistencies in the cfg while dynamic is scaled by the
profile - I think in order to keep eye on optimizers the first number is quite
relevant. WHile when tracking why code quality regressed the second number
matters more.
2021-11-28 Jan Hubicka <hubicka@ucw.cz>
* cfghooks.c: Include sreal.h, profile.h.
(profile_record_check_consistency): Fix checking of count counsistency;
record also dynamic mismatches.
* cfgrtl.c (rtl_account_profile_record): Similarly.
* tree-cfg.c (gimple_account_profile_record): Likewise.
* cfghooks.h (struct profile_record): Remove num_mismatched_freq_in,
num_mismatched_freq_out, turn time to double, add
dyn_mismatched_prob_out, dyn_mismatched_count_in,
num_mismatched_prob_out; remove num_mismatched_count_out.
* passes.c (account_profile_1): New function.
(account_profile_in_list): New function.
(pass_manager::dump_profile_report): Rewrite.
(execute_one_ipa_transform_pass): Check profile consistency after
running all passes.
(execute_all_ipa_transforms): Remove cfun test; record all transform
methods.
(execute_one_pass): Fix collecting of profile stats.
Jakub Jelinek [Sun, 28 Nov 2021 15:32:24 +0000 (16:32 +0100)]
libstdc++: Implement std::byteswap for C++23
This patch attempts to implement P1272R4 (except for the std::bit_cast
changes in there which seem quite unrelated to this and will need to be
fixed on the compiler side).
While at least for GCC __builtin_bswap{16,32,64,128} should work fine
in constant expressions, I wonder about other compilers, so I'm using
a fallback implementation for constexpr evaluation always.
If you think that is unnecessary, I can drop the
__cpp_if_consteval >= 202106L &&
if !consteval
{
and
}
and reformat.
The fallback implementation is an attempt to make it work even for integral
types that don't have number of bytes divisible by 2 or when __CHAR_BIT__
is e.g. 16.
2021-11-28 Jakub Jelinek <jakub@redhat.com>
* include/std/bit (__cpp_lib_byteswap, byteswap): Define.
* include/std/version (__cpp_lib_byteswap): Define.
* testsuite/26_numerics/bit/bit.byteswap/byteswap.cc: New test.
* testsuite/26_numerics/bit/bit.byteswap/version.cc: New test.
Martin Liska [Sun, 28 Nov 2021 08:39:40 +0000 (09:39 +0100)]
d: fix thinko in optimize attr parsing
gcc/d/ChangeLog:
* d-attribs.cc (parse_optimize_options): Fix thinko.
GCC Administrator [Sun, 28 Nov 2021 00:16:20 +0000 (00:16 +0000)]
Daily bump.
John David Anglin [Sat, 27 Nov 2021 21:47:47 +0000 (21:47 +0000)]
Fix typo in t-dimode
2021-11-27 John David Anglin <danglin@gcc.gnu.org>
libgcc/ChangeLog:
* config/pa/t-dimode (lib2difuncs): Fix typo.
Petter Tomner [Sat, 27 Nov 2021 14:52:15 +0000 (15:52 +0100)]
jit: Change printf specifiers for size_t to %zu
Change four occurances of %ld specifier for size_t to %zu for clean 32bit builds.
Signed-off-by
2021-11-27 Petter Tomner <tomner@kth.se>
gcc/jit/
* libgccjit.c: %ld -> %zu
Jakub Jelinek [Sat, 27 Nov 2021 12:02:06 +0000 (13:02 +0100)]
x86: Fix up x86_{,64_}sh{l,r}d patterns [PR103431]
The following testcase is miscompiled because the x86_{,64_}sh{l,r}d
patterns don't properly describe what the instructions do. One thing
is left out, in particular that there is initial count &= 63 for
sh{l,r}dq and initial count &= 31 for sh{l,r}d{l,w}. And another thing
not described properly, in particular the behavior when count (after the
masking) is 0. The pattern says it is e.g.
res = (op0 << op2) | (op1 >> (64 - op2))
but that triggers UB on op1 >> 64. For op2 0 we actually want
res = (op0 << op2) | 0
When constants are propagated to these patterns during RTL optimizations,
both such problems trigger wrong-code issues.
This patch represents the patterns as e.g.
res = (op0 << (op2 & 63)) | (unsigned long long) ((uint128_t) op1 >> (64 - (op2 & 63)))
so there is both the initial masking and op2 == 0 behavior results in
zero being ored.
The patch introduces alternate patterns for constant op2 where
simplify-rtx.c will fold those expressions into simple numbers,
and define_insn_and_split pre-reload splitter for how the patterns
looked before into the new form, so that it can pattern match during
combine even computations that assumed the shift amount will be in
the range of 1 .. bitsize-1.
2021-11-27 Jakub Jelinek <jakub@redhat.com>
PR middle-end/103431
* config/i386/i386.md (x86_64_shld, x86_shld, x86_64_shrd, x86_shrd):
Change insn pattern to accurately describe the instructions.
(*x86_64_shld_1, *x86_shld_1, *x86_64_shrd_1, *x86_shrd_1): New
define_insn patterns.
(*x86_64_shld_2, *x86_shld_2, *x86_64_shrd_2, *x86_shrd_2): New
define_insn_and_split patterns.
(*ashl<dwi>3_doubleword_mask, *ashl<dwi>3_doubleword_mask_1,
*<insn><dwi>3_doubleword_mask, *<insn><dwi>3_doubleword_mask_1,
ix86_rotl<dwi>3_doubleword, ix86_rotr<dwi>3_doubleword): Adjust
splitters for x86_{,64_}sh{l,r}d pattern changes.
* gcc.dg/pr103431.c: New test.
Jakub Jelinek [Sat, 27 Nov 2021 12:00:55 +0000 (13:00 +0100)]
bswap: Fix UB in find_bswap_or_nop_finalize [PR103435]
On gcc.c-torture/execute/pr103376.c in the following code we trigger UB
in the compiler. n->range is 8 because it is 64-bit load and rsize is 0
because it is a bswap sequence with load and known to be 0:
/* Find real size of result (highest non-zero byte). */
if (n->base_addr)
for (tmpn = n->n, rsize = 0; tmpn; tmpn >>= BITS_PER_MARKER, rsize++);
else
rsize = n->range;
The shifts then shift uint64_t by 64 bits. For this case mask is 0
and we want both *cmpxchg and *cmpnop as 0, the operation can be done as
both nop and bswap and callers will prefer nop.
2021-11-27 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/103435
* gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Avoid UB if
n->range - rsize == 8, just clear both *cmpnop and *cmpxchg in that
case.
Roger Sayle [Sat, 27 Nov 2021 10:13:31 +0000 (10:13 +0000)]
[Committed] Fix new ivopts-[89].c test cases for -m32.
2021-11-27 Roger Sayle <roger@nextmovesoftware.com>
gcc/testsuite/ChangeLog
* gcc.dg/tree-ssa/ivopts-8.c: Fix new test case for -m32.
* gcc.dg/tree-ssa/ivopts-9.c: Likewise.
GCC Administrator [Sat, 27 Nov 2021 00:16:19 +0000 (00:16 +0000)]
Daily bump.
Martin Jambor [Sat, 27 Nov 2021 00:00:56 +0000 (01:00 +0100)]
ipa: Fix CFG fix-up in IPA-CP transform phase (PR 103441)
I forgot that IPA passes before ipa-inline must not return
TODO_cleanup_cfg from their transformation function because ordinary
CFG cleanup does not remove call graph edges associated with removed
call statements but must use
delete_unreachable_blocks_update_callgraph instead. This patch fixes
that error.
gcc/ChangeLog:
2021-11-26 Martin Jambor <mjambor@suse.cz>
PR ipa/103441
* ipa-prop.c (ipcp_transform_function): Call
delete_unreachable_blocks_update_callgraph instead of returning
TODO_cleanup_cfg.
Jonathan Wakely [Fri, 26 Nov 2021 22:53:02 +0000 (22:53 +0000)]
libstdc++: Fix test that fails in C++20 mode
This test was written to verify that the LWG 3265 changes work. But
those changes were superseded by LWG 3435, and the test is now incorrect
according to the current draft. The assignment operator is now
constrained to also require convertibility, which makes the test fail.
Change the Iter type to be convertible from int*, but make it throw an
exception if that conversion is used. Change the test from compile-only
to run, so we verify that the exception isn't thrown.
libstdc++-v3/ChangeLog:
* testsuite/24_iterators/move_iterator/dr3265.cc: Fix test to
account for LWG 3435 resolution.
Jonathan Wakely [Fri, 26 Nov 2021 21:34:17 +0000 (21:34 +0000)]
libstdc++: Fix trivial relocation for constexpr std::vector
When implementing constexpr std::vector I added a check for constant
evaluation in vector::_S_use_relocate(), so that we would not try to relocate
trivial objects by using memmove. But I put it in the constexpr function
that decides whether to relocate or not, and calls to that function are
always constant evaluated. This had the effect of disabling relocation
entirely, even in non-constexpr vectors.
This removes the check in _S_use_relocate() and modifies the actual
relocation algorithm, __relocate_a_1, to use the non-trivial
implementation instead of memmove when called during constant
evaluation.
libstdc++-v3/ChangeLog:
* include/bits/stl_uninitialized.h (__relocate_a_1): Do not use
memmove during constant evaluation.
* include/bits/stl_vector.h (vector::_S_use_relocate()): Do not
check is_constant_evaluated in always-constexpr function.
Jonathan Wakely [Fri, 26 Nov 2021 17:46:47 +0000 (17:46 +0000)]
libstdc++: Remove workaround for FE bug in std::tuple [PR96592]
The FE bug was fixed, so we don't need this workaround now.
libstdc++-v3/ChangeLog:
PR libstdc++/96592
* include/std/tuple (tuple::is_constructible): Remove.
Harald Anlauf [Fri, 26 Nov 2021 20:00:35 +0000 (21:00 +0100)]
Fortran: improve check of arguments to the RESHAPE intrinsic
gcc/fortran/ChangeLog:
PR fortran/103411
* check.c (gfc_check_reshape): Improve check of size of source
array for the RESHAPE intrinsic against the given shape when pad
is not given, and shape is a parameter. Try other simplifications
of shape.
gcc/testsuite/ChangeLog:
PR fortran/103411
* gfortran.dg/pr68153.f90: Adjust test to improved check.
* gfortran.dg/reshape_7.f90: Likewise.
* gfortran.dg/reshape_9.f90: New test.
Iain Sandoe [Sun, 21 Nov 2021 10:49:29 +0000 (10:49 +0000)]
libitm: Fix bootstrap for targets without HAVE_ELF_STYLE_WEAKREF.
Recent improvements to null address warnings notice that for
targets that do not support HAVE_ELF_STYLE_WEAKREF the dummy stub
implementation of __cxa_get_globals() means that the address can
never be null.
Fixed by removing the test for such targets.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libitm/ChangeLog:
* eh_cpp.cc (GTM::gtm_thread::init_cpp_exceptions): If the
target does not support HAVE_ELF_STYLE_WEAKREF then do not
try to test the __cxa_get_globals against NULL.
Siddhesh Poyarekar [Fri, 26 Nov 2021 03:14:58 +0000 (08:44 +0530)]
tree-object-size: Abstract object_sizes array
Put all accesses to object_sizes behind functions so that we can add
dynamic capability more easily.
gcc/ChangeLog:
* tree-object-size.c (object_sizes_grow, object_sizes_release,
object_sizes_unknown_p, object_sizes_get, object_size_set_force,
object_sizes_set): New functions.
(addr_object_size, compute_builtin_object_size,
expr_object_size, call_object_size, unknown_object_size,
merge_object_sizes, plus_stmt_object_size,
cond_expr_object_size, collect_object_sizes_for,
check_for_plus_in_loops_1, init_object_sizes,
fini_object_sizes): Adjust.
Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
Siddhesh Poyarekar [Fri, 26 Nov 2021 03:14:21 +0000 (08:44 +0530)]
tree-object-size: Replace magic numbers with enums
A simple cleanup to allow inserting dynamic size code more easily.
gcc/ChangeLog:
* tree-object-size.c: New enum.
(object_sizes, computed, addr_object_size,
compute_builtin_object_size, expr_object_size, call_object_size,
merge_object_sizes, plus_stmt_object_size,
collect_object_sizes_for, init_object_sizes, fini_object_sizes,
object_sizes_execute): Replace magic numbers with enums.
Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
Roger Sayle [Fri, 26 Nov 2021 17:22:10 +0000 (17:22 +0000)]
ivopts: Improve code generated for very simple loops.
This patch tidies up the code that GCC generates for simple loops,
by selecting/generating a simpler loop bound expression in ivopts.
The original motivation came from looking at the following loop (from
gcc.target/i386/pr90178.c)
int *find_ptr (int* mem, int sz, int val)
{
for (int i = 0; i < sz; i++)
if (mem[i] == val)
return &mem[i];
return 0;
}
which GCC currently compiles to:
find_ptr:
movq %rdi, %rax
testl %esi, %esi
jle .L4
leal -1(%rsi), %ecx
leaq 4(%rdi,%rcx,4), %rcx
jmp .L3
.L7: addq $4, %rax
cmpq %rcx, %rax
je .L4
.L3: cmpl %edx, (%rax)
jne .L7
ret
.L4: xorl %eax, %eax
ret
Notice the relatively complex leal/leaq instructions, that result
from ivopts using the following expression for the loop bound:
inv_expr 2: ((unsigned long) ((unsigned int) sz_8(D) +
4294967295)
* 4 + (unsigned long) mem_9(D)) + 4
which results from NITERS being (unsigned int) sz_8(D) +
4294967295,
i.e. (sz - 1), and the logic in cand_value_at determining the bound
as BASE + NITERS*STEP at the start of the final iteration and as
BASE + NITERS*STEP + STEP at the end of the final iteration.
Ideally, we'd like the middle-end optimizers to simplify
BASE + NITERS*STEP + STEP as BASE + (NITERS+1)*STEP, especially
when NITERS already has the form BOUND-1, but with type conversions
and possible overflow to worry about, the above "inv_expr 2" is the
best that can be done by fold (without additional context information).
This patch improves ivopts' cand_value_at by instead of using just
the tree expression for NITERS, passing the data structure that
explains how that expression was derived. This allows us to peek
under the surface to check that NITERS+1 doesn't overflow, and in
this patch to use the SSA_NAME already holding the required value.
In the motivating loop above, inv_expr 2 now becomes:
(unsigned long) sz_8(D) * 4 + (unsigned long) mem_9(D)
And as a result, on x86_64 we now generate:
find_ptr:
movq %rdi, %rax
testl %esi, %esi
jle .L4
movslq %esi, %rsi
leaq (%rdi,%rsi,4), %rcx
jmp .L3
.L7: addq $4, %rax
cmpq %rcx, %rax
je .L4
.L3: cmpl %edx, (%rax)
jne .L7
ret
.L4: xorl %eax, %eax
ret
This improvement required one minor tweak to GCC's testsuite for
gcc.dg/wrapped-binop-simplify.c, where we again generate better
code, and therefore no longer find as many optimization opportunities
in later passes (vrp2).
Previously:
void v1 (unsigned long *in, unsigned long *out, unsigned int n)
{
int i;
for (i = 0; i < n; i++) {
out[i] = in[i];
}
}
on x86_64 generated:
v1: testl %edx, %edx
je .L1
movl %edx, %edx
xorl %eax, %eax
.L3: movq (%rdi,%rax,8), %rcx
movq %rcx, (%rsi,%rax,8)
addq $1, %rax
cmpq %rax, %rdx
jne .L3
.L1: ret
and now instead generates:
v1: testl %edx, %edx
je .L1
movl %edx, %edx
xorl %eax, %eax
leaq 0(,%rdx,8), %rcx
.L3: movq (%rdi,%rax), %rdx
movq %rdx, (%rsi,%rax)
addq $8, %rax
cmpq %rax, %rcx
jne .L3
.L1: ret
2021-11-26 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* tree-ssa-loop-ivopts.c (cand_value_at): Take a class
tree_niter_desc* argument instead of just a tree for NITER.
If we require the iv candidate value at the end of the final
loop iteration, try using the original loop bound as the
NITER for sufficiently simple loops.
(may_eliminate_iv): Update (only) call to cand_value_at.
gcc/testsuite/ChangeLog
* gcc.dg/wrapped-binop-simplify.c: Update expected test result.
* gcc.dg/tree-ssa/ivopts-5.c: New test case.
* gcc.dg/tree-ssa/ivopts-6.c: New test case.
* gcc.dg/tree-ssa/ivopts-7.c: New test case.
* gcc.dg/tree-ssa/ivopts-8.c: New test case.
* gcc.dg/tree-ssa/ivopts-9.c: New test case.
Jonathan Wakely [Fri, 26 Nov 2021 15:10:43 +0000 (15:10 +0000)]
libstdc++: Ensure dg-add-options comes after dg-options
This is what the docs say is required.
libstdc++-v3/ChangeLog:
* testsuite/29_atomics/atomic_float/1.cc: Reorder directives.
Jonathan Wakely [Fri, 26 Nov 2021 13:58:07 +0000 (13:58 +0000)]
libstdc++: Fix dg-do directive for tests supposed to be run
libstdc++-v3/ChangeLog:
* testsuite/23_containers/unordered_map/modifiers/move_assign.cc:
Change dg-do compile to run.
* testsuite/27_io/basic_istream/extractors_character/wchar_t/lwg2499.cc:
Likewise.
Jonathan Wakely [Fri, 26 Nov 2021 13:55:32 +0000 (13:55 +0000)]
libstdc++: Remove redundant xfail selectors in dg-do compile tests
An 'xfail' selector means the test is expected to fail at runtime, so is
ignored for a compile-only test. The way to mark a compile-only test as
failing is with dg-error (which these already do).
libstdc++-v3/ChangeLog:
* testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc:
Remove xfail selector.
* testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc:
Likewise.
Likewise.
* testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc:
Likewise.
* testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc:
Likewise.
* testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc:
Likewise.
* testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc:
Likewise.
* testsuite/23_containers/span/101411.cc: Likewise.
* testsuite/25_algorithms/copy/debug/constexpr_neg.cc: Likewise.
* testsuite/25_algorithms/copy_backward/debug/constexpr_neg.cc:
Likewise.
* testsuite/25_algorithms/equal/constexpr_neg.cc: Likewise.
* testsuite/25_algorithms/equal/debug/constexpr_neg.cc: Likewise.
* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_neg.cc:
Likewise.
* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_pred_neg.cc:
Likewise.
* testsuite/25_algorithms/lower_bound/debug/constexpr_valid_range_neg.cc:
Likewise.
* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_neg.cc:
Likewise.
* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_pred_neg.cc:
Likewise.
* testsuite/25_algorithms/upper_bound/debug/constexpr_valid_range_neg.cc:
Likewise.
Martin Liska [Thu, 25 Nov 2021 13:41:50 +0000 (14:41 +0100)]
d: fix ASAN in option processing
Fixes:
==129444==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000666ca5c at pc 0x000000ef094b bp 0x7fffffff8180 sp 0x7fffffff8178
READ of size 4 at 0x00000666ca5c thread T0
#0 0xef094a in parse_optimize_options ../../gcc/d/d-attribs.cc:855
#1 0xef0d36 in d_handle_optimize_attribute ../../gcc/d/d-attribs.cc:916
#2 0xef107e in d_handle_optimize_attribute ../../gcc/d/d-attribs.cc:887
#3 0xff85b1 in decl_attributes(tree_node**, tree_node*, int, tree_node*) ../../gcc/attribs.c:829
#4 0xef2a91 in apply_user_attributes(Dsymbol*, tree_node*) ../../gcc/d/d-attribs.cc:427
#5 0xf7b7f3 in get_symbol_decl(Declaration*) ../../gcc/d/decl.cc:1346
#6 0xf87bc7 in get_symbol_decl(Declaration*) ../../gcc/d/decl.cc:967
#7 0xf87bc7 in DeclVisitor::visit(FuncDeclaration*) ../../gcc/d/decl.cc:808
#8 0xf83db5 in DeclVisitor::build_dsymbol(Dsymbol*) ../../gcc/d/decl.cc:146
for the following test-case: gcc/testsuite/gdc.dg/attr_optimize1.d.
gcc/d/ChangeLog:
* d-attribs.cc (parse_optimize_options): Check index before
accessing cl_options.
Jan Hubicka [Fri, 26 Nov 2021 12:54:41 +0000 (13:54 +0100)]
Minor ipa-modref tweaks
To make dumps easier to read modref now dumps cgraph_node name rather then
cfun name in function being analysed and I also fixed minor issue with ECF
flags merging when updating inline summary.
gcc/ChangeLog:
2021-11-26 Jan Hubicka <hubicka@ucw.cz>
* ipa-modref.c (analyze_function): Drop parameter F and dump
cgraph node name rather than cfun name.
(modref_generate): Update.
(modref_summaries::insert):Update.
(modref_summaries_lto::insert):Update.
(pass_modref::execute):Update.
(ipa_merge_modref_summary_after_inlining): Improve combining of
ECF_FLAGS.
Jan Hubicka [Fri, 26 Nov 2021 12:48:29 +0000 (13:48 +0100)]
Fix failure in inlline-9.c testcase
gcc/testsuite/ChangeLog:
2021-11-26 Jan Hubicka <hubicka@ucw.cz>
* gcc.dg/ipa/inline-9.c: Update template.c
Jonathan Wakely [Fri, 26 Nov 2021 11:03:06 +0000 (11:03 +0000)]
libstdc++: Move std::to_address tests to more appropriate place
Some of the checks in 20_util/pointer_traits/lwg3545.cc really belong in
20_util/to_address/lwg3545 instead.
This also fixes the ordering of the dg-options and dg-do directives.
libstdc++-v3/ChangeLog:
* testsuite/20_util/pointer_traits/lwg3545.cc: Move to_address
tests to ...
* testsuite/20_util/to_address/lwg3545.cc: ... here. Add -std
option before checking effective target.
Jan Hubicka [Fri, 26 Nov 2021 12:36:35 +0000 (13:36 +0100)]
Fix handling of in_flags in update_escape_summary_1
update_escape_summary_1 has thinko where it compues proper min_flags but then
stores original value (ignoring the fact whether there was a dereference
in the escape point).
PR ipa/102943
* ipa-modref.c (update_escape_summary_1): Fix handling of min_flags.
Jakub Jelinek [Fri, 26 Nov 2021 09:11:13 +0000 (10:11 +0100)]
c++: Fix up taking address of an immediate function diagnostics [PR102753]
On Wed, Oct 20, 2021 at 07:16:44PM -0400, Jason Merrill wrote:
> or an unevaluated operand, or a subexpression of an immediate invocation.
>
> Hmm...that suggests that in consteval23.C, bar(foo) should also be OK,
The following patch handles that by removing the diagnostics about taking
address of immediate function from cp_build_addr_expr_1, and instead diagnoses
it in cp_fold_r. To do that with proper locations, the patch attempts to
ensure that ADDR_EXPRs of immediate functions get EXPR_LOCATION set and
adds a PTRMEM_CST_LOCATION for PTRMEM_CSTs. Also, evaluation of
std::source_location::current() is moved from genericization to cp_fold.
2021-11-26 Jakub Jelinek <jakub@redhat.com>
PR c++/102753
* cp-tree.h (struct ptrmem_cst): Add locus member.
(PTRMEM_CST_LOCATION): Define.
* tree.c (make_ptrmem_cst): Set PTRMEM_CST_LOCATION to input_location.
(cp_expr_location): Return PTRMEM_CST_LOCATION for PTRMEM_CST.
* typeck.c (build_x_unary_op): Overwrite PTRMEM_CST_LOCATION for
PTRMEM_CST instead of calling maybe_wrap_with_location.
(cp_build_addr_expr_1): Don't diagnose taking address of
immediate functions here. Instead when taking their address make
sure the returned ADDR_EXPR has EXPR_LOCATION set.
(expand_ptrmemfunc_cst): Copy over PTRMEM_CST_LOCATION to ADDR_EXPR's
EXPR_LOCATION.
(convert_for_assignment): Use cp_expr_loc_or_input_loc instead of
EXPR_LOC_OR_LOC.
* pt.c (tsubst_copy): Use build1_loc instead of build1. Ensure
ADDR_EXPR of immediate function has EXPR_LOCATION set.
* cp-gimplify.c (cp_fold_r): Diagnose taking address of immediate
functions here. For consteval if don't walk THEN_CLAUSE.
(cp_genericize_r): Move evaluation of calls to
std::source_location::current from here to...
(cp_fold): ... here. Don't assert calls to immediate functions must
be source_location_current_p, instead only constant evaluate
calls to source_location_current_p.
* g++.dg/cpp2a/consteval20.C: Add some extra tests.
* g++.dg/cpp2a/consteval23.C: Likewise.
* g++.dg/cpp2a/consteval25.C: New test.
* g++.dg/cpp2a/srcloc20.C: New test.
konglin1 [Wed, 10 Nov 2021 01:37:32 +0000 (09:37 +0800)]
i386: vcvtph2ps and vcvtps2ph should be used to convert _Float16 to SFmode with -mf16c [PR 102811]
Add define_insn extendhfsf2 and truncsfhf2 for target_f16c.
gcc/ChangeLog:
PR target/102811
* config/i386/i386.c (ix86_can_change_mode_class): Allow 16 bit data in XMM register
for TARGET_SSE2.
* config/i386/i386.md (extendhfsf2): Add extenndhfsf2 for TARGET_F16C.
(extendhfdf2): Restrict extendhfdf for TARGET_AVX512FP16 only.
(*extendhf<mode>2): Rename from extendhf<mode>2.
(truncsfhf2): Likewise.
(truncdfhf2): Likewise.
(*trunc<mode>2): Likewise.
gcc/testsuite/ChangeLog:
PR target/102811
* gcc.target/i386/pr90773-21.c: Allow pextrw instead of movw.
* gcc.target/i386/pr90773-23.c: Ditto.
* gcc.target/i386/avx512vl-vcvtps2ph-pr102811.c: New test.
liuhongt [Thu, 25 Nov 2021 05:51:57 +0000 (13:51 +0800)]
Fix typo in r12-5486.
gcc/ChangeLog:
PR middle-end/103419
* match.pd: Fix typo, use the type of second parameter, not
first one.
GCC Administrator [Fri, 26 Nov 2021 00:16:26 +0000 (00:16 +0000)]
Daily bump.
Jonathan Wakely [Thu, 25 Nov 2021 22:54:07 +0000 (22:54 +0000)]
libstdc++: Remove dg-error that no longer happens
There was a c++11_only dg-error in this testcase, for a "body of
constexpr function is not a return statement" diagnostic that was bogus,
but happened because the return statement was ill-formed. A change to
G++ earlier this month means that diagnostic is no longer emitted, so
remove the dg-error.
libstdc++-v3/ChangeLog:
* testsuite/20_util/tuple/comparison_operators/overloaded2.cc:
Remove dg-error for C++11_only error.
Jonathan Wakely [Thu, 25 Nov 2021 16:49:45 +0000 (16:49 +0000)]
libstdc++: Make std::pointer_traits SFINAE-friendly [PR96416]
This implements the resolution I'm proposing for LWG 3545, to avoid hard
errors when using std::to_address for types that make pointer_traits
ill-formed.
Consistent with std::iterator_traits, instantiating std::pointer_traits
for a non-pointer type will be well-formed, but give an empty type with
no member types. This avoids the problematic cases for std::to_address.
Additionally, the pointer_to member is now only declared when the
element type is not cv void (and for C++20, when the function body would
be well-formed). The rebind member was already SFINAE-friendly in our
implementation.
libstdc++-v3/ChangeLog:
PR libstdc++/96416
* include/bits/ptr_traits.h (pointer_traits): Reimplement to be
SFINAE-friendly (LWG 3545).
* testsuite/20_util/pointer_traits/lwg3545.cc: New test.
* testsuite/20_util/to_address/1_neg.cc: Adjust dg-error line.
* testsuite/20_util/to_address/lwg3545.cc: New test.
Jan Hubicka [Thu, 25 Nov 2021 22:58:48 +0000 (23:58 +0100)]
Remove forgotten early return in ipa_value_range_from_jfunc
gcc/ChangeLog:
* ipa-cp.c (ipa_value_range_from_jfunc): Remove forgotten early return.
gcc/testsuite/ChangeLog:
* gcc.dg/ipa/inline10.c: New test.
Jonathan Wakely [Wed, 24 Nov 2021 13:17:54 +0000 (13:17 +0000)]
libstdc++: Do not use memset in constexpr calls to ranges::fill_n [PR101608]
libstdc++-v3/ChangeLog:
PR libstdc++/101608
* include/bits/ranges_algobase.h (__fill_n_fn): Check for
constant evaluation before using memset.
* testsuite/25_algorithms/fill_n/constrained.cc: Check
byte-sized values as well.
Roger Sayle [Thu, 25 Nov 2021 19:02:06 +0000 (19:02 +0000)]
PR middle-end/103406: Check for Inf before simplifying x-x.
This is a simple one line fix to the regression PR middle-end/103406,
where x - x is being folded to 0.0 even when x is +Inf or -Inf.
In GCC 11 and previously, we'd check whether the type honored NaNs
(which implicitly covered the case where the type honors infinities),
but my patch to test whether the operand could potentially be NaN
failed to also check whether the operand could potentially be Inf.
2021-11-25 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR middle-end/103406
* match.pd (minus @0 @0): Check tree_expr_maybe_infinite_p.
gcc/testsuite/ChangeLog
PR middle-end/103406
* gcc.dg/pr103406.c: New test case.
Florian Weimer [Thu, 25 Nov 2021 17:40:51 +0000 (18:40 +0100)]
libgcc: Split FDE search code from PT_GNU_EH_FRAME lookup
This allows switching to a different implementation for
PT_GNU_EH_FRAME lookup in a subsequent commit.
This moves some of the PT_GNU_EH_FRAME parsing out of the glibc loader
lock that is implied by dl_iterate_phdr. However, the FDE is already
parsed outside the lock before this change, so this does not introduce
additional crashes in case of a concurrent dlclose.
libgcc/ChangeLog:
* unwind-dw2-fde-dip.c (struct unw_eh_callback_data): Add hdr.
Remove func, ret.
(find_fde_tail): New function. Split from
_Unwind_IteratePhdrCallback. Move the result initialization
from _Unwind_Find_FDE.
(_Unwind_Find_FDE): Updated to call find_fde_tail.
Martin Jambor [Thu, 25 Nov 2021 16:58:12 +0000 (17:58 +0100)]
ipa: Teach IPA-CP transformation about IPA-SRA modifications (PR 103227)
PR 103227 exposed an issue with ordering of transformations of IPA
passes. IPA-CP can create clones for constants passed by reference
and at the same time IPA-SRA can also decide that the parameter does
not need to be a pointer (or an aggregate) and plan to convert it
into (a) simple scalar(s). Because no intermediate clone is created
just for the purpose of ordering the transformations and because
IPA-SRA transformation is implemented as part of clone
materialization, the IPA-CP transformation happens only afterwards,
reversing the order of the transformations compared to the ordering of
analyses.
IPA-CP transformation looks at planned substitutions for values passed
by reference or in aggregates but finds that all the relevant
parameters no longer exist. Currently it subsequently simply gives
up, leading to clones created for no good purpose (and huge regression
of 548.exchange_r. This patch teaches it recognize the situation,
look up the new scalarized parameter and perform value substitution on
it. On my desktop this has recovered the lost exchange2 run-time (and
some more).
I have disabled IPA-SRA in a Fortran testcase so that the dumping from
the transformation phase can still be matched in order to verify that
IPA-CP understands the IL after verifying that it does the right thing
also with IPA-SRA.
gcc/ChangeLog:
2021-11-23 Martin Jambor <mjambor@suse.cz>
PR ipa/103227
* ipa-prop.h (ipa_get_param): New overload. Move bits of the existing
one to the new one.
* ipa-param-manipulation.h (ipa_param_adjustments): New member
function get_updated_index_or_split.
* ipa-param-manipulation.c
(ipa_param_adjustments::get_updated_index_or_split): New function.
* ipa-prop.c (adjust_agg_replacement_values): Reimplement, add
capability to identify scalarized parameters and perform substitution
on them.
(ipcp_transform_function): Create descriptors earlier, handle new
return values of adjust_agg_replacement_values.
gcc/testsuite/ChangeLog:
2021-11-23 Martin Jambor <mjambor@suse.cz>
PR ipa/103227
* gcc.dg/ipa/pr103227-1.c: New test.
* gcc.dg/ipa/pr103227-3.c: Likewise.
* gcc.dg/ipa/pr103227-2.c: Likewise.
* gfortran.dg/pr53787.f90: Disable IPA-SRA.
Aldy Hernandez [Thu, 25 Nov 2021 16:30:07 +0000 (17:30 +0100)]
path solver: Revert computation of ranges in gimple order.
Revert the patch below, as it may slow down compilation with large CFGs.
commit
8acbd7bef6edbf537e3037174907029b530212f6
Author: Aldy Hernandez <aldyh@redhat.com>
Date: Wed Nov 24 09:43:36 2021 +0100
path solver: Compute ranges in path in gimple order.
gcc/ChangeLog:
* gimple-range-path.cc (path_range_query::compute_ranges_defined): Remove.
(path_range_query::compute_ranges_in_block): Revert to bitmap order.
* gimple-range-path.h: Remove compute_ranges_defined.
Andrew Stubbs [Thu, 25 Nov 2021 15:59:20 +0000 (15:59 +0000)]
amdgcn: Fix ICE generating CFI [PR103396]
gcc/ChangeLog:
PR target/103396
* config/gcn/gcn.c (move_callee_saved_registers): Ensure that the
number of spilled registers is counted correctly.
Andrew MacLeod [Thu, 25 Nov 2021 13:58:19 +0000 (08:58 -0500)]
Add the testcase for this PR to the testsuite.
Various ranger-enabled patches like threading and VRP2 can do this now, so add the testcase for posterity.
gcc/testsuite/
PR tree-optimization/102648
* gcc.dg/pr102648.c: New.
Jan Hubicka [Thu, 25 Nov 2021 13:48:14 +0000 (14:48 +0100)]
Initialize node_is_self_scc in ipa_node_params::ipa_node_params
gcc/ChangeLog:
2021-11-25 Jan Hubicka <hubicka@ucw.cz>
* ipa-prop.h (ipa_node_params::ipa_node_params): Initialize
node_is_self_scc.
Andrew MacLeod [Tue, 23 Nov 2021 19:12:29 +0000 (14:12 -0500)]
Check for equivalences between PHI argument and def.
If a PHI argument on an edge is equivalent with the DEF, then it doesn't
provide any new information, defer processing it unless they are all
equivalences.
PR tree-optimization/103359
gcc/
* gimple-range-fold.cc (fold_using_range::range_of_phi): If arg is
equivalent to def, don't initially include it's range.
gcc/testsuite/
* gcc.dg/pr103359.c: New.
Jan Hubicka [Thu, 25 Nov 2021 13:42:47 +0000 (14:42 +0100)]
Do not check gimple_static_cahin in ref_maybe_used_by_call_p_1
gcc/ChangeLog:
2021-11-25 Jan Hubicka <hubicka@ucw.cz>
* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Do not check
gimple_static_chain.
Richard Biener [Wed, 24 Nov 2021 14:57:03 +0000 (15:57 +0100)]
Remove dead code and function
The only use of get_alias_symbol is gated by a gcc_unreachable (),
so the following patch gets rid of it.
2021-11-24 Richard Biener <rguenther@suse.de>
* cgraphunit.c (symbol_table::output_weakrefs): Remove
unreachable init.
(get_alias_symbol): Remove now unused function.
Richard Biener [Wed, 24 Nov 2021 14:57:03 +0000 (15:57 +0100)]
Continue RTL verifying in rtl_verify_fallthru
One case used fatal_insn which does not return which isn't
intended as can be seen by the following erro = 1. The following
change refactors this to inline the relevant parts of fatal_insn
instead and continue validating the RTL IL.
2021-11-25 Richard Biener <rguenther@suse.de>
* cfgrtl.c (rtl_verify_fallthru): Do not stop verifying
with fatal_insn.
(skip_insns_after_block): Remove unreachable break and continue.
Richard Biener [Wed, 24 Nov 2021 14:57:03 +0000 (15:57 +0100)]
Remove never looping loop in label_rtx_for_bb
This refactors the IL "walk" in a way to avoid the loop which will
never iterate.
2021-11-25 Richard Biener <rguenther@suse.de>
* cfgexpand.c (label_rtx_for_bb): Remove dead loop construct.
Richard Biener [Wed, 24 Nov 2021 14:57:03 +0000 (15:57 +0100)]
Introduce REG_SET_EMPTY_P
This avoids a -Wunreachable-code diagnostic with EXECUTE_IF_*
in case the first iteration will exit the loop. For the case
in thread_jump using bitmap_empty_p looks preferable so this
adds REG_SET_EMPTY_P to make that available for register sets.
2021-11-25 Richard Biener <rguenther@suse.de>
* regset.h (REG_SET_EMPTY_P): New macro.
* cfgcleanup.c (thread_jump): Use REG_SET_EMPTY_P.
Martin Liska [Thu, 25 Nov 2021 11:13:59 +0000 (12:13 +0100)]
docs: Add missing @option keyword.
gcc/ChangeLog:
* doc/invoke.texi: Use @option for -Wuninitialized.
Aldy Hernandez [Wed, 24 Nov 2021 16:58:43 +0000 (17:58 +0100)]
path solver: Move boolean import code to compute_imports.
In a follow-up patch I will be pruning the set of exported ranges
within blocks to avoid unnecessary work. In order to do this, all the
interesting SSA names must be in the internal import bitmap ahead of
time. I had already abstracted them out into compute_imports, but I
missed the boolean code. This fixes the oversight.
There's a net gain of 25 threadable paths, which is unexpected but
welcome.
Tested on x86-64 & ppc64le Linux.
gcc/ChangeLog:
PR tree-optimization/103254
* gimple-range-path.cc (path_range_query::compute_ranges): Move
exported boolean code...
(path_range_query::compute_imports): ...here.
Aldy Hernandez [Wed, 24 Nov 2021 08:43:36 +0000 (09:43 +0100)]
path solver: Compute ranges in path in gimple order.
Andrew's patch for this PR103254 papered over some underlying
performance issues in the path solver that I'd like to address.
We are currently solving the SSA's defined in the current block in
bitmap order, which amounts to random order for all purposes. This is
causing unnecessary recursion in gori. This patch changes the order
to gimple order, thus solving dependencies before uses.
There is no change in threadable paths with this change.
Tested on x86-64 & ppc64le Linux.
gcc/ChangeLog:
PR tree-optimization/103254
* gimple-range-path.cc (path_range_query::compute_ranges_defined): New
(path_range_query::compute_ranges_in_block): Move to
compute_ranges_defined.
* gimple-range-path.h (compute_ranges_defined): New.
Jakub Jelinek [Thu, 25 Nov 2021 09:47:24 +0000 (10:47 +0100)]
match.pd: Fix up the recent bitmask_inv_cst_vector_p simplification [PR103417]
The following testcase is miscompiled since the r12-5489-g0888d6bbe97e10
changes.
The simplification triggers on
(x & 4294967040U) >= 0U
and turns it into:
x <= 255U
which is incorrect, it should fold to 1 because unsigned >= 0U is always
true and normally the
/* Non-equality compare simplifications from fold_binary */
(if (wi::to_wide (cst) == min)
(if (cmp == GE_EXPR)
{ constant_boolean_node (true, type); })
simplification folds that, but this simplification was done earlier.
The simplification correctly doesn't include lt which has the same
reason why it shouldn't be handled, we'll fold it to 0 elsewhere.
But, IMNSHO while it isn't incorrect to handle le and gt there, it is
unnecessary. Because (x & cst) <= 0U and (x & cst) > 0U should
never appear, again in
/* Non-equality compare simplifications from fold_binary */
we have a simplification for it:
(if (cmp == LE_EXPR)
(eq @2 @1))
(if (cmp == GT_EXPR)
(ne @2 @1))))
This is done for
(cmp (convert?@2 @0) uniform_integer_cst_p@1)
and so should be done for both integers and vectors.
As the bitmask_inv_cst_vector_p simplification only handles
eq and ne for signed types, I think it can be simplified to just
following patch.
2021-11-25 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/103417
* match.pd ((X & Y) CMP 0): Only handle eq and ne. Commonalize
common tests.
* gcc.c-torture/execute/pr103417.c: New test.
Jakub Jelinek [Thu, 25 Nov 2021 09:38:33 +0000 (10:38 +0100)]
bswap: Improve perform_symbolic_merge [PR103376]
Thinking more about it, perhaps we could do more for BIT_XOR_EXPR.
We could allow masked1 == masked2 case for it, but would need to
do something different than the
n->n = n1->n | n2->n;
we do on all the bytes together.
In particular, for masked1 == masked2 if masked1 != 0 (well, for 0
both variants are the same) and masked1 != 0xff we would need to
clear corresponding n->n byte instead of setting it to the input
as x ^ x = 0 (but if we don't know what x and y are, the result is
also don't know). Now, for plus it is much harder, because not only
for non-zero operands we don't know what the result is, but it can
modify upper bytes as well. So perhaps only if current's byte
masked1 && masked2 set the resulting byte to 0xff (unknown) iff
the byte above it is 0 and 0, and set that resulting byte to 0xff too.
Also, even for | we could instead of return NULL just set the resulting
byte to 0xff if it is different, perhaps it will be masked off later on.
This patch just punts on plus if both corresponding bytes are non-zero,
otherwise implements the above.
2021-11-25 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/103376
* gimple-ssa-store-merging.c (perform_symbolic_merge): For
BIT_IOR_EXPR, if masked1 && masked2 && masked1 != masked2, don't
punt, but set the corresponding result byte to MARKER_BYTE_UNKNOWN.
For BIT_XOR_EXPR similarly and if masked1 == masked2 and the
byte isn't MARKER_BYTE_UNKNOWN, set the corresponding result byte to
0.
* gcc.dg/optimize-bswapsi-7.c: New test.
Jakub Jelinek [Thu, 25 Nov 2021 07:39:35 +0000 (08:39 +0100)]
c++: Return early in apply_late_template_attributes if there are no late attribs [PR101180]
The r12-299-ga0fdff3cf33f7284 change can result in cplus_decl_attributes being called
even if there are no late attributes (but at least one early attribute) in
apply_late_template_attributes. This patch fixes that, so that we return early
if there are no late attrs, only arrange for TYPE_ATTRIBUTES to get the early
attribute list.
2021-11-25 Jakub Jelinek <jakub@redhat.com>
PR c++/101180
* pt.c (apply_late_template_attributes): Return early if there are no
dependent attributes.
Jakub Jelinek [Thu, 25 Nov 2021 07:36:20 +0000 (08:36 +0100)]
c++: Implement C++23 P2128R6 - Multidimensional subscript operator [PR102611]
The following patch implements the C++23 Multidimensional subscript operator
P2128R6 paper.
As C++20 and older only allow a single expression in between []s (albeit
for C++20 with a deprecation warning if it is a comma expression) and even
in C++23 and for the coming years I think the vast majority of subscript
expressions will still have a single expression and even in C++23 it is
quite special, as e.g. the builtin operator requires exactly one
assignment expression, the patch attempts to optimize for that case and
if possible not to slow down that common case (or use more memory for it).
So, already during parsing it differentiates between that (uses a single
index_exp tree in that case) and the new cases (zero or two+ expressions
in the list), for which it sets index_exp to NULL_TREE and uses a
releasing_vec instead similarly to how e.g. finish_call_expr uses it.
In call.c it introduces new functions build_op_subscript{,_1} which are
something in between build_new_op{,_1} and build_op_call{,_1}.
The former requires fixed number of arguments (and the patch still uses
it for the common case of subscript with exactly one index expression),
the latter handles variable number of arguments but is too CALL_EXPR specific
and handles various cases that are unnecessary for the subscript.
Right now the subscript for 0 or 2+ expressions doesn't need to deal with
builtin candidates and so is quite simple.
As discussed in the paper, for backwards compatibility, if for 2+ index
expressions build_op_subscript fails (called with tf_none) and the
expressions together form a valid comma expression (again checked with
tf_none), it is used that C++20-ish way with a pedwarn about it, but if
even that fails, build_op_subscript is called again with standard complain
flags to diagnose it in the new way. And similarly for the builtin case.
The -Wcomma-subscript warning used to be enabled by default unless
-Wno-deprecated. Since the C/C++98..20 behavior is no longer deprecated,
but ill-formed or changed meaning, it is now for C++23 enabled by
default regardless of -Wno-deprecated and controls the pedwarn (but not the
errors emitted if something wasn't valid before and isn't valid in C++23
either).
2021-11-25 Jakub Jelinek <jakub@redhat.com>
PR c++/102611
gcc/
* doc/invoke.texi (-Wcomma-subscript): Document that for
-std=c++20 the option isn't enabled by default with -Wno-deprecated
but for -std=c++23 it is.
gcc/c-family/
* c-opts.c (c_common_post_options): Enable -Wcomma-subscript by
default for C++23 regardless of warn_deprecated.
* c-cppbuiltin.c (c_cpp_builtins): Predefine
__cpp_multidimensional_subscript=202110L for C++23.
gcc/cp/
* cp-tree.h (build_op_subscript): Implement P2128R6
- Multidimensional subscript operator. Declare.
(class releasing_vec): Add release method.
(grok_array_decl): Remove bool argument, add vec<tree, va_gc> **
and tsubst_flags_t arguments.
(build_min_non_dep_op_overload): Declare another overload.
* parser.c (cp_parser_parenthesized_expression_list_elt): New function.
(cp_parser_postfix_open_square_expression): Mention C++23 syntax in
function comment. For C++23 parse zero or more than one initializer
clauses in expression list, adjust grok_array_decl caller.
(cp_parser_parenthesized_expression_list): Use
cp_parser_parenthesized_expression_list_elt.
(cp_parser_builtin_offsetof): Adjust grok_array_decl caller.
* decl.c (grok_op_properties): For C++23 don't check number
of arguments of operator[].
* decl2.c (grok_array_decl): Remove decltype_p argument, add
index_exp_list and complain arguments. If index_exp is NULL,
handle *index_exp_list as the subscript expression list.
* tree.c (build_min_non_dep_op_overload): New overload.
* call.c (add_operator_candidates, build_over_call): Adjust comments
for removal of build_new_op_1.
(build_op_subscript): New function.
* pt.c (tsubst_copy_and_build_call_args): New function.
(tsubst_copy_and_build) <case ARRAY_REF>: If second
operand is magic CALL_EXPR with ovl_op_identifier (ARRAY_REF)
as CALL_EXPR_FN, tsubst CALL_EXPR arguments including expanding
pack expressions in it and call grok_array_decl instead of
build_x_array_ref.
<case CALL_EXPR>: Use tsubst_copy_and_build_call_args.
* semantics.c (handle_omp_array_sections_1): Adjust grok_array_decl
caller.
gcc/testsuite/
* g++.dg/cpp2a/comma1.C: Expect different diagnostics for C++23.
* g++.dg/cpp2a/comma3.C: Likewise.
* g++.dg/cpp2a/comma4.C: Expect diagnostics for C++23.
* g++.dg/cpp2a/comma5.C: Expect different diagnostics for C++23.
* g++.dg/cpp23/feat-cxx2b.C: Test __cpp_multidimensional_subscript
predefined macro.
* g++.dg/cpp23/subscript1.C: New test.
* g++.dg/cpp23/subscript2.C: New test.
* g++.dg/cpp23/subscript3.C: New test.
* g++.dg/cpp23/subscript4.C: New test.
* g++.dg/cpp23/subscript5.C: New test.
* g++.dg/cpp23/subscript6.C: New test.
H.J. Lu [Thu, 25 Nov 2021 04:16:13 +0000 (20:16 -0800)]
pr103194-5.c: Replace long with int64_t
Replace long with int64_t to work with -mx32.
* gcc.target/i386/pr103194-5.c: Include <stdint.h>.
Replace long with int64_t.
GCC Administrator [Thu, 25 Nov 2021 00:16:29 +0000 (00:16 +0000)]
Daily bump.
Jan Hubicka [Wed, 24 Nov 2021 21:27:17 +0000 (22:27 +0100)]
Fix handling of static chain in ipa_merge_modref_summary_after_inlining
gcc/ChangeLog:
2021-11-24 Jan Hubicka <hubicka@ucw.cz>
* ipa-modref.c (implicit_eaf_flags_for_edge_and_arg): Break out from...
(modref_merge_call_site_flags): ... here.
(ipa_merge_modref_summary_after_inlining): Use it.
gcc/testsuite/ChangeLog:
2021-11-24 Jan Hubicka <hubicka@ucw.cz>
* gcc.c-torture/execute/pr103405.c: New test.
Thomas Schwinge [Fri, 30 Jul 2021 07:23:20 +0000 (09:23 +0200)]
Reduce scope of a few 'class loop *loop' variables
Further clean-up after commit
e41ba804ba5f5ca433e09238d561b1b4c8b10985
"Use range-based for loops for traversing loops". No functional change.
gcc/
* cfgloop.c (verify_loop_structure): Reduce scope of
'class loop *loop' variable.
* ipa-fnsummary.c (analyze_function_body): Likewise.
* loop-init.c (fix_loop_structure): Likewise.
* loop-invariant.c (calculate_loop_reg_pressure): Likewise.
* predict.c (predict_loops): Likewise.
* tree-loop-distribution.c (loop_distribution::execute): Likewise.
* tree-vectorizer.c (pass_vectorize::execute): Likewise.
Andrew MacLeod [Mon, 22 Nov 2021 19:39:41 +0000 (14:39 -0500)]
Directly resolve range_of_stmt dependencies.
All ranger API entries eventually call range_of_stmt to ensure there is an
initial global value to work with. This can cause very deep call chains when
satisfied via the normal API. Instead, push any dependencies onto a stack
and evaluate them in a depth first manner, mirroring what would have happened
via the normal API calls.
PR tree-optimization/103231
gcc/
* gimple-range.cc (gimple_ranger::gimple_ranger): Create stmt stack.
(gimple_ranger::gimple_ranger): Delete stmt stack.
(gimple_ranger::range_of_stmt): Process depenedencies if they have no
global cache entry.
(gimple_ranger::prefill_name): New.
(gimple_ranger::prefill_stmt_dependencies): New.
* gimple-range.h (class gimple_ranger): Add prototypes.
Andrew MacLeod [Fri, 19 Nov 2021 17:59:12 +0000 (12:59 -0500)]
Split return functionality of get_non_stale_global_range.
Get_non_stale_global_range returns true only when there is a cache entry that
is not out of date. Change it so that it returns true if there was a cache
value, but return the temporal comparison result in an auxiallary flag.
* gimple-range-cache.cc (ranger_cache::get_global_range): Always
return a range, return if it came from the cache or not.
(get_non_stale_global_range): Rename to get_global_range, and return
the temporal state in a flag.
* gimple-range-cache.h (get_non_stale_global_range): Rename and adjust.
* gimple-range.cc (gimple_ranger::range_of_expr): No need to query
get_global_range.
(gimple_ranger::range_of_stmt): Adjust for global cache temporal state
returned in a flag.
Andrew MacLeod [Fri, 19 Nov 2021 18:27:18 +0000 (13:27 -0500)]
Range-on-edge trace tweak.
Trace formatting gets out of sync when range on edge is called with a constant.
* gimple-range.cc (gimple_ranger::range_on_edge): Call trailer when
a constant is encountered to terminate the trace.
Jonathan Wakely [Wed, 24 Nov 2021 11:47:44 +0000 (11:47 +0000)]
libstdc++: Add xfail to some printer tests for debug mode
The type printers are not substituting std::string for
std::basic_string<char> in debug mode, mark some tests as xfail.
libstdc++-v3/ChangeLog:
* testsuite/libstdc++-prettyprinters/80276.cc: Add xfail for
debug mode.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
Jonathan Wakely [Wed, 24 Nov 2021 11:41:01 +0000 (11:41 +0000)]
libstdc++: Replace hyphens in effective target keywords
An effective target like foo-bar-baz will match a target selector of
*-*-* and cause problems in the testsuite. Several libstdc++ et keywords
are of the form foo-bar, which could still be a problem for *-*
selectors.
Replace hyphens with underscores in the et keywords "debug-mode",
"cxx11-abi", etc.
libstdc++-v3/ChangeLog:
* testsuite/lib/libstdc++.exp: Rename effective target keywords
to avoid dashes in the name.
* testsuite/*: Update effective targe keywords.
Maciej W. Rozycki [Wed, 24 Nov 2021 13:15:06 +0000 (13:15 +0000)]
PR middle-end/103059: reload: Also accept ASHIFT with indexed addressing
Correct a `vax-netbsdelf' target regression ultimately caused by commit
c605a8bf9270 ("VAX: Accept ASHIFT in address expressions") (needed for
LRA) and as of commit
4a960d548b7d ("Avoid invalid loop transformations
in jump threading registry.") causing a build error in libgcc:
.../libgcc/libgcov-driver.c: In function 'gcov_do_dump':
.../libgcc/libgcov-driver.c:686:1: error: insn does not satisfy its constraints:
686 | }
| ^
(insn 2051 2050 2052 185 (set (reg/f:SI 0 %r0 [555])
(plus:SI (ashift:SI (mem/c:SI (plus:SI (reg/f:SI 13 %fp)
(const_int -28 [0xffffffffffffffe4])) [40 %sfp+-28 S4 A32])
(const_int 3 [0x3]))
(plus:SI (reg/v/f:SI 9 %r9 [orig:176 fn_buffer ] [176])
(const_int 24 [0x18])))) ".../libgcc/libgcov-driver.c":172:40 614 {movaddrdi}
(nil))
during RTL pass: postreload
.../libgcc/libgcov-driver.c:686:1: internal compiler error: in extract_constrain_insn, at recog.c:2670
0x1122a5ff _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
.../gcc/rtl-error.c:108
0x1122a697 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
.../gcc/rtl-error.c:118
0x111b5f2f extract_constrain_insn(rtx_insn*)
.../gcc/recog.c:2670
0x11143eef reload_cse_simplify_operands
.../gcc/postreload.c:407
0x11142fdb reload_cse_simplify
.../gcc/postreload.c:132
0x11143533 reload_cse_regs_1
.../gcc/postreload.c:238
0x11142ce7 reload_cse_regs
.../gcc/postreload.c:66
0x1114af33 execute
.../gcc/postreload.c:2355
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
This is because reload does not recognize the ASHIFT form of scaled
indexed addressing that the offending commit enabled the backend to
produce, and as seen in the RTL above lets the pseudo holding the
index part become the original memory reference rather than reloading it
into a hard register.
Fix it then by adding said form to reload, removing the build failure
and numerous similar regressions throughout `vax-netbsdelf' test suites
run with the source as at right before the build regression.
Cf. <https://gcc.gnu.org/pipermail/gcc-patches/2021-March/567256.html>,
and commit
6b3034eaba83 ("lra: Canonicalize mult to shift in address
reloads").
gcc/
PR middle-end/103059
* reload.c (find_reloads_address_1): Also accept the ASHIFT form
of indexed addressing.
(find_reloads): Adjust accordingly.
Richard Biener [Wed, 24 Nov 2021 08:08:44 +0000 (09:08 +0100)]
tree-optimization/103168 - Improve VN of pure function calls
This improves value-numbering of calls that read memory, calls
to const functions with aggregate arguments and calls to
pure functions where the latter include const functions we
demoted to pure for the fear of interposing with a less
optimized version. Note that for pure functions we do not
handle functions that access global memory.
2021-11-24 Richard Biener <rguenther@suse.de>
Jan Hubicka <jh@suse.cz>
PR tree-optimization/103168
* ipa-modref.h (struct modref_summary): Add load_accesses.
* ipa-modref.c (modref_summary::finalize): Initialize load_accesses.
* tree-ssa-sccvn.c (visit_reference_op_call): Use modref
info to walk the virtual use->def chain to CSE const/pure
function calls possibly reading from memory.
* g++.dg/tree-ssa/pr103168.C: New testcase.
Thomas Schwinge [Mon, 22 Nov 2021 16:29:09 +0000 (17:29 +0100)]
Restore previous OpenACC implicit data clauses ordering [PR103244]
Follow-up for recent commit
b7e20480630e3eeb9eed8b3941da3b3f0c22c969
"openmp: Relax handling of implicit map vs. existing device mappings".
As discussed, we likely also for OpenACC ought to use
'OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P' and do the appropriate implicit clauses
ordering -- but that's for a separate step.
gcc/
PR middle-end/103244
* gimplify.c (gimplify_adjust_omp_clauses): Restore previous
OpenACC behavior.
gcc/testsuite/
PR middle-end/103244
* c-c++-common/goacc/combined-reduction.c: Revert/expect previous
OpenACC behavior.
* c-c++-common/goacc/firstprivate-mappings-1.c: Likewise.
* c-c++-common/goacc/mdc-1.c: Likewise.
* g++.dg/goacc/firstprivate-mappings-1.C: Likewise.
Martin Liska [Wed, 24 Nov 2021 09:15:34 +0000 (10:15 +0100)]
jit: Initialize function::m_blocks in ctor
This resolves the problem reported here:
https://mail.gnu.org/archive/html/bug-gnu-emacs/2021-11/msg00606.html
https://bugzilla.opensuse.org/show_bug.cgi?id=1192951
gcc/jit/ChangeLog:
* jit-playback.c (function): Initialize m_blocks vector.
Tobias Burnus [Wed, 24 Nov 2021 10:08:40 +0000 (11:08 +0100)]
Update GMP/MPFR/MPC/ISL version in contrib/download_prerequisites
contrib/
* download_prerequisites: Update to gmp-6.2.1, mpfr-4.1.0,
mpc-1.2.1 and isl-0.24.
* prerequisites.md5: Update hash.
* prerequisites.sha512: Likewise.
Richard Biener [Mon, 15 Nov 2021 11:13:40 +0000 (12:13 +0100)]
middle-end/103193 - avoid canonicalizing <= and >= to == for floats
This avoids doing aforementioned canoncalization when -ftrapping-math
is in effect and we honor NaNs.
2021-11-15 Richard Biener <rguenther@suse.de>
PR middle-end/103193
* match.pd: Avoid canonicalizing (le/ge @0 @0) to (eq @0 @0)
with NaNs and -ftrapping-math.
Jakub Jelinek [Wed, 24 Nov 2021 09:30:32 +0000 (10:30 +0100)]
openmp: Fix up handling of kind(host) and kind(nohost) in ACCEL_COMPILERs [PR103384]
As the testcase shows, we weren't handling kind(host) and kind(nohost) properly
in the ACCEL_COMPILERs, the code written in there is valid for the host
compiler only, where if we are maybe offloaded, we defer resolution after IPA,
otherwise return 0 for kind(nohost) and accept it for kind(host). Note,
omp_maybe_offloaded is false after IPA. If ACCEL_COMPILER is defined, it is
the other way around, but also we know we are after IPA.
2021-11-24 Jakub Jelinek <jakub@redhat.com>
PR middle-end/103384
gcc/
* omp-general.c (omp_context_selector_matches): For ACCEL_COMPILER,
return 0 for kind(host) and continue for kind(nohost).
libgomp/
* testsuite/libgomp.c/declare-variant-2.c: New test.
Jakub Jelinek [Wed, 24 Nov 2021 09:08:35 +0000 (10:08 +0100)]
attribs: Fix ICEs on attributes starting with _ [PR103365]
As the patch shows, we have quite a few asserts that we don't call
lookup_attribute etc. with attr_name that starts with an underscore,
to make sure nobody is trying to call it with non-canonicalized
attribute name like "__cold__" instead of "cold".
We canonicalize only attributes that start with 2 underscores and end
with 2 underscores though.
Before Marek's patch, that wasn't an issue, we had no attributes like
"_foo" or "__bar_" etc., so lookup_scoped_attribute_spec would
always return NULL for those and we wouldn't try to register them,
look them up etc., just with -Wattributes would warn about them.
But now, as the new testcases show, users can actually request such
attributes to be ignored, and we ICE for those during
register_scoped_attribute and when that is fixed, ICE later on when
somebody uses those attributes because they will be looked up
to find out that they should be ignored.
So, the following patch instead of or in addition to, depending on
how performance sensitive a particular spot is, checking that
attribute doesn't start with underscore allows attribute
names that start with underscore as long as it doesn't canonicalize
(i.e. doesn't start and end with 2 underscores).
In addition to that, I've noticed lookup_attribute_by_prefix
was calling get_attribute_name twice unnecessarily, and 2 tests
were running in c++98 mode with -std=c++98 -std=c++11 which IMHO
isn't useful because -std=c++11 testing is done too when testing
all language versions.
2021-11-24 Jakub Jelinek <jakub@redhat.com>
PR middle-end/103365
* attribs.h (lookup_attribute): Allow attr_name to start with
underscore, as long as canonicalize_attr_name returns false.
(lookup_attribute_by_prefix): Don't call get_attribute_name twice.
* attribs.c (extract_attribute_substring): Reimplement using
canonicalize_attr_name.
(register_scoped_attribute): Change gcc_assert into
gcc_checking_assert, verify !canonicalize_attr_name rather than
that str.str doesn't start with '_'.
* c-c++-common/Wno-attributes-1.c: Require effective target
c || c++11 and drop dg-additional-options.
* c-c++-common/Wno-attributes-2.c: Likewise.
* c-c++-common/Wno-attributes-4.c: New test.
* c-c++-common/Wno-attributes-5.c: New test.
Jakub Jelinek [Wed, 24 Nov 2021 08:54:44 +0000 (09:54 +0100)]
bswap: Fix up symbolic merging for xor and plus [PR103376]
On Mon, Nov 22, 2021 at 08:39:42AM -0000, Roger Sayle wrote:
> This patch implements PR tree-optimization/103345 to merge adjacent
> loads when combined with addition or bitwise xor. The current code
> in gimple-ssa-store-merging.c's find_bswap_or_nop alreay handles ior,
> so that all that's required is to treat PLUS_EXPR and BIT_XOR_EXPR in
> the same way at BIT_IOR_EXPR.
Unfortunately they aren't exactly the same. They work the same if always
at least one operand (or corresponding byte in it) is known to be 0,
0 | 0 = 0 ^ 0 = 0 + 0 = 0. But for | also x | x = x for any other x,
so perform_symbolic_merge has been accepting either that at least one
of the bytes is 0 or that both are the same, but that is wrong for ^
and +.
The following patch fixes that by passing through the code of binary
operation and allowing non-zero masked1 == masked2 through only
for BIT_IOR_EXPR.
Thinking more about it, perhaps we could do more for BIT_XOR_EXPR.
We could allow masked1 == masked2 case for it, but would need to
do something different than the
n->n = n1->n | n2->n;
we do on all the bytes together.
In particular, for masked1 == masked2 if masked1 != 0 (well, for 0
both variants are the same) and masked1 != 0xff we would need to
clear corresponding n->n byte instead of setting it to the input
as x ^ x = 0 (but if we don't know what x and y are, the result is
also don't know). Now, for plus it is much harder, because not only
for non-zero operands we don't know what the result is, but it can
modify upper bytes as well. So perhaps only if current's byte
masked1 && masked2 set the resulting byte to 0xff (unknown) iff
the byte above it is 0 and 0, and set that resulting byte to 0xff too.
Also, even for | we could instead of return NULL just set the resulting
byte to 0xff if it is different, perhaps it will be masked off later on.
2021-11-24 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/103376
* gimple-ssa-store-merging.c (perform_symbolic_merge): Add CODE
argument. If CODE is not BIT_IOR_EXPR, ensure that one of masked1
or masked2 is 0.
(find_bswap_or_nop_1, find_bswap_or_nop,
imm_store_chain_info::try_coalesce_bswap): Adjust
perform_symbolic_merge callers.
* gcc.c-torture/execute/pr103376.c: New test.
Richard Biener [Tue, 23 Nov 2021 12:51:10 +0000 (13:51 +0100)]
Avoid redundant get_loop_body calls in IVOPTs
This removes redundant get_loop_body calls in IVOPTs by passing
around the body we're gathering early.
2021-11-23 Richard Biener <rguenther@suse.de>
* tree-ssa-loop-ivopts.c (find_givs): Take loop body as
argument instead of re-computing it.
(find_interesting_uses): Likewise.
(find_induction_variables): Pass through loop body.
(tree_ssa_iv_optimize_loop): Pass down loop body.
Tamar Christina [Wed, 24 Nov 2021 06:39:05 +0000 (06:39 +0000)]
middle-end: Fix failures with bitclear patterns on signed values
During testing after rebasing to commit I noticed a failing testcase with the
bitmask compare patch.
Consider the following C++ testcase:
#include <compare>
#define A __attribute__((noipa))
A bool f5 (double i, double j) { auto c = i <=> j; return c >= 0; }
This turns into a comparison against chars, on systems where chars are signed
the pattern inserts an unsigned convert such that it's able to do the
transformation.
i.e.:
# RANGE [-1, 2]
# c$_M_value_22 = PHI <-1(3), 0(2), 2(5), 1(4)>
# RANGE ~[3, 254]
_11 = (unsigned char) c$_M_value_22;
_19 = _11 <= 1;
# .MEM_24 = VDEF <.MEM_6(D)>
D.10434 ={v} {CLOBBER};
# .MEM_14 = VDEF <.MEM_24>
D.10407 ={v} {CLOBBER};
# VUSE <.MEM_14>
return _19;
instead of:
# RANGE [-1, 2]
# c$_M_value_5 = PHI <-1(3), 0(2), 2(5), 1(4)>
# RANGE [-2, 2]
_3 = c$_M_value_5 & -2;
_19 = _3 == 0;
# .MEM_24 = VDEF <.MEM_6(D)>
D.10440 ={v} {CLOBBER};
# .MEM_14 = VDEF <.MEM_24>
D.10413 ={v} {CLOBBER};
# VUSE <.MEM_14>
return _19;
This causes much worse codegen under -ffast-math due to phiops no longer
recognizing the pattern. It turns out that phiopts spaceship_replacement is
looking for the exact form that was just changed.
The comments seems to suggest this code only checks for (res & ~1) == 0 but the
implementation seems to suggest it's broader.
As such I added a case to check to see if the value comparison we found is a
type cast. and strips away the type cast and continues.
In match.pd the typecasts are only added for signed comparisons to == 0 and != 0
which are then rewritten into comparisons with 1.
As such I only check for 1 and LE and GT, which is what match.pd would have
rewritten it to.
This fixes the regression but this is not code I 100% understand, since I don't
really know the semantics of the spaceship operator so would appreciate an extra
look.
gcc/ChangeLog:
* tree-ssa-phiopt.c (spaceship_replacement): Handle new canonical
codegen.