Jiufu Guo [Thu, 4 Nov 2021 06:47:52 +0000 (14:47 +0800)]
Update dg-require-effective-target for pr101145 cases
For test cases pr101145*.c, some types are not able to be
vectorized on some targets. This patch updates
dg-require-effective-target according to test cases.
Vector lane indices follow memory (array) order, so lane 0 corresponds
to the high element rather than the low element on big-endian targets.
This was causing quite a few execution failures on aarch64_be,
such as gcc.c-torture/execute/pr47538.c.
gcc/
* simplify-rtx.c (simplify_context::simplify_gen_vec_select): Assert
that the operand has a vector mode. Use subreg_lowpart_offset
to test whether an index corresponds to the low part.
gcc/testsuite/
* gcc.dg/rtl/aarch64/big-endian-cse-1.c: New test.
The RTL frontend makes sure that CONST_INTs use shared rtxes where
appropriate. We should do the same thing for CONST_VECTORs,
reusing CONST0_RTX, CONST1_RTX and CONSTM1_RTX. This also has
the effect of setting CONST_VECTOR_NELTS_PER_PATTERN and
CONST_VECTOR_NPATTERNS.
While looking at where to add that, I noticed we had some dead #includes
in read-rtl.c. Some of the stuff that read-rtl-function.c does was once
in that file instead.
liuhongt [Wed, 3 Nov 2021 08:32:22 +0000 (16:32 +0800)]
Extend vternlog define_insn_and_split to memory_operand to enable more optimziation.
gcc/ChangeLog:
PR target/101989
* config/i386/predicates.md (reg_or_notreg_operand): Rename to ..
(regmem_or_bitnot_regmem_operand): .. and extend to handle
memory_operand.
* config/i386/sse.md (*<avx512>_vpternlog<mode>_1): Force_reg
the operands which are required to be register_operand.
(*<avx512>_vpternlog<mode>_2): Ditto.
(*<avx512>_vpternlog<mode>_3): Ditto.
(*<avx512>_vternlog<mode>_all): Disallow embeded broadcast for
vector HFmodes since it's not a real AVX512FP16 instruction.
liuhongt [Wed, 3 Nov 2021 08:07:34 +0000 (16:07 +0800)]
Simplify (trunc)copysign((extend)a, (extend)b) to .COPYSIGN (a,b).
a and b are same type as the truncation type and has less precision
than extend type.
gcc/ChangeLog:
PR target/102464
* match.pd: simplify (trunc)copysign((extend)a, (extend)b) to
.COPYSIGN (a,b) when a and b are same type as the truncation
type and has less precision than extend type.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr102464-copysign-1.c: New test.
Hongyu Wang [Tue, 26 Oct 2021 05:07:31 +0000 (13:07 +0800)]
i386: Auto vectorize sdot_prod, usdot_prod with VNNI instruction.
AVX512VNNI/AVXVNNI has vpdpwssd for HImode, vpdpbusd for QImode, so
Adjust HImode sdot_prod expander and add QImode usdot_prod expander
to enhance vectorization for dotprod.
gcc/ChangeLog:
* config/i386/sse.md (VI2_AVX512VNNIBW): New mode iterator.
(VI1_AVX512VNNI): Likewise.
(SDOT_VPDP_SUF): New mode_attr.
(VI1SI): Likewise.
(vi1si): Likewise.
(sdot_prod<mode>): Use VI2_AVX512F iterator, expand to
vpdpwssd when VNNI targets available.
(usdot_prod<mode>): New expander for vector QImode.
gcc/testsuite/ChangeLog:
* gcc.target/i386/vnni-auto-vectorize-1.c: New test.
* gcc.target/i386/vnni-auto-vectorize-2.c: Ditto.
Hongyu Wang [Wed, 3 Nov 2021 05:58:52 +0000 (13:58 +0800)]
i386: Fix wrong result for AMX-TILE intrinsic when parsing expression.
_tile_loadd, _tile_stored, _tile_streamloadd intrinsics are defined by
macro, so the parameters should be wrapped by parentheses to accept
expressions.
gcc/ChangeLog:
* config/i386/amxtileintrin.h (_tile_loadd_internal): Add
parentheses to base and stride.
(_tile_stream_loadd_internal): Likewise.
(_tile_stored_internal): Likewise.
gcc/testsuite/ChangeLog:
* gcc.target/i386/amxtile-3.c: New test.
RISC-V: Fix register class subset checks for CLASS_MAX_NREGS
Fix the register class subset checks in the determination of the maximum
number of consecutive registers needed to hold a value of a given mode.
The number depends on whether a register is a general-purpose or a
floating-point register, so check whether the register class requested
is a subset (argument 1 to `reg_class_subset_p') rather than superset
(argument 2) of GR_REGS or FP_REGS class respectively.
gcc/
* config/riscv/riscv.c (riscv_class_max_nregs): Swap the
arguments to `reg_class_subset_p'.
Joseph Myers [Wed, 3 Nov 2021 14:58:25 +0000 (14:58 +0000)]
c: Fold implicit integer-to-floating conversions in static initializers with -frounding-math [PR103031]
Recent fixes to avoid inappropriate folding of some conversions to
floating-point types with -frounding-math also prevented such folding
in C static initializers, when folding (in the default rounding mode,
exceptions discarded) is required for correctness.
Folding for static initializers is handled via functions in
fold-const.c calling START_FOLD_INIT and END_FOLD_INIT to adjust flags
such as flag_rounding_math that should not apply in static initializer
context, but no such function was being called for the folding of
these implicit conversions to the type of the object being
initialized, only for explicit conversions as part of the initializer.
Arrange for relevant folding (a fold call in convert, in particular)
to use this special initializer handling (via a new fold_init
function, in particular).
Because convert is used by language-independent code but defined in
each front end, this isn't as simple as just adding a new default
argument to it. Instead, I added a new convert_init function; that
then gets called by c-family code, and C and C++ need convert_init
implementations (the C++ one does nothing different from convert and
will never actually get called because the new convert_and_check
argument will never be true from C++), but other languages don't.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/
PR c/103031
* fold-const.c (fold_init): New function.
* fold-const.h (fold_init): New prototype.
gcc/c/
PR c/103031
* c-convert.c (c_convert): New function, based on convert.
(convert): Make into wrapper of c_convert.
(convert_init): New function.
* c-typeck.c (enum impl_conv): Add ic_init_const.
(convert_for_assignment): Handle ic_init_const like ic_init. Add
new argument to convert_and_check call.
(digest_init): Pass ic_init_const to convert_for_assignment for
initializers required to be constant.
gcc/cp/
PR c/103031
* cvt.c (convert_init): New function.
gcc/testsuite/
PR c/103031
* gcc.dg/init-rounding-math-1.c: New test.
Andrew MacLeod [Tue, 2 Nov 2021 13:46:53 +0000 (09:46 -0400)]
For ranges, PHIs don't need to process arg == def.
If an argument of a phi is the same as the DEF of the phi, then the range
on the incoming edge doesn't need to be taken into account since it can't
be anything other than itself.
* gimple-range-fold.cc (fold_using_range::range_of_phi): Don't import
a range from edge if arg == phidef.
Andrew MacLeod [Mon, 1 Nov 2021 20:20:59 +0000 (16:20 -0400)]
Check for constant builtin value first.
The original code imported from EVRP for evaluating built_in_constant_p
didn't check to see if the value was a constant before checking the
inlining flag. Now we check for a constant first.
* gimple-range-fold.cc (fold_using_range::range_of_builtin_call): Test
for constant before any other processing.
Andrew MacLeod [Mon, 1 Nov 2021 17:32:11 +0000 (13:32 -0400)]
Provide some context to folding via ranger.
Provide an internal mechanism to supply context to range_of_expr for calls
to ::fold_stmt.
* gimple-range.cc (gimple_ranger::gimple_ranger): Initialize current_bb.
(gimple_ranger::range_of_expr): Pick up range_on_entry when there is
no explcit context and current_bb is set.
(gimple_ranger::fold_stmt): New.
* gimple-range.h (current_bb, fold_stmt): New.
* tree-vrp.c (rvrp_folder::fold_stmt): Call ranger's fold_stmt.
Richard Biener [Wed, 3 Nov 2021 12:26:48 +0000 (13:26 +0100)]
tree-optimization/102970 - remap cliques when translating over backedges
The following makes sure to remap (or rather drop for simplicity)
dependence info encoded in MR_DEPENDENCE_CLIQUE when PRE PHI translation
translates a reference over a backedge since that ends up interleaving
two different loop iterations which boils down to two different
inline copies.
2021-11-03 Richard Biener <rguenther@suse.de>
PR tree-optimization/102970
* tree-ssa-pre.c (phi_translate_1): Drop clique and base
when translating a MEM_REF over a backedge.
Philipp Tomsich [Thu, 20 May 2021 19:57:48 +0000 (21:57 +0200)]
aarch64: enable Ampere-1 CPU
This adds support and a basic turning model for the Ampere Computing
"Ampere-1" CPU.
The Ampere-1 implements the ARMv8.6 architecture in A64 mode and is
modelled as a 4-wide issue (as with all modern micro-architectures,
the chosen issue rate is a compromise between the maximum dispatch
rate and the maximum rate of uops issued to the scheduler).
This adds the -mcpu=ampere1 command-line option and the relevant cost
information/tuning tables for the Ampere-1.
gcc/ChangeLog:
* config/aarch64/aarch64-cores.def (AARCH64_CORE): New Ampere-1 core.
* config/aarch64/aarch64-tune.md: Regenerate.
* config/aarch64/aarch64-cost-tables.h: Add extra costs for Ampere-1.
* config/aarch64/aarch64.c: Add tuning structures for Ampere-1.
* doc/invoke.texi: Add documentation for Ampere-1 core.
Wilco Dijkstra [Wed, 3 Nov 2021 12:51:41 +0000 (12:51 +0000)]
AArch64: Improve GOT addressing
Improve GOT addressing by treating the instructions as a pair. This reduces
register pressure and improves code quality significantly. SPECINT2017
improves by 0.6% with -fPIC and codesize is 0.73% smaller. Perlbench has
0.9% smaller codesize, 1.5% fewer executed instructions and is 1.8% faster
on Neoverse N1.
Richard Biener [Wed, 3 Nov 2021 08:57:21 +0000 (09:57 +0100)]
Make sbitmap bitmap_set_bit and bitmap_clear_bit return changed state
The following adjusts the sbitmap bitmap_set_bit and bitmap_clear_bit
APIs to match that of bitmap by returning a bool indicating whether
the bitmap was changed. I've also changed bitmap_bit_p to return
a bool rather than an int and made use of the sbitmap bitmap_set_bit
API change in one place.
2021-11-03 Richard Biener <rguenther@suse.de>
* bitmap.h (bitmap_bit_p): Change the return type to bool.
* bitmap.c (bitmap_bit_p): Likewise.
* sbitmap.h (bitmap_bit_p): Likewise.
(bitmap_set_bit): Return whether the bit changed.
(bitmap_clear_bit): Likewise.
* tree-ssa.c (verify_vssa): Make use of the changed state
from bitmap_set_bit.
Richard Biener [Wed, 3 Nov 2021 10:10:19 +0000 (11:10 +0100)]
middle-end/103033 - drop native_interpret_expr with .DEFERRED_INIT expansion
This drops the use of native_interpret_expr which can fail even though
can_native_interpret_expr_p returns true in favor of simply folding
the VIEW_CONVERT_EXPR punning.
2021-11-03 Richard Biener <rguenther@suse.de>
PR middle-end/103033
* internal-fn.c (expand_DEFERRED_INIT): Elide the
native_interpret_expr path in favor of folding the
VIEW_CONVERT_EXPR generated when punning the RHS.
Jan Hubicka [Wed, 3 Nov 2021 00:45:47 +0000 (01:45 +0100)]
Fix wrong code caulsed by retslot EAF flags propagation [PR103040]
Fixe (quite nasty) thinko in how I propagate EAF flags from callee
to caller. In this case some flags needs to be changed. In particular
- EAF_NOT_RETURNED in callee does not really mean EAF_NOT_RETURNED in caller
since we speak of different return values
- if callee escapes the parametr, we caller may return it
- for retslot the rewritting is even bit more funny, since escaping to of
return slot to return slot is not really an escape, however escape of
argument to itself is.
This patch should correct all of the cases above and does fix the testcase from PR103040.
Bootstrapped/regtested x86_64 with all languages. Also lto-bootstrapped.
gcc/ChangeLog:
PR ipa/103040
* ipa-modref.c (callee_to_caller_flags): New function.
(modref_eaf_analysis::analyze_ssa_name): Use it.
(ipa_merge_modref_summary_after_inlining): Fix whitespace.
Roger Sayle [Tue, 2 Nov 2021 21:58:32 +0000 (21:58 +0000)]
x86_64: Improved implementation of TImode rotations.
This simple patch improves the implementation of 128-bit (TImode)
rotations on x86_64 (a missed optimization opportunity spotted
during the recent V1TImode improvements).
with this patch, GCC will now generate the much nicer:
rotrti3:
movl %edx, %ecx
movq %rdi, %rdx
shrdq %rsi, %rdx
shrdq %rdi, %rsi
andl $64, %ecx
movq %rdx, %rax
cmove %rsi, %rdx
cmovne %rsi, %rax
ret
Even I wasn't expecting the optimizer's choice of the final three
instructions; a thing of beauty. For rotations larger than 64,
the lowpart and the highpart (%rax and %rdx) are transposed, and
it would be nice to have a conditional swap/exchange. The inspired
solution the compiler comes up with is to store/duplicate the same
value in both %rax/%rdx, and then use complementary conditional moves
to either update the lowpart or highpart, which cleverly avoids the
potential decode-stage pipeline stall (on some microarchitectures)
from having multiple instructions conditional on the same condition.
See X86_TUNE_ONE_IF_CONV_INSN, and notice there are two such stalls
in the original expansion of rot[rl]ti3.
2021-11-02 Roger Sayle <roger@nextmovesoftware.com>
Uroš Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (<any_rotate>ti3): Provide expansion for
rotations by non-constant amounts.
Jan Hubicka [Tue, 2 Nov 2021 21:08:56 +0000 (22:08 +0100)]
ipa-modref cleanup
A small refactoring of ipa-modref to make it bit more
C++y by moving logic analyzing ssa name flags to a class
and I also moved the anonymous namespace markers so we do not
export unnecessary stuff. There are no functional changes.
Bootstrapped/regtested x86_64-linux, will commit it shortly.
gcc/ChangeLog:
* ipa-modref.c: Fix anonymous namespace placement.
(class modref_eaf_analysis): New class.
(analyze_ssa_name_flags): Turn to ...
(modref_eaf_analysis::analyze_ssa_name): ... this one.
(merge_call_lhs_flags): Turn to ...
(modref_eaf_analysis::merge_call_lhs_flags): .. this one
(modref_eaf_analysis::merge_with_ssa_name): New member function.
(record_escape_points): Turn to ...
(modref_eaf_analysis::record_escape_points): ... this one.
(analyze_parms): Updat
(ipa_merge_modref_summary_after_inlining): Move to the end of file.
Jan Hubicka [Tue, 2 Nov 2021 17:57:51 +0000 (18:57 +0100)]
Static chain support in ipa-modref
Teach ipa-modref about the static chain that is, like
retslot, a hiden argument. The patch is pretty much symemtric to what
was done for retslot handling and I verified it does the intended job
for Ada LTO bootstrap.
Richard Biener [Tue, 2 Nov 2021 17:47:14 +0000 (18:47 +0100)]
tree-optimization/103029 - ensure vect loop versioning constraint on PHIs
PHI nodes in vectorizer loop versioning need to maintain the same
order of PHI arguments to not disturb SLP discovery. The following
adds an assertion and mitigation in case loop versioning breaks this
which happens more often after the recent reorg.
2021-11-02 Richard Biener <rguenther@suse.de>
PR tree-optimization/103029
* tree-vect-loop-manip.c (vect_loop_versioning): Ensure
the PHI nodes in the loop maintain their original operand
order.
Jan Hubicka [Tue, 2 Nov 2021 17:43:17 +0000 (18:43 +0100)]
addS EAF_NOT_RETURNED_DIRECTLY
addS EAF_NOT_RETURNED_DIRECTLY which works similarly as
EAF_NODIRECTESCAPE. Values pointed to by a given argument may be returned but
not the argument itself. This helps PTA quite noticeably because we mostly
care about tracking points to which given memory location can escape.
IBM Z: ldist-{rawmemchr,strlen} tests require vector extensions
The tests require vector extensions which are only available for z13 and
later while using the z/Architecture.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/ldist-rawmemchr-1.c: For IBM Z set arch to z13
and use z/Architecture since the tests require vector extensions.
* gcc.dg/tree-ssa/ldist-rawmemchr-2.c: Likewise.
* gcc.dg/tree-ssa/ldist-strlen-1.c: Likewise.
* gcc.dg/tree-ssa/ldist-strlen-3.c: Likewise.
Richard Biener [Tue, 2 Nov 2021 08:58:00 +0000 (09:58 +0100)]
middle-end/103038 - avoid ICE with -ftrivial-auto-var-init=pattern
This avoids ICEing with expanding a VIEW_CONVERT_EXRP of a SSA name
on the LHS by making sure we can native-interpret OFFSET_TYPE and
by never building such a LHS but instead view-converting the RHS
for SSA LHS.
2021-11-02 Richard Biener <rguenther@suse.de>
PR middle-end/103038
* fold-const.c (native_interpret_expr): Handle OFFSET_TYPE.
(can_native_interpret_type_p): Likewise.
* internal-fn.c (expand_DEFERRED_INIT): View-convert the
RHS if the LHS is an SSA name.
This patch adds a lang hook for defining a struct/RECORD_TYPE
“as if” it had appeared directly in the source code. It follows
the similar existing hook for enums.
It's the caller's responsibility to create the fields
(as FIELD_DECLs) but the hook's responsibility to create
and declare the associated RECORD_TYPE.
For now the hook is hard-coded to do the equivalent of:
typedef struct NAME { FIELDS } NAME;
but this could be controlled by an extra parameter if some callers
want a different behaviour in future.
The motivating use case is to allow the long list of struct
definitions in arm_neon.h to be provided by the compiler,
which in turn unblocks various arm_neon.h optimisations.
gcc/
* langhooks.h (lang_hooks_for_types::simulate_record_decl): New hook.
* langhooks-def.h (lhd_simulate_record_decl): Declare.
(LANG_HOOKS_SIMULATE_RECORD_DECL): Define.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Include it.
* langhooks.c (lhd_simulate_record_decl): New function.
Jakub Jelinek [Tue, 2 Nov 2021 08:44:24 +0000 (09:44 +0100)]
ia32: Disallow mode(V1TI) [PR103020]
As discussed in the PR, TImode isn't supported for -m32 on x86 (for the same
reason as on most 32-bit targets, no support for > 2 * BITS_PER_WORD
precision integers), but since PR32280 V1TImode is allowed with -msse in SSE
regs, V2TImode with -mavx or V4TImode with -mavx512f.
typedef __int128 V __attribute__((vector_size ({16,32,64}));
will not work, neither typedef int I __attribute__((mode(TI)));
but mode(V1TI), mode(V2TI) etc. are accepted with a warning when those
ISAs are enabled. But they are certainly not fully supported, for some
optabs maybe, but most of them will not. And, veclower lowering those ops
to TImode scalar operations will not work either because TImode isn't
supported.
So, this patch keeps V1TImode etc. in VALID*_MODE macros so that we can use
it in certain instructions, but disallows it in
targetm.vector_mode_supported_p, so that we don't offer those modes to the
user as supported.
2021-11-02 Jakub Jelinek <jakub@redhat.com>
PR target/103020
* config/i386/i386.c (ix86_vector_mode_supported_p): Reject vector
modes with TImode inner mode if 32-bit.
Martin Liska [Fri, 15 Oct 2021 16:31:48 +0000 (18:31 +0200)]
Add TSVC tests.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/vect.exp: Include also tsvc sub-directory.
* gcc.dg/vect/tsvc/license.txt: New test.
* gcc.dg/vect/tsvc/tsvc.h: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s000.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s111.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1111.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1112.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1113.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1115.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1119.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s112.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s113.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s114.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s115.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s116.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1161.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s118.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s119.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s121.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1213.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s122.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1221.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s123.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1232.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s124.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1244.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s125.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1251.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s126.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s127.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1279.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s128.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1281.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s131.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s13110.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s132.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1351.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s141.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s1421.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s151.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s152.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s161.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s162.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s171.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s172.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s173.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s174.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s175.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s176.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s2101.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s2102.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s211.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s2111.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s212.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s221.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s222.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s2233.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s2244.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s2251.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s2275.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s231.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s232.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s233.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s235.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s241.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s242.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s243.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s244.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s251.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s252.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s253.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s254.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s255.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s256.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s257.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s258.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s261.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s271.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s2710.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s2711.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s2712.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s272.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s273.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s274.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s275.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s276.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s277.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s278.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s279.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s281.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s291.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s292.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s293.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s311.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s3110.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s3111.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s31111.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s3112.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s3113.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s312.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s313.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s314.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s315.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s316.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s317.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s318.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s319.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s321.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s322.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s323.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s3251.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s331.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s332.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s341.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s342.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s343.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s351.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s352.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s353.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s4112.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s4113.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s4114.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s4115.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s4116.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s4117.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s4121.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s421.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s422.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s423.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s424.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s431.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s441.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s442.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s443.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s451.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s452.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s453.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s471.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s481.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s482.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-s491.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-va.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vag.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vas.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vbor.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vdotr.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vif.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vpv.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vpvpv.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vpvts.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vpvtv.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vsumr.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vtv.c: New test.
* gcc.dg/vect/tsvc/vect-tsvc-vtvtv.c: New test.
liuhongt [Thu, 28 Oct 2021 06:28:29 +0000 (14:28 +0800)]
Adjust testcase for O2 vect.
Adjust code in check_vect_slp_store_usage to make it an exact
pattern match of the corresponding testcases.
These new target/xfail selectors are added as a temporary solution,
and should be removed after real issue is fixed for Wstringop-overflow.
Roger Sayle [Tue, 2 Nov 2021 08:23:04 +0000 (08:23 +0000)]
x86_64: Expand ashrv1ti (and PR target/102986)
This patch was originally intended to implement 128-bit arithmetic right
shifts by constants of vector registers (V1TImode), but while working on
it I discovered the (my) recent ICE on valid regression now known as
PR target/102986.
As diagnosed by Jakub, expanders for shifts are not allowed to fail, and
so any backend that provides a shift optab needs to handle variable amount
shifts as well as constant shifts [even though the middle-end knows how
to synthesize these for vector modes]. This constraint could be relaxed
in the middle-end, but it makes sense to fix this in my erroneous code.
The solution is to change the constraints on the recently added (and new)
shift expanders from SImode const_int_register to QImode general operand,
matching the TImode expanders' constraints, and then simply check for
!CONST_INT_P at the start of the ix86_expand_v1ti_* functions, converting
the operands from V1TImode to TImode, performing the TImode operation
and converting the result back to V1TImode.
One nice benefit of this strategy, is that it allows us to implement
Uros' recent suggestion, that we should be more efficiently converting
between these modes, avoiding the use of memory and using the same idiom
as LLVM or using pextrq/pinsrq where available. The new helper functions
ix86_expand_v1ti_to_ti and ix86_expand_ti_to_v1ti are sufficient to take
care of this. Interestingly partial support for this is already present,
but x86_64's generic tuning prefers memory transfers to avoid penalizing
microarchitectures with significant interunit delays. With these changes
we now generate both pextrq and pinsrq for -mtune=native.
The main body of the patch is to implement arithmetic right shift in
addition to the logical right shift and left shift implemented in the
previous patch. This expander provides no less than 13 different code
sequences, special casing the different constant shifts, including
variants taking advantage of TARGET_AVX2 and TARGET_SSE4_1. The code
is structured with the faster/shorter sequences and the start, and
the generic implementations at the end.
To test these changes there are several new test cases. sse2-v1ti-shift-2.c
is a compile-test designed to spot/catch PR target/102986 [for all shifts
and rotates by variable amounts], and sse2-v1ti-shift-3.c is an execution
test to confirm shifts/rotates by variable amounts produce the same results
for TImode and V1TImode. sse2-v1ti-ashiftrt-1.c is a (similar) execution
test to confirm arithmetic right shifts by different constants produce
identical results between TImode and V1TImode. sse2-v1ti-ashift-[23].c are
duplicates of this file as compilation tests specifying -mavx2 and -msse4.1
respectively to trigger all the paths through the new expander.
2021-11-02 Roger Sayle <roger@nextmovesoftware.com>
Jakub Jelinek <jakub@redhat.com>
gcc/ChangeLog
PR target/102986
* config/i386/i386-expand.c (ix86_expand_v1ti_to_ti,
ix86_expand_ti_to_v1ti): New helper functions.
(ix86_expand_v1ti_shift): Check if the amount operand is an
integer constant, and expand as a TImode shift if it isn't.
(ix86_expand_v1ti_rotate): Check if the amount operand is an
integer constant, and expand as a TImode rotate if it isn't.
(ix86_expand_v1ti_ashiftrt): New function to expand arithmetic
right shifts of V1TImode quantities.
* config/i386/i386-protos.h (ix86_expand_v1ti_ashift): Prototype.
* config/i386/sse.md (ashlv1ti3, lshrv1ti3): Change constraints
to QImode general_operand, and let the helper functions lower
shifts by non-constant operands, as TImode shifts. Make
conditional on TARGET_64BIT.
(ashrv1ti3): New expander calling ix86_expand_v1ti_ashiftrt.
(rotlv1ti3, rotrv1ti3): Change shift operand to QImode.
Make conditional on TARGET_64BIT.
gcc/testsuite/ChangeLog
PR target/102986
* gcc.target/i386/sse2-v1ti-ashiftrt-1.c: New test case.
* gcc.target/i386/sse2-v1ti-ashiftrt-2.c: New test case.
* gcc.target/i386/sse2-v1ti-ashiftrt-3.c: New test case.
* gcc.target/i386/sse2-v1ti-shift-2.c: New test case.
* gcc.target/i386/sse2-v1ti-shift-3.c: New test case.
IBM Z: Fix address of operands will never be NULL warnings
Since a recent enhancement of -Waddress a couple of warnings are emitted
and turned into errors during bootstrap:
gcc/config/s390/s390.md:12087:25: error: the address of 'operands' will never be NULL [-Werror=address]
12087 | "TARGET_HTM && operands != NULL
build/gencondmd.c:59:12: note: 'operands' declared here
59 | extern rtx operands[];
| ^~~~~~~~
Jakub Jelinek [Tue, 2 Nov 2021 08:13:07 +0000 (09:13 +0100)]
openmp: Add testcase for threadprivate random access class iterators
This adds a testcase for random access class iterators. The diagnostics
can be different between templates and non-templates, as for some
threadprivate vars finish_id_expression replaces them with call to their
corresponding wrapper, but I think it is not that big deal, we reject
it in either case.
Jonathan Wakely [Mon, 1 Nov 2021 12:27:43 +0000 (12:27 +0000)]
libstdc++: Missing constexpr for __gnu_debug::__valid_range etc
The new 25_algorithms/move/constexpr.cc test fails in debug mode,
because the debug assertions use the non-constexpr overloads in
<debug/stl_iterator.h>.
libstdc++-v3/ChangeLog:
* include/debug/stl_iterator.h (__valid_range): Add constexpr
for C++20. Qualify call to avoid ADL.
(__get_distance, __can_advance, __unsafe, __base): Likewise.
* testsuite/25_algorithms/move/constexpr.cc: Also check with
std::reverse_iterator arguments.
Jonathan Wakely [Mon, 1 Nov 2021 11:32:39 +0000 (11:32 +0000)]
libstdc++: Reorder constraints on std::span::span(Range&&) constructor.
In PR libstdc++/103013 Tim Song pointed out that we could reorder the
constraints of this constructor. That's worth doing just to reduce the
work the compiler has to do during overload resolution, even if it isn't
needed to make the code in the PR work.
Martin Liska [Mon, 25 Oct 2021 14:54:22 +0000 (16:54 +0200)]
Fix negative integer range for UInteger.
gcc/ChangeLog:
* opt-functions.awk: Add new sanity checking.
* optc-gen.awk: Add new argument to integer_range_info.
* params.opt: Update 2 params which have negative IntegerRange.
David Malcolm [Fri, 8 Oct 2021 14:53:42 +0000 (10:53 -0400)]
contrib: add unicode/utf8-dump.py
This script may be useful when debugging issues relating to Unicode
encoding (e.g. when investigating source files with bidirectional control
characters).
It dumps a UTF-8 file as a list of numbered lines (mimicking GCC's
diagnostic output format), interleaved with lines per character showing
the Unicode codepoints, the UTF-8 encoding bytes, the name of the
character, and, where printable, the characters themselves.
The lines are printed in logical order, which may help the reader to grok
the relationship between visual and logical ordering in bi-di files.
For example:
$ cat test.c
int གྷ;
const char *אבג = "ALEF-BET-GIMEL";
$ ./contrib/unicode/utf8-dump.py test.c
1 | int གྷ;
| U+0069 0x69 LATIN SMALL LETTER I i
| U+006E 0x6e LATIN SMALL LETTER N n
| U+0074 0x74 LATIN SMALL LETTER T t
| U+0020 0x20 SPACE (separator)
| U+0F43 0xe0 0xbd 0x83 TIBETAN LETTER GHA གྷ
| U+003B 0x3b SEMICOLON ;
| U+000A 0x0a LINE FEED (LF) (control character)
2 | const char *אבג = "ALEF-BET-GIMEL";
| U+0063 0x63 LATIN SMALL LETTER C c
| U+006F 0x6f LATIN SMALL LETTER O o
| U+006E 0x6e LATIN SMALL LETTER N n
| U+0073 0x73 LATIN SMALL LETTER S s
| U+0074 0x74 LATIN SMALL LETTER T t
| U+0020 0x20 SPACE (separator)
| U+0063 0x63 LATIN SMALL LETTER C c
| U+0068 0x68 LATIN SMALL LETTER H h
| U+0061 0x61 LATIN SMALL LETTER A a
| U+0072 0x72 LATIN SMALL LETTER R r
| U+0020 0x20 SPACE (separator)
| U+002A 0x2a ASTERISK *
| U+05D0 0xd7 0x90 HEBREW LETTER ALEF א
| U+05D1 0xd7 0x91 HEBREW LETTER BET ב
| U+05D2 0xd7 0x92 HEBREW LETTER GIMEL ג
| U+0020 0x20 SPACE (separator)
| U+003D 0x3d EQUALS SIGN =
| U+0020 0x20 SPACE (separator)
| U+0022 0x22 QUOTATION MARK "
| U+0041 0x41 LATIN CAPITAL LETTER A A
| U+004C 0x4c LATIN CAPITAL LETTER L L
| U+0045 0x45 LATIN CAPITAL LETTER E E
| U+0046 0x46 LATIN CAPITAL LETTER F F
| U+002D 0x2d HYPHEN-MINUS -
| U+0042 0x42 LATIN CAPITAL LETTER B B
| U+0045 0x45 LATIN CAPITAL LETTER E E
| U+0054 0x54 LATIN CAPITAL LETTER T T
| U+002D 0x2d HYPHEN-MINUS -
| U+0047 0x47 LATIN CAPITAL LETTER G G
| U+0049 0x49 LATIN CAPITAL LETTER I I
| U+004D 0x4d LATIN CAPITAL LETTER M M
| U+0045 0x45 LATIN CAPITAL LETTER E E
| U+004C 0x4c LATIN CAPITAL LETTER L L
| U+0022 0x22 QUOTATION MARK "
| U+003B 0x3b SEMICOLON ;
| U+000A 0x0a LINE FEED (LF) (control character)
Tested with Python 3.8
contrib/ChangeLog:
* unicode/utf8-dump.py: New file.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Do not add call to __builtin_clear_padding when a variable is a gimple
register or it might not have padding.
gcc/ChangeLog:
2021-11-01 qing zhao <qing.zhao@oracle.com>
* gimplify.c (gimplify_decl_expr): Do not add call to
__builtin_clear_padding when a variable is a gimple register
or it might not have padding.
(gimplify_init_constructor): Likewise.
Tamar Christina [Mon, 1 Nov 2021 13:49:46 +0000 (13:49 +0000)]
AArch64: Add better costing for vector constants and operations
This patch adds extended costing to cost the creation of constants and the
manipulation of constants. The default values provided are based on
architectural expectations and each cost models can be individually tweaked as
needed.
The changes in this patch covers:
* Construction of PARALLEL or CONST_VECTOR:
Adds better costing for vector of constants which is based on the constant
being created and the instruction that can be used to create it. i.e. a movi
is cheaper than a literal load etc.
* Construction of a vector through a vec_dup.
Tamar Christina [Mon, 1 Nov 2021 13:48:58 +0000 (13:48 +0000)]
middle-end: Teach CSE to be able to do vector extracts.
This patch gets CSE to re-use constants already inside a vector rather than
re-materializing the constant again.
Basically consider the following case:
#include <stdint.h>
#include <arm_neon.h>
uint64_t
test (uint64_t a, uint64x2_t b, uint64x2_t* rt)
{
uint64_t arr[2] = { 0x0942430810234076UL, 0x0942430810234076UL};
uint64_t res = a | arr[0];
uint64x2_t val = vld1q_u64 (arr);
*rt = vaddq_u64 (val, b);
return res;
}
The actual behavior is inconsequential however notice that the same constants
are used in the vector (arr and later val) and in the calculation of res.
The code we generate for this however is quite sub-optimal:
Essentially we materialize the same constant twice. The reason for this is
because the front-end lowers the constant extracted from arr[0] quite early on.
If you look into the result of fre you'll find
Which makes sense for further optimization. However come expand time if the
constant isn't representable in the target arch it will be assigned to a
register again.
And since it's out of the immediate range of the scalar instruction used
combine won't be able to do anything here.
This will then trigger the re-materialization of the constant twice.
To fix this this patch extends CSE to be able to generate an extract for a
constant from another vector, or to make a vector for a constant by duplicating
another constant.
Whether this transformation is done or not depends entirely on the costing for
the target for the different constants and operations.
I Initially also investigated doing this in PRE, but PRE requires at least 2 BB
to work and does not currently have any way to remove redundancies within a
single BB and it did not look easy to support.
gcc/ChangeLog:
* cse.c (add_to_set): New.
(find_sets_in_insn): Register constants in sets.
(canonicalize_insn): Use auto_vec instead.
(cse_insn): Try materializing using vec_dup.
* rtl.h (simplify_context::simplify_gen_vec_select,
simplify_gen_vec_select): New.
* simplify-rtx.c (simplify_context::simplify_gen_vec_select): New.
David Malcolm [Mon, 18 Oct 2021 22:55:31 +0000 (18:55 -0400)]
diagnostics: escape non-ASCII source bytes for certain diagnostics
This patch adds support to GCC's diagnostic subsystem for escaping certain
bytes and Unicode characters when quoting source code.
Specifically, this patch adds a new flag rich_location::m_escape_on_output
which is a hint from a diagnostic that non-ASCII bytes in the pertinent
lines of the user's source code should be escaped when printed.
The patch sets this for the following diagnostics:
- when complaining about stray bytes in the program (when these
are non-printable)
- when complaining about "null character(s) ignored");
- for -Wnormalized= (and generate source ranges for such warnings)
The escaping is controlled by a new option:
-fdiagnostics-escape-format=[unicode|bytes]
For example, consider a diagnostic involing a source line containing the
string "before" followed by the Unicode character U+03C0 ("GREEK SMALL
LETTER PI", with UTF-8 encoding 0xCF 0x80) followed by the byte 0xBF
(a stray UTF-8 trailing byte), followed by the string "after", where the
diagnostic highlights the U+03C0 character.
By default, this line will be printed verbatim to the user when
reporting a diagnostic at it, as:
beforeπXafter
^
(using X for the stray byte to avoid putting invalid UTF-8 in this
commit message)
If the diagnostic sets the "escape" flag, it will be printed as:
before<U+03C0><BF>after
^~~~~~~~
with -fdiagnostics-escape-format=unicode (the default), or as:
before<CF><80><BF>after
^~~~~~~~
if the user supplies -fdiagnostics-escape-format=bytes.
This only affects how the source is printed; it does not affect
how column numbers that are printed (as per -fdiagnostics-column-unit=
and -fdiagnostics-column-origin=).
gcc/c-family/ChangeLog:
* c-lex.c (c_lex_with_flags): When complaining about non-printable
CPP_OTHER tokens, set the "escape on output" flag.
gcc/ChangeLog:
* common.opt (fdiagnostics-escape-format=): New.
(diagnostics_escape_format): New enum.
(DIAGNOSTICS_ESCAPE_FORMAT_UNICODE): New enum value.
(DIAGNOSTICS_ESCAPE_FORMAT_BYTES): Likewise.
* diagnostic-format-json.cc (json_end_diagnostic): Add
"escape-source" attribute.
* diagnostic-show-locus.c
(exploc_with_display_col::exploc_with_display_col): Replace
"tabstop" param with a cpp_char_column_policy and add an "aspect"
param. Use these to compute m_display_col accordingly.
(struct char_display_policy): New struct.
(layout::m_policy): New field.
(layout::m_escape_on_output): New field.
(def_policy): New function.
(make_range): Update for changes to exploc_with_display_col ctor.
(default_print_decoded_ch): New.
(width_per_escaped_byte): New.
(escape_as_bytes_width): New.
(escape_as_bytes_print): New.
(escape_as_unicode_width): New.
(escape_as_unicode_print): New.
(make_policy): New.
(layout::layout): Initialize new fields. Update m_exploc ctor
call for above change to ctor.
(layout::maybe_add_location_range): Update for changes to
exploc_with_display_col ctor.
(layout::calculate_x_offset_display): Update for change to
cpp_display_width.
(layout::print_source_line): Pass policy
to cpp_display_width_computation. Capture cpp_decoded_char when
calling process_next_codepoint. Move printing of source code to
m_policy.m_print_cb.
(line_label::line_label): Pass in policy rather than context.
(layout::print_any_labels): Update for change to line_label ctor.
(get_affected_range): Pass in policy rather than context, updating
calls to location_compute_display_column accordingly.
(get_printed_columns): Likewise, also for cpp_display_width.
(correction::correction): Pass in policy rather than tabstop.
(correction::compute_display_cols): Pass m_policy rather than
m_tabstop to cpp_display_width.
(correction::m_tabstop): Replace with...
(correction::m_policy): ...this.
(line_corrections::line_corrections): Pass in policy rather than
context.
(line_corrections::m_context): Replace with...
(line_corrections::m_policy): ...this.
(line_corrections::add_hint): Update to use m_policy rather than
m_context.
(line_corrections::add_hint): Likewise.
(layout::print_trailing_fixits): Likewise.
(selftest::test_display_widths): New.
(selftest::test_layout_x_offset_display_utf8): Update to use
policy rather than tabstop.
(selftest::test_one_liner_labels_utf8): Add test of escaping
source lines.
(selftest::test_diagnostic_show_locus_one_liner_utf8): Update to
use policy rather than tabstop.
(selftest::test_overlapped_fixit_printing): Likewise.
(selftest::test_overlapped_fixit_printing_utf8): Likewise.
(selftest::test_overlapped_fixit_printing_2): Likewise.
(selftest::test_tab_expansion): Likewise.
(selftest::test_escaping_bytes_1): New.
(selftest::test_escaping_bytes_2): New.
(selftest::diagnostic_show_locus_c_tests): Call the new tests.
* diagnostic.c (diagnostic_initialize): Initialize
context->escape_format.
(convert_column_unit): Update to use default character width policy.
(selftest::test_diagnostic_get_location_text): Likewise.
* diagnostic.h (enum diagnostics_escape_format): New enum.
(diagnostic_context::escape_format): New field.
* doc/invoke.texi (-fdiagnostics-escape-format=): New option.
(-fdiagnostics-format=): Add "escape-source" attribute to examples
of JSON output, and document it.
* input.c (location_compute_display_column): Pass in "policy"
rather than "tabstop", passing to
cpp_byte_column_to_display_column.
(selftest::test_cpp_utf8): Update to use cpp_char_column_policy.
* input.h (class cpp_char_column_policy): New forward decl.
(location_compute_display_column): Pass in "policy" rather than
"tabstop".
* opts.c (common_handle_option): Handle
OPT_fdiagnostics_escape_format_.
* selftest.c (temp_source_file::temp_source_file): New ctor
overload taking a size_t.
* selftest.h (temp_source_file::temp_source_file): Likewise.
gcc/testsuite/ChangeLog:
* c-c++-common/diagnostic-format-json-1.c: Add regexp to consume
"escape-source" attribute.
* c-c++-common/diagnostic-format-json-2.c: Likewise.
* c-c++-common/diagnostic-format-json-3.c: Likewise.
* c-c++-common/diagnostic-format-json-4.c: Likewise, twice.
* c-c++-common/diagnostic-format-json-5.c: Likewise.
* gcc.dg/cpp/warn-normalized-4-bytes.c: New test.
* gcc.dg/cpp/warn-normalized-4-unicode.c: New test.
* gcc.dg/encoding-issues-bytes.c: New test.
* gcc.dg/encoding-issues-unicode.c: New test.
* gfortran.dg/diagnostic-format-json-1.F90: Add regexp to consume
"escape-source" attribute.
* gfortran.dg/diagnostic-format-json-2.F90: Likewise.
* gfortran.dg/diagnostic-format-json-3.F90: Likewise.
libcpp/ChangeLog:
* charset.c (convert_escape): Use encoding_rich_location when
complaining about nonprintable unknown escape sequences.
(cpp_display_width_computation::::cpp_display_width_computation):
Pass in policy rather than tabstop.
(cpp_display_width_computation::process_next_codepoint): Add "out"
param and populate *out if non-NULL.
(cpp_display_width_computation::advance_display_cols): Pass NULL
to process_next_codepoint.
(cpp_byte_column_to_display_column): Pass in policy rather than
tabstop. Pass NULL to process_next_codepoint.
(cpp_display_column_to_byte_column): Pass in policy rather than
tabstop.
* errors.c (cpp_diagnostic_get_current_location): New function,
splitting out the logic from...
(cpp_diagnostic): ...here.
(cpp_warning_at): New function.
(cpp_pedwarning_at): New function.
* include/cpplib.h (cpp_warning_at): New decl for rich_location.
(cpp_pedwarning_at): Likewise.
(struct cpp_decoded_char): New.
(struct cpp_char_column_policy): New.
(cpp_display_width_computation::cpp_display_width_computation):
Replace "tabstop" param with "policy".
(cpp_display_width_computation::process_next_codepoint): Add "out"
param.
(cpp_display_width_computation::m_tabstop): Replace with...
(cpp_display_width_computation::m_policy): ...this.
(cpp_byte_column_to_display_column): Replace "tabstop" param with
"policy".
(cpp_display_width): Likewise.
(cpp_display_column_to_byte_column): Likewise.
* include/line-map.h (rich_location::escape_on_output_p): New.
(rich_location::set_escape_on_output): New.
(rich_location::m_escape_on_output): New.
* internal.h (cpp_diagnostic_get_current_location): New decl.
(class encoding_rich_location): New.
* lex.c (skip_whitespace): Use encoding_rich_location when
complaining about null characters.
(warn_about_normalization): Generate a source range when
complaining about improperly normalized tokens, rather than just a
point, and use encoding_rich_location so that the source code
is escaped on printing.
* line-map.c (rich_location::rich_location): Initialize
m_escape_on_output.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Jonathan Wakely [Mon, 1 Nov 2021 11:06:51 +0000 (11:06 +0000)]
libstdc++: Fix range access for empty std::valarray [PR103022]
The std::begin and std::end overloads for std::valarray are defined in
terms of std::addressof(v[0]) which is undefined for an empty valarray.
libstdc++-v3/ChangeLog:
PR libstdc++/103022
* include/std/valarray (begin, end): Do not dereference an empty
valarray. Add noexcept and [[nodiscard]].
* testsuite/26_numerics/valarray/range_access.cc: Check empty
valarray. Check iterator properties. Run as well as compiling.
* testsuite/26_numerics/valarray/range_access2.cc: Likewise.
* testsuite/26_numerics/valarray/103022.cc: New test.
Aldy Hernandez [Fri, 29 Oct 2021 15:30:42 +0000 (17:30 +0200)]
Add debug counters to back threader.
Chasing down stage3 miscomparisons is never fun, and having no way to
distinguish between jump threads registered by a particular
pass, is even harder. This patch adds debug counters for the individual
back threading passes. I've left the ethread pass alone, as that one is
usually benign, but we could easily add it if needed.
The fact that we can only pass one boolean argument to the passes
infrastructure has us do all sorts of gymnastics to differentiate
between the various back threading passes.
Tested on x86-64 Linux.
gcc/ChangeLog:
* dbgcnt.def: Add debug counter for back_thread[12] and
back_threadfull[12].
* passes.def: Pass "first" argument to each back threading pass.
* tree-ssa-threadbackward.c (back_threader::back_threader): Add
first argument.
(back_threader::debug_counter): New.
(back_threader::maybe_register_path): Call debug_counter.
Aldy Hernandez [Fri, 29 Oct 2021 15:28:41 +0000 (17:28 +0200)]
Move statics to threader pass class.
This patch moves all the static functions into the pass class, and
cleans up things a little. The goal is to shuffle things around such
that we can add debug counters that depend on different threading
passes, but it's a clean-up on its own right.
Tested on x86-64 Linux.
gcc/ChangeLog:
* tree-ssa-threadbackward.c (BT_NONE): New.
(BT_SPEED): New.
(BT_RESOLVE): New.
(back_threader::back_threader): Add flags.
Move loop initialization here.
(back_threader::~back_threader): New.
(back_threader::find_taken_edge_switch): Change solver and ranger
to pointers.
(back_threader::find_taken_edge_cond): Same.
(back_threader::find_paths_to_names): Same.
(back_threader::find_paths): Same.
(back_threader::dump): Same.
(try_thread_blocks): Merge into thread_blocks.
(back_threader::thread_blocks): New.
(do_early_thread_jumps): Merge into thread_blocks.
(do_thread_jumps): Merge into thread_blocks.
(back_threader::thread_through_all_blocks): Remove.
Dan Li [Mon, 1 Nov 2021 11:04:12 +0000 (11:04 +0000)]
aarch64: Fix redundant check in aut insn generation
During the generation of the epilogue of aarch64(aarch64_expand_epilogue),
the value of crtl->calls_eh_return does not need to be checked again.
This value has been checked during aarch64_return_address_signing_enabled.
Xionghu Luo [Mon, 1 Nov 2021 05:12:36 +0000 (00:12 -0500)]
Refactor loop_version
loop_version currently does lv_adjust_loop_entry_edge
before it loopifys the copy inserted on the header. This patch moves
the condition generation later and thus we have four pieces to help
understanding of how the adjustment works:
1) duplicating the loop on the entry edge.
2) loopify the duplicated new loop.
3) adjusting the CFG to insert a condition branching to either loop
with lv_adjust_loop_entry_edge.
4) From loopify extract the scale_loop_frequencies bits.
Also removed some piece of code seems obviously useless:
- redirect_all_edges since it is false and loopify only called once.
- extract_cond_bb_edges and lv_flush_pending_stmts (false_edge) as the
edge is not redirected actually.
gcc/ChangeLog:
2021-11-01 Xionghu Luo <luoxhu@linux.ibm.com>
* cfgloopmanip.c (loop_version): Refactor loopify to
loop_version. Move condition generation after loopify.
(loopify): Delete.
* cfgloopmanip.h (loopify): Delete.
Jan Hubicka [Sun, 31 Oct 2021 22:14:29 +0000 (23:14 +0100)]
Improve handling of return slot in ipa-pure-const and modref.
while preparing testcase for return slot tracking I noticed that both
ipa-pure-const and modref treat return slot writes as non-local which prevents
detecting functions as pure or not modifying global state. Fixed by making
points_to_local_or_readonly_memory_p to special case return slot. This is bit
of a side case, but presently at all uses of
points_to_local_or_readonly_memory_p we want to handle return slot this way.
I also noticed that we handle gimple copy unnecesarily pesimistically. This
does not make difference right now since we do no not track non-scalars, but
I fixed it anyway.
Bootstrapped/regtested x86_64-linux, comitted.
gcc/ChangeLog:
* ipa-fnsummary.c: Include tree-dfa.h.
(points_to_local_or_readonly_memory_p): Return true on return
slot writes.
* ipa-modref.c (analyze_ssa_name_flags): Fix handling of copy
statement.
Iain Buclaw [Sun, 31 Oct 2021 17:07:16 +0000 (18:07 +0100)]
d: Fix regressing test failures on ix86-solaris2.11
The _Unwind_Exception struct had its alignment adjusted to 16-bytes,
however malloc() on Solaris X86 is not guaranteed to allocate memory
aligned to 16-bytes as well.
PR d/102837
libphobos/ChangeLog:
* libdruntime/gcc/deh.d (ExceptionHeader.free): Use memset to reset
contents of internal EH storage.
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.
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>
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.
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.
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.
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.
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.
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.
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?