Commit Graph

193911 Commits

Author SHA1 Message Date
Ian Lance Taylor
7905a9ac26 libgo: #include <sys/types.h> when checking for loff_t
PR go/106033

Fixes golang/go#53469

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413214
2022-06-21 08:03:17 -07:00
Nathan Sidwell
f1fcd6e3ad doc: Document module language-linkage supported
I missed we documented this as unimplemented, when I implemented it.

	gcc/
	* doc/invoke.texi (C++ Modules): Remove language-linkage
	as missing feature.
2022-06-21 06:25:03 -07:00
Arjun Shankar
ab981aab92 match.pd: Remove "+ 0x80000000" in int comparisons [PR94899]
Expressions of the form "X + CST < Y + CST" where:

* CST is an unsigned integer constant with only the MSB set, and
* X and Y's types have integer conversion ranks <= CST's

can be simplified to "(signed) X < (signed) Y".

This is because, assuming a 32-bit signed numbers,
(unsigned) INT_MIN + 0x80000000 is 0, and
(unsigned) INT_MAX + 0x80000000 is UINT_MAX.

i.e. the result increases monotonically with signed input.

This means:
((signed) X < (signed) Y) iff (X + 0x80000000 < Y + 0x80000000)

gcc/
	PR tree-optimization/94899
	* match.pd (X + C < Y + C -> (signed) X < (signed) Y, if C is
	0x80000000): New simplification.
gcc/testsuite/
	* gcc.dg/pr94899.c: New test.
2022-06-21 12:13:52 +02:00
Jakub Jelinek
a0c30fe3b8 ifcvt: Don't introduce trapping or faulting reads in noce_try_sign_mask [PR106032]
noce_try_sign_mask as documented will optimize
  if (c < 0)
    x = t;
  else
    x = 0;
into x = (c >> bitsm1) & t;
The optimization is done if either t is unconditional
(e.g. for
  x = t;
  if (c >= 0)
    x = 0;
) or if it is cheap.  We already check that t doesn't have side-effects,
but if t is conditional, we need to punt also if it may trap or fault,
as we make it unconditional.

I've briefly skimmed other noce_try* optimizations and didn't find one that
would suffer from the same problem.

2022-06-21  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/106032
	* ifcvt.cc (noce_try_sign_mask): Punt if !t_unconditional, and
	t may_trap_or_fault_p, even if it is cheap.

	* gcc.c-torture/execute/pr106032.c: New test.
2022-06-21 11:40:16 +02:00
Jakub Jelinek
2df1df945f expand: Fix up expand_cond_expr_using_cmove [PR106030]
If expand_cond_expr_using_cmove can't find a cmove optab for a particular
mode, it tries to promote the mode and perform the cmove in the promoted
mode.

The testcase in the patch ICEs on arm because in that case we pass temp which
has the promoted mode (SImode) as target to expand_operands where the
operands have the non-promoted mode (QImode).
Later on the function uses paradoxical subregs:
  if (GET_MODE (op1) != mode)
    op1 = gen_lowpart (mode, op1);

  if (GET_MODE (op2) != mode)
    op2 = gen_lowpart (mode, op2);
to change the operand modes.

The following patch fixes it by passing NULL_RTX as target if it has
promoted mode.

2022-06-21  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/106030
	* expr.cc (expand_cond_expr_using_cmove): Pass NULL_RTX instead of
	temp to expand_operands if mode has been promoted.

	* gcc.c-torture/compile/pr106030.c: New test.
2022-06-21 11:38:59 +02:00
Xionghu Luo
57424087e8 if-to-switch: Don't skip the first condition bb when find_conditions in if-to-switch [PR105740]
The if condition is at last of first bb, so side effect statement in first BB
doesn't matter, then the first if condition could also be folded to switch
table.

gcc/ChangeLog:

	PR target/105740
	* gimple-if-to-switch.cc (find_conditions): Don't skip the first
	condition bb.

gcc/testsuite/ChangeLog:

	PR target/105740
	* gcc.dg/tree-ssa/if-to-switch-11.c: New test.

Signed-off-by: Xionghu Luo <xionghuluo@tencent.com>
2022-06-21 17:26:45 +08:00
Siddhesh Poyarekar
70454c50b4 tree-object-size: Don't let error_mark_node escape for ADDR_EXPR [PR105736]
The addr_expr computation does not check for error_mark_node before
returning the size expression.  This used to work in the constant case
because the conversion to uhwi would end up causing it to return
size_unknown, but that won't work for the dynamic case.

Modify the control flow to explicitly return size_unknown if the offset
computation returns an error_mark_node.

gcc/ChangeLog:

	PR tree-optimization/105736
	* tree-object-size.cc (addr_object_size): Return size_unknown
	when object offset computation returns an error.

gcc/testsuite/ChangeLog:

	PR tree-optimization/105736
	* gcc.dg/builtin-dynamic-object-size-0.c (TV4): New struct.
	(val3): New variable.
	(test_pr105736): New test.
	(main): Call it.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2022-06-21 12:15:07 +05:30
GCC Administrator
d6ba321135 Daily bump. 2022-06-21 00:16:27 +00:00
Iain Sandoe
607118dfa4 testsuite, asan: Avoid color in asan test output.
The presence of the color markers in the some of the asan tests
appears to confuse the dg-output matching (possibly a platform
TCL or termios bug) on some Darwin platforms.

Since the color is not being tested, switch it off (makes the log
files easier to read too).  This fixes a large number of spurious
test fails on AVX512 Darwin19.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/testsuite/ChangeLog:

	* lib/asan-dg.exp: Do not apply color to asan output when
	under test.
2022-06-20 16:33:10 +01:00
H.J. Lu
fe9765c0b9 i386: Disallow sibcall for calling ifunc functions with PIC register
Disallow siball when calling ifunc functions with PIC register so that
PIC register can be restored.

gcc/

	PR target/105960
	* config/i386/i386.cc (ix86_function_ok_for_sibcall): Return
	false if PIC register is used when calling ifunc functions.

gcc/testsuite/

	PR target/105960
	* gcc.target/i386/pr105960.c: New test.
2022-06-20 08:26:47 -07:00
Iain Sandoe
1b23812484 testsuite, Darwin: Skip an unsupported test.
Darwin does not support patchable function entries, skip the test
there.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/pr105169_a.C: Skip the test on Darwin.
	* g++.dg/modules/pr105169_b.C: Likewise.
2022-06-20 16:23:49 +01:00
Iain Sandoe
125bf21299 testsuite, Darwin: Allow for two CTOR bodies in array61 test.
For targets without alias support, we emit two essentially identical function
bodies into the gimple (complete and base CTORs). So this test needs to allow
for that when the target does not support aliases.  The target support alias
test does not seem to be usable in the context of a single scan-tree-dump so
the fix here uses the target designation.

Note that the array has 10 elements, so that if the test were failing (because
we were emitting 10 inits instead of a loop) the count would be expected to
exceed 2, on Darwin and 1 where there's alias support.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/testsuite/ChangeLog:

	* g++.dg/init/array61.C: Allow for two CTOR bodies on Darwin, where
	aliases are not currently supported.
2022-06-20 16:21:03 +01:00
Richard Earnshaw
2eb3adb43e arm: more testsutie fallout for mve move-immediate changes
Unfortunately, there is more fall-out in the testsuite for my changes
to use MVE move-immediate operations instead of literal pool loads.
Fixed as follows:

gcc/testsuite/ChangeLog:
	* gcc.target/arm/simd/mve-vcmp-f32-2.c: Adjust expected output.
	* gcc.target/arm/simd/pr100757.c: Likewise.
	* gcc.target/arm/simd/pr100757-2.c: Likewise.
	* gcc.target/arm/simd/pr100757-3.c: Likewise.
	* gcc.target/arm/simd/pr100757-4.c: Likewise.
2022-06-20 16:19:40 +01:00
Iain Sandoe
a78e5d307c testsuite: Add a missing USER_LABEL_PREFIX to a regex.
Fixes this test on Darwin.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/testsuite/ChangeLog:

	* g++.dg/modules/init-2_b.C: Add a missing USER_LABEL_PREFIX
	to a regex.
2022-06-20 16:17:48 +01:00
Iain Sandoe
ab5d82c029 testsuite: Require init_priority target support in a test.
The attr-cdtor-1 test fails on targets without init priority since the
diagnostic emitted concerns the absence of support.  Disable the test
on such targets.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/testsuite/ChangeLog:

	* c-c++-common/attr-cdtor-1.c: Requite init_priority support.
2022-06-20 16:14:22 +01:00
Richard Biener
713f2fd923 middle-end/106027 - fix types in needle folding
The fold_to_nonsharp_ineq_using_bound folding ends up creating invalid
typed IL which confuses later foldings.  The following fixes that.

2022-06-20  Richard Biener  <rguenther@suse.de>

	PR middle-end/106027
	* fold-const.cc (fold_to_nonsharp_ineq_using_bound): Use the
	type of the prevailing comparison for the new comparison type.
	(fold_binary_loc): Use proper types for the A < X && A + 1 > Y
	to A < X && A >= Y folding.

	* gcc.dg/pr106027.c: New testcase.
2022-06-20 15:01:57 +02:00
Kewen Lin
86882d9feb vect: Respect slp decision when applying suggested uf [PR105940]
This follows Richi's suggestion in PR105940, it aims to avoid
inconsistent slp decision between when the suggested unroll
factor is worked out and when the suggested unroll factor is
applied.

If the previous slp decision is true when the suggested unroll
factor is worked out, when we are applying unroll factor we
don't need to start over with slp off if the analysis with slp
on fails.  On the other hand, if the previous slp decision is
false when the suggested unroll factor is worked out, when we
are applying unroll factor we can skip the slp handlings.

Function vect_is_simple_reduction saves reduction chains for
subsequent slp analyses, we have to disable this early otherwise
there is an ICE in vectorizable_reduction for below:

  if (REDUC_GROUP_FIRST_ELEMENT (stmt_info))
    gcc_assert (slp_node
		&& REDUC_GROUP_FIRST_ELEMENT (stmt_info)
		   == stmt_info);

	PR tree-optimization/105940

gcc/ChangeLog:

	* tree-vect-loop.cc (vect_analyze_loop_2): Add new parameter
	slp_done_for_suggested_uf and adjust with it accordingly.
	(vect_analyze_loop_1): Add new variable slp_done_for_suggested_uf,
	pass it down to vect_analyze_loop_2 for the initial analysis and
	applying suggested unroll factor.
	(vect_is_simple_reduction): Add parameter slp and adjust with it.
	(vect_analyze_scalar_cycles_1): Add parameter slp and pass down.
	(vect_analyze_scalar_cycles): Likewise.
2022-06-20 07:44:21 -05:00
Martin Liska
c56f7983be lto-plugin: support LDPT_GET_SYMBOLS_V3
That supports skipping of an object file (LDPS_NO_SYMS).

lto-plugin/ChangeLog:

	* lto-plugin.c (struct plugin_file_info): Add skip_file flag.
	(write_resolution): Write resolution only if get_symbols != LDPS_NO_SYMS.
	(all_symbols_read_handler): Ignore file if skip_file is true.
	(onload): Handle LDPT_GET_SYMBOLS_V3.
2022-06-20 11:27:34 +02:00
Martin Liska
9f55aee9dc Add operators / and * for profile_{count,probability}.
gcc/ChangeLog:

	* bb-reorder.cc (find_traces_1_round): Add operators / and * and
	use them.
	(better_edge_p): Likewise.
	* cfgloop.cc (find_subloop_latch_edge_by_profile): Likewise.
	* cfgloopmanip.cc (scale_loop_profile): Likewise.
	* cfgrtl.cc (force_nonfallthru_and_redirect): Likewise.
	* cgraph.cc (cgraph_edge::maybe_hot_p): Likewise.
	* config/sh/sh.cc (expand_cbranchdi4): Likewise.
	* dojump.cc (do_compare_rtx_and_jump): Likewise.
	* final.cc (compute_alignments): Likewise.
	* ipa-cp.cc (update_counts_for_self_gen_clones): Likewise.
	(decide_about_value): Likewise.
	* ipa-inline-analysis.cc (do_estimate_edge_time): Likewise.
	* loop-unroll.cc (unroll_loop_runtime_iterations): Likewise.
	* modulo-sched.cc (sms_schedule): Likewise.
	* omp-expand.cc (extract_omp_for_update_vars): Likewise.
	(expand_omp_ordered_sink): Likewise.
	(expand_omp_for_ordered_loops): Likewise.
	(expand_omp_for_static_nochunk): Likewise.
	* predict.cc (maybe_hot_count_p): Likewise.
	(probably_never_executed): Likewise.
	(set_even_probabilities): Likewise.
	(handle_missing_profiles): Likewise.
	(expensive_function_p): Likewise.
	* profile-count.h: Likewise.
	* profile.cc (compute_branch_probabilities): Likewise.
	* stmt.cc (emit_case_dispatch_table): Likewise.
	* symtab-thunks.cc (expand_thunk): Likewise.
	* tree-ssa-loop-manip.cc (tree_transform_and_unroll_loop): Likewise.
	* tree-ssa-sink.cc (select_best_block): Likewise.
	* tree-switch-conversion.cc (switch_decision_tree::analyze_switch_statement): Likewise.
	(switch_decision_tree::balance_case_nodes): Likewise.
	(switch_decision_tree::emit_case_nodes): Likewise.
	* tree-vect-loop.cc (scale_profile_for_vect_loop): Likewise.
2022-06-20 11:11:38 +02:00
yulong
970b03c003 RISC-V: Fix a bug that is the CMO builtins are missing parameter
We changed builtins format about zicbom and zicboz subextensions and modified test cases.

diff with the previous version:
1.We modified the FUNCTION_TYPE from RISCV_VOID_FTYPE_SI/DI to RISCV_VOID_FTYPE_VOID_PTR.
2.We added a new RISCV_ATYPE_VOID_PTR in riscv-builtins.cc and a new DEF_RISCV_FTYPE (1, (VOID, VOID_PTR)) in riscv-ftypes.def.
3.We deleted DEF_RISCV_FTYPE (1, (VOID, SI/DI)).
4.We modified the input parameters of the test cases.

Thanks, Simon and Kito.

gcc/ChangeLog:

	* config/riscv/riscv-builtins.cc (RISCV_ATYPE_VOID_PTR): New.
	* config/riscv/riscv-cmo.def (RISCV_BUILTIN): Changed the FUNCTION_TYPE
	of RISCV_BUILTIN.
	* config/riscv/riscv-ftypes.def (0): Remove unused.
	(1): New.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/cmo-zicbom-1.c: modified the input parameters.
	* gcc.target/riscv/cmo-zicbom-2.c: modified the input parameters.
	* gcc.target/riscv/cmo-zicboz-1.c: modified the input parameters.
	* gcc.target/riscv/cmo-zicboz-2.c: modified the input parameters.
2022-06-20 16:44:40 +08:00
GCC Administrator
e058dfc43f Daily bump. 2022-06-20 00:16:24 +00:00
Takayuki 'January June' Suwa
46880cd8be xtensa: Fix RTL insn cost estimation about relaxed MOVI instructions
These instructions will all be converted to L32R ones with litpool entries
by the assembler.

gcc/ChangeLog:

	* config/xtensa/xtensa.cc (xtensa_is_insn_L32R_p):
	Consider relaxed MOVI instructions as L32R.
2022-06-19 14:07:09 -07:00
Takayuki 'January June' Suwa
75ab2f0ebd xtensa: Apply a few minor fixes
No functional changes.

gcc/ChangeLog:

	* config/xtensa/xtensa.cc (xtensa_emit_move_sequence):
	Use can_create_pseudo_p(), instead of using individual
	reload_in_progress and reload_completed.
	(xtensa_expand_block_set_small_loop): Use xtensa_simm8x256(),
	the existing predicate function.
	(xtensa_is_insn_L32R_p, gen_int_relational, xtensa_emit_sibcall):
	Use the standard RTX code predicate macros such as MEM_P,
	SYMBOL_REF_P and/or CONST_INT_P.
	* config/xtensa/xtensa.md: Avoid using numeric literals	to determine
	if callee-saved register, at the split patterns for indirect sibcall
	fixups.
2022-06-19 14:07:05 -07:00
GCC Administrator
4390e7bfbc Daily bump. 2022-06-19 00:16:23 +00:00
Harald Anlauf
856a9b8fc2 Fortran: check POS and LEN arguments simplifying bit intrinsics [PR105986]
gcc/fortran/ChangeLog:

	PR fortran/105986
	* simplify.cc (gfc_simplify_btest): Add check for POS argument.
	(gfc_simplify_ibclr): Add check for POS argument.
	(gfc_simplify_ibits): Add check for POS and LEN arguments.
	(gfc_simplify_ibset): Add check for POS argument.

gcc/testsuite/ChangeLog:

	PR fortran/105986
	* gfortran.dg/check_bits_3.f90: New test.
2022-06-18 18:42:17 +02:00
Jakub Jelinek
2c7cfc7b41 ubsan: Add -fsanitize-trap= support
On Thu, Jun 16, 2022 at 09:32:02PM +0100, Jonathan Wakely wrote:
> It looks like clang has addressed this deficiency now:
>
> https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#usage

Thanks, that is roughly what I'd implement anyway and apparently they have
it already since 2015, we've added the -fsanitize-undefined-trap-on-error
support back in 2014 and didn't change it since then.

As a small divergence from clang, I chose -fsanitize-undefined-trap-on-error
to be a (deprecated) alias for -fsanitize-trap aka -fsanitize-trap=all
rather thn -fsanitize-trap=undefined which seems to be what clang does,
because for a deprecated option it is IMHO more important backwards
compatibility with what gcc did over the past 8 years rather than clang
compatibility.
Some sanitizers (e.g. asan, lsan, tsan) don't support traps,
-fsanitize-trap=address etc. will be rejected (if enabled at the end of
command line), -fno-sanitize-trap= can be specified even for them.
This is similar behavior to -fsanitize-recover=.
One complication is vptr sanitization, which can't easily trap,
as the whole slow path of the checking is inside of libubsan.
Previously, -fsanitize=vptr -fsanitize-undefined-trap-on-error
silently ignored vptr sanitization.
This patch similarly to what clang does will accept
-fsanitize-trap=all or -fsanitize-trap=undefined which enable
the vptr bit as trapping and again that causes silent disabling
of vptr sanitization, while -fsanitize-trap=vptr is rejected
(already during option processing).

2022-06-18  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* common.opt (flag_sanitize_trap): New variable.
	(fsanitize-trap=, fsanitize-trap): New options.
	(fsanitize-undefined-trap-on-error): Change into deprecated alias
	for -fsanitize-trap=all.
	* opts.h (struct sanitizer_opts_s): Add can_trap member.
	* opts.cc (finish_options): Complain about unsupported
	-fsanitize-trap= options.
	(sanitizer_opts): Add can_trap values to all entries.
	(get_closest_sanitizer_option): Ignore -fsanitize-trap=
	options which have can_trap false.
	(parse_sanitizer_options): Add support for -fsanitize-trap=.
	For -fsanitize-trap=all, enable
	SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT.  Disallow
	-fsanitize-trap=vptr here.
	(common_handle_option): Handle OPT_fsanitize_trap_ and
	OPT_fsanitize_trap.
	* sanopt.cc (maybe_optimize_ubsan_null_ifn): Check
	flag_sanitize_trap & SANITIZE_{NULL,ALIGNMENT} instead of
	flag_sanitize_undefined_trap_on_error.
	* gcc.cc (sanitize_spec_function): Use
	flag_sanitize & ~flag_sanitize_trap instead of flag_sanitize
	and drop use of flag_sanitize_undefined_trap_on_error in
	"undefined" handling.
	* ubsan.cc (ubsan_instrument_unreachable): Use
	flag_sanitize_trap & SANITIZE_??? instead of
	flag_sanitize_undefined_trap_on_error.
	(ubsan_expand_bounds_ifn, ubsan_expand_null_ifn,
	ubsan_expand_objsize_ifn, ubsan_expand_ptr_ifn,
	ubsan_build_overflow_builtin, instrument_bool_enum_load,
	ubsan_instrument_float_cast, instrument_nonnull_arg,
	instrument_nonnull_return, instrument_builtin): Likewise.
	* doc/invoke.texi (-fsanitize-trap=, -fsanitize-trap): Document.
	(-fsanitize-undefined-trap-on-error): Document as deprecated
	alias of -fsanitize-trap.
gcc/c-family/
	* c-ubsan.cc (ubsan_instrument_division, ubsan_instrument_shift):
	Use flag_sanitize_trap & SANITIZE_??? instead of
	flag_sanitize_undefined_trap_on_error.  If 2 sanitizers are involved
	and flag_sanitize_trap differs for them, emit __builtin_trap only
	for the comparison where trap is requested.
	(ubsan_instrument_vla, ubsan_instrument_return): Use
	lag_sanitize_trap & SANITIZE_??? instead of
	flag_sanitize_undefined_trap_on_error.
gcc/cp/
	* cp-ubsan.cc (cp_ubsan_instrument_vptr_p): Use
	flag_sanitize_trap & SANITIZE_VPTR instead of
	flag_sanitize_undefined_trap_on_error.
gcc/testsuite/
	* c-c++-common/ubsan/nonnull-4.c: Use -fsanitize-trap=all
	instead of -fsanitize-undefined-trap-on-error.
	* c-c++-common/ubsan/div-by-zero-4.c: Use
	-fsanitize-trap=signed-integer-overflow instead of
	-fsanitize-undefined-trap-on-error.
	* c-c++-common/ubsan/overflow-add-4.c: Use -fsanitize-trap=undefined
	instead of -fsanitize-undefined-trap-on-error.
	* c-c++-common/ubsan/pr56956.c: Likewise.
	* c-c++-common/ubsan/pr68142.c: Likewise.
	* c-c++-common/ubsan/pr80932.c: Use
	-fno-sanitize-trap=all -fsanitize-trap=shift,undefined
	instead of -fsanitize-undefined-trap-on-error.
	* c-c++-common/ubsan/align-8.c: Use -fsanitize-trap=alignment
	instead of -fsanitize-undefined-trap-on-error.
2022-06-18 11:09:48 +02:00
Jakub Jelinek
ef66212017 varasm: Fix up ICE in narrowing_initializer_constant_valid_p [PR105998]
The following testcase ICEs because there is NON_LVALUE_EXPR (location
wrapper) around a VAR_DECL and has TYPE_MODE V2SImode and
SCALAR_INT_TYPE_MODE on that ICEs.  Or for -m32 -march=i386 TYPE_MODE
is DImode, but SCALAR_INT_TYPE_MODE still uses the raw V2SImode and ICEs
too.

2022-06-18  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/105998
	* varasm.cc (narrowing_initializer_constant_valid_p): Check
	SCALAR_INT_MODE_P instead of INTEGRAL_MODE_P, also break on
	! INTEGRAL_TYPE_P and do the same check also on op{0,1}'s type.

	* c-c++-common/pr105998.c: New test.
2022-06-18 11:07:13 +02:00
Roger Sayle
9991d84d2a PR tree-optimization/105835: Two narrowing patterns for match.pd.
This patch resolves PR tree-optimization/105835, which is a code quality
(dead code elimination) regression at -O1 triggered/exposed by a recent
change to canonicalize X&-Y as X*Y.  The new (shorter) form exposes some
missed optimization opportunities that can be handled by adding some
extra simplifications to match.pd.

One transformation is to simplify "(short)(x ? 65535 : 0)" into the
equivalent "x ? -1 : 0", or more accurately x ? (short)-1 : (short)0",
as INTEGER_CSTs record their type, and integer conversions can be
pushed inside COND_EXPRs reducing the number of gimple statements.

The other transformation is that (short)(X * 65535), where X is [0,1],
into the equivalent (short)X * -1, (or again (short)-1 where tree's
INTEGER_CSTs encode their type).  This is valid because multiplications
where one operand is [0,1] are guaranteed not to overflow, and hence
integer conversions can also be pushed inside these multiplications.

These narrowing conversion optimizations can be identified by range
analyses, such as EVRP, but these are only performed at -O2 and above,
which is why this regression is only visible with -O1.

2022-06-18  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	PR tree-optimization/105835
	* match.pd (convert (mult zero_one_valued_p@1 INTEGER_CST@2)):
	Narrow integer multiplication by a zero_one_valued_p operand.
	(convert (cond @1 INTEGER_CST@2 INTEGER_CST@3)): Push integer
	conversions inside COND_EXPR where both data operands are
	integer constants.

gcc/testsuite/ChangeLog
	PR tree-optimization/105835
	* gcc.dg/pr105835.c: New test case.
2022-06-18 09:09:26 +01:00
Takayuki 'January June' Suwa
479b6f449e xtensa: Defer storing integer constants into litpool until reload
Storing integer constants into litpool in the early stage of compilation
hinders some integer optimizations.  In fact, such integer constants are
not subject to the constant folding process.

For example:

    extern unsigned short value;
    extern void foo(void);
    void test(void) {
      if (value == 30001)
        foo();
    }

	.literal_position
	.literal .LC0, value
	.literal .LC1, 30001
    test:
	l32r	a3, .LC0
	l32r	a2, .LC1
	l16ui	a3, a3, 0
	extui	a2, a2, 0, 16  // runtime zero-extension despite constant
	bne	a3, a2, .L1
	j.l	foo, a9
    .L1:
	ret.n

This patch defers the placement of integer constants into litpool until
the start of reload:

	.literal_position
	.literal .LC0, value
	.literal .LC1, 30001
    test:
	l32r	a3, .LC0
	l32r	a2, .LC1
	l16ui	a3, a3, 0
	bne	a3, a2, .L1
	j.l	foo, a9
    .L1:
	ret.n

gcc/ChangeLog:

	* config/xtensa/constraints.md (Y):
	Change to include integer constants until reload begins.
	* config/xtensa/predicates.md (move_operand): Ditto.
	* config/xtensa/xtensa.cc (xtensa_emit_move_sequence):
	Change to allow storing integer constants into litpool only after
	reload begins.
2022-06-17 23:28:14 -07:00
GCC Administrator
5a66d7dd2b Daily bump. 2022-06-18 00:16:19 +00:00
Ian Lance Taylor
7f195a2270 libgo: permit loff_t and off_t to be macros
They are macros in musl libc, rather than typedefs, and -fgo-dump-spec
doesn't handle that case.

Based on patch by Sören Tempel.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/412075
2022-06-17 14:27:06 -07:00
Jakub Jelinek
a284fadcce c++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shufflevector handling [PR106001]
In this case the STATIC_CAST_EXPR expressions in the call aren't
type nor value dependent, but maybe_constant_value still ICEs on those
when processing_template_decl.  Calling fold_non_dependent_expr on it
instead fixes the ICE and folds them to INTEGER_CSTs.

2022-06-17  Jakub Jelinek  <jakub@redhat.com>

	PR c++/106001
	* typeck.cc (build_x_shufflevector): Use fold_non_dependent_expr
	instead of maybe_constant_value.

	* g++.dg/ext/builtin-shufflevector-4.C: New test.
2022-06-17 17:40:49 +02:00
Uros Bizjak
cc378e6557 alpha: Introduce target specific store_data_bypass_p function [PR105209]
This patch introduces alpha-specific version of store_data_bypass_p that
ignores TRAP_IF that would result in assertion failure (and internal
compiler error) in the generic store_data_bypass_p function.

While at it, also remove ev4_ist_c reservation, store_data_bypass_p
can handle the patterns with multiple sets since some time ago.

2022-06-17  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

	PR target/105209
	* config/alpha/alpha-protos.h (alpha_store_data_bypass_p): New.
	* config/alpha/alpha.cc (alpha_store_data_bypass_p): New function.
	(alpha_store_data_bypass_p_1): Ditto.
	* config/alpha/ev4.md: Use alpha_store_data_bypass_p instead
	of generic store_data_bypass_p.
	(ev4_ist_c): Remove insn reservation.

gcc/testsuite/ChangeLog:

	PR target/105209
	* gcc.target/alpha/pr105209.c: New test.
2022-06-17 17:20:41 +02:00
Uros Bizjak
1f8278bfcf i386: Fix assert in ix86_function_arg [PR105970]
The mode of pointer argument should equal ptr_mode, not Pmode.

2022-06-17  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

	PR target/105970
	* config/i386/i386.cc (ix86_function_arg): Assert that
	the mode of pointer argumet is equal to ptr_mode, not Pmode.

gcc/testsuite/ChangeLog:

	PR target/105970
	* gcc.target/i386/pr105970.c: New test.
2022-06-17 17:02:25 +02:00
Uros Bizjak
1d6044c250 i386: Fix VPMOV splitter [PR105993]
REGNO should not be used with register_operand before reload because
subregs of registers or even subregs of memory match the predicate.
The build with RTL checking enabled does not tolerate REGNO with
non-reg operand.
The patch splits the splitter into two related splitters and uses
(match_dup ...) RTXes instead of REGNO comparisons.

2022-06-17  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

	PR target/105993
	* config/i386/sse.md (vpmov splitter): Use (match_dup ...)
	instead of REGNO comparisons in combine splitter.

gcc/testsuite/ChangeLog:

	PR target/105993
	* gcc.target/i386/pr105993.c: New test.
2022-06-17 16:23:12 +02:00
Segher Boessenkool
06a1b0418f rs6000: Fix some error messages for invalid conversions
"* something" isn't a type.  "something *" is.

2022-06-17  Segher Boessenkool  <segher@kernel.crashing.org>

	* config/rs6000/rs6000.cc (rs6000_invalid_conversion): Correct some
	types.
2022-06-17 14:16:20 +00:00
Kito Cheng
d6b423882a RISC-V: Supress warning for comparison of integer expressions of different signedness
gcc/ChangeLog:

	* config/riscv/bitmanip.md: Supress warning.
2022-06-17 21:58:50 +08:00
Richard Earnshaw
040f822461 arm: fix checking ICE in arm_print_operand [PR106004]
Sigh, another instance where I incorrectly used XUINT instead of
UINTVAL.

I've also made the code here a little more robust (although I think
this case can't in fact be reached) if the 32-bit clear mask includes
bit 31.  This case, if reached, would print out an out-of-range value
based on the size of the compiler's HOST_WIDE_INT type due to
sign-extension.  We avoid this by masking the value after inversion.

gcc/ChangeLog:
	PR target/106004
	* config/arm/arm.cc (arm_print_operand, case 'V'): Use UINTVAL.
	Clear bits in the mask above bit 31.
2022-06-17 14:27:01 +01:00
Jonathan Wakely
0f96ac43fa libstdc++: Add missing #include <string> to new test
Somehow I pushed a different version of this test to the one I actually
tested.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/cons/char/105995.cc: Add
	missing #include.
2022-06-17 13:30:10 +01:00
Martin Liska
c524d860a7 docs: add missing table header
libgomp/ChangeLog:

	* libgomp.texi: Add table header for new features of
	OpenMP 5.2.
2022-06-17 13:33:35 +02:00
Richard Earnshaw
94018fd267 arm: mve: Don't force trivial vector literals to the pool
A bug in the ordering of the operands in the mve_mov<mode> pattern
meant that all literal values were being pushed to the literal pool.
This patch fixes that and simplifies some of the logic slightly so
that we can use as simple switch statement.

For example:
void f (uint32_t *a)
{
  int i;
  for (i = 0; i < 100; i++)
    a[i] += 1;
}

Now compiles to:
        push    {lr}
        mov     lr, #25
        vmov.i32        q2, #0x1  @ v4si
        ...

instead of

        push    {lr}
        mov     lr, #25
        vldr.64 d4, .L6
        vldr.64 d5, .L6+8
	...
.L7:
        .align  3
.L6:
        .word   1
        .word   1
        .word   1
        .word   1

gcc/ChangeLog:
	* config/arm/mve.md (*mve_mov<mode>): Re-order constraints
	to avoid spilling trivial literals to the constant pool.

gcc/testsuite/ChangeLog:
	* gcc.target/arm/acle/cde-mve-full-assembly.c: Adjust expected
	output.
2022-06-17 10:33:15 +01:00
GCC Administrator
bc7e9f7675 Daily bump. 2022-06-17 00:16:23 +00:00
David Malcolm
6ab98d8b58 gimple-ssa-warn-access.cc: add missing auto_diagnostic_group
Whilst working on SARIF output I noticed some places where followup notes
weren't being properly associated with their warnings in
gcc/gimple-ssa-warn-access.cc.

Fixed thusly.

gcc/ChangeLog:
	* gimple-ssa-warn-access.cc (warn_string_no_nul): Add
	auto_diagnostic_group to group any warning with its note.
	(maybe_warn_for_bound): Likewise.
	(check_access): Likewise.
	(warn_dealloc_offset): Likewise.
	(pass_waccess::maybe_warn_memmodel): Likewise.
	(pass_waccess::maybe_check_dealloc_call): Likewise.
	(pass_waccess::warn_invalid_pointer): Likewise.
	(pass_waccess::check_dangling_stores): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-06-16 17:37:15 -04:00
David Malcolm
d3e0da54c1 c-decl: fix "inform" grouping and conditionalization
Whilst working on SARIF output I noticed some places where followup notes
weren't being properly associated with their errors/warnings in c-decl.cc.

Whilst fixing those I noticed some places where we "inform" after a
"warning" without checking that the warning was actually emitted.

Fixed the various issues seen in gcc/c/c-decl.cc thusly.

gcc/c/ChangeLog:
	* c-decl.cc (implicitly_declare): Add auto_diagnostic_group to
	group the warning with any note.
	(warn_about_goto): Likewise to group error or warning with note.
	Bail out if the warning wasn't emitted, to avoid emitting orphan
	notes.
	(lookup_label_for_goto): Add auto_diagnostic_group to
	group the error with the note.
	(check_earlier_gotos): Likewise.
	(c_check_switch_jump_warnings): Likewise for any error/warning.
	Conditionalize emission of the notes.
	(diagnose_uninitialized_cst_member): Likewise for warning,
	conditionalizing emission of the note.
	(grokdeclarator): Add auto_diagnostic_group to group the "array
	type has incomplete element type" error with any note.
	(parser_xref_tag): Add auto_diagnostic_group to group warnings
	with their notes.  Conditionalize emission of notes.
	(start_struct): Add auto_diagnostic_group to group the
	"redefinition of" errors with any note.
	(start_enum): Likewise for "redeclaration of %<enum %E%>" error.
	(check_for_loop_decls): Likewise for pre-C99 error.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-06-16 17:36:38 -04:00
David Malcolm
f0da5f0a31 analyzer: associate -Wanalyzer-va-arg-type-mismatch with CWE-686
gcc/analyzer/ChangeLog:
	* varargs.cc (va_arg_type_mismatch::emit): Associate the warning
	with CWE-686 ("Function Call With Incorrect Argument Type").

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/stdarg-1.c
	(__analyzer_called_by_test_type_mismatch_1): Verify that
	-Wanalyzer-va-arg-type-mismatch is associated with CWE-686.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-06-16 17:35:16 -04:00
David Malcolm
f443024bca analyzer: associate -Wanalyzer-va-list-exhausted with CWE-685
gcc/analyzer/ChangeLog:
	* varargs.cc: Include "diagnostic-metadata.h".
	(va_list_exhausted::emit): Associate the warning with
	CWE-685 ("Function Call With Incorrect Number of Arguments").

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/stdarg-1.c
	(__analyzer_called_by_test_not_enough_args): Verify that
	-Wanalyzer-va-list-exhausted is associated with CWE-685.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-06-16 17:33:40 -04:00
David Malcolm
065d191893 analyzer: associate -Wanalyzer-double-fclose with CWE-1341
gcc/analyzer/ChangeLog:
	* sm-file.cc (double_fclose::emit): Associate the warning with
	CWE-1341 ("Multiple Releases of Same Resource or Handle").

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/file-1.c (test_1): Verify that double-fclose is
	associated with CWE-1341.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-06-16 17:27:08 -04:00
Jason Merrill
753aaa949a opts: fix opts_set->x_flag_sanitize
While working on PR104642 I noticed this wasn't getting set.

gcc/ChangeLog:

	* opts.cc (common_handle_option) [OPT_fsanitize_]: Set
	opts_set->x_flag_sanitize.
2022-06-16 15:48:48 -04:00
Jason Merrill
d89e64d4cb flags: add comment
gcc/ChangeLog:

	* flags.h (issue_strict_overflow_warning): Comment #endif.
2022-06-16 15:48:38 -04:00
Mikhail Ablakatov
b2aaa44d2c compiler: don't generate stubs for ambiguous direct interface methods
Current implementation checks whether it has to generate a stub method for a
promoted method of an embedded struct field in Type::build_stub_methods(). If
the promoted method is ambiguous it's simply skipped. But struct types that
can fit in an interface value (e.g. structs that consist of a single pointer
field) get a second chance in Type::build_direct_iface_stub_methods().

This patch adds the same check used by Type::build_stub_methods() to
Type::build_direct_iface_stub_methods().

Fixes golang/go#52870

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/405974
2022-06-16 12:26:15 -07:00