Commit graph

203308 commits

Author SHA1 Message Date
Juzhe-Zhong
c27f06260b VECT: Support loop len control on EXTRACT_LAST vectorization
Hi, @Richi and @Richard, base on previous disscussion, I simpily fix issuses for
powerpc and s390 with your suggestions:

-  machine_mode len_load_mode = get_len_load_store_mode
-    (loop_vinfo->vector_mode, true).require ();
-  machine_mode len_store_mode = get_len_load_store_mode
-    (loop_vinfo->vector_mode, false).require ();
+  machine_mode len_load_mode, len_store_mode;
+  if (!get_len_load_store_mode (loop_vinfo->vector_mode, true)
+        .exists (&len_load_mode))
+    return false;
+  if (!get_len_load_store_mode (loop_vinfo->vector_mode, false)
+        .exists (&len_store_mode))
+    return false;

Co-Authored-By: Kewen.Lin <linkw@linux.ibm.com>

gcc/ChangeLog:

	* tree-vect-loop.cc (vect_verify_loop_lens): Add exists check.
	(vectorizable_live_operation): Add live vectorization for length loop
	control.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/partial/live-1.c: New test.
	* gcc.target/riscv/rvv/autovec/partial/live_run-1.c: New test.
2023-08-22 14:30:16 +08:00
liuhongt
710d54f4c5 Testcase fix.
gcc/testsuite/ChangeLog:

	* gcc.target/i386/invariant-ternlog-1.c: Only scan %rdx under
	TARGET_64BIT.
2023-08-22 14:07:25 +08:00
Lehua Ding
eaabae8e30 RISC-V: Change fnms testcases assertion to xfail
Hi,

This patch fixes inappropriate assertions in fnms testcases since
we want to generate .COND_FNMS but actually generate .FNMS + .VCOND_MASK.
A patch to do this optimization will follow.

Best,
Lehua

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-1.c: Adjust.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-4.c: Ditto.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-5.c: Ditto.
	* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-6.c: Ditto.
2023-08-22 11:10:11 +08:00
David Malcolm
3b691e0190 analyzer: check format strings for null termination [PR105899]
This patch extends -fanalyzer to check the format strings of calls
to functions marked with '__attribute__ ((format...))'.

The only checking done in this patch is to check that the format string
is a valid null-terminated string; this patch doesn't attempt to check
the content of the format string.

gcc/analyzer/ChangeLog:
	PR analyzer/105899
	* call-details.cc (call_details::call_details): New ctor.
	* call-details.h (call_details::call_details): New ctor decl.
	(struct call_arg_details): Move here from region-model.cc.
	* region-model.cc (region_model::check_call_format_attr): New.
	(region_model::check_call_args): Call it.
	(struct call_arg_details): Move it to call-details.h.
	* region-model.h (region_model::check_call_format_attr): New decl.

gcc/testsuite/ChangeLog:
	PR analyzer/105899
	* gcc.dg/analyzer/attr-format-1.c: New test.
	* gcc.dg/analyzer/sprintf-1.c: Update expected results for
	now-passing tests.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-08-21 21:13:19 -04:00
David Malcolm
4325c82736 analyzer: add kf_fopen
Add checking to -fanalyzer that both params of calls to "fopen" are
valid null-terminated strings.

gcc/analyzer/ChangeLog:
	* kf.cc (class kf_fopen): New.
	(register_known_functions): Register it.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/fopen-1.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-08-21 21:13:19 -04:00
David Malcolm
fe97f09a0c analyzer: replace -Wanalyzer-unterminated-string with scan_for_null_terminator [PR105899]
In r14-3169-g325f9e88802daa I added check_for_null_terminated_string_arg
to -fanalyzer, calling it in various places, with a sole check for
unterminated string constants, adding -Wanalyzer-unterminated-string for
this case.

This patch adds region_model::scan_for_null_terminator, which simulates
scanning memory for a zero byte, complaining about uninitiliazed bytes
and out-of-range accesses seen before any zero byte is seen.

This more flexible approach catches the issues we saw before with
-Wanalyzer-unterminated-string, and also catches uninitialized runs
of bytes, and I believe will be a better way to build checking of C
string operations in the analyzer.

Given that the patch makes -Wanalyzer-unterminated-string redundant
and that this option was only in trunk for 10 days and has no known
users, the patch simply removes the option without a compatibility
fallback.

The patch uses custom events and notes to provide context on where
the issues are coming from.  For example, given:

null-terminated-strings-1.c: In function ‘test_partially_initialized’:
null-terminated-strings-1.c:71:3: warning: use of uninitialized value ‘buf[1]’ [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
   71 |   __analyzer_get_strlen (buf);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  ‘test_partially_initialized’: events 1-3
    |
    |   69 |   char buf[16];
    |      |        ^~~
    |      |        |
    |      |        (1) region created on stack here
    |   70 |   buf[0] = 'a';
    |   71 |   __analyzer_get_strlen (buf);
    |      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |   |
    |      |   (2) while looking for null terminator for argument 1 (‘&buf’) of ‘__analyzer_get_strlen’...
    |      |   (3) use of uninitialized value ‘buf[1]’ here
    |
analyzer-decls.h:59:22: note: argument 1 of ‘__analyzer_get_strlen’ must be a pointer to a null-terminated string
   59 | extern __SIZE_TYPE__ __analyzer_get_strlen (const char *ptr);
      |                      ^~~~~~~~~~~~~~~~~~~~~

gcc/analyzer/ChangeLog:
	PR analyzer/105899
	* analyzer.opt (Wanalyzer-unterminated-string): Delete.
	* call-details.cc
	(call_details::check_for_null_terminated_string_arg): Convert
	return type from void to const svalue *.  Add param "out_sval".
	* call-details.h
	(call_details::check_for_null_terminated_string_arg): Likewise.
	* kf-analyzer.cc (kf_analyzer_get_strlen::impl_call_pre): Wire up
	to result of check_for_null_terminated_string_arg.
	* region-model.cc (get_strlen): Delete.
	(class unterminated_string_arg): Delete.
	(struct fragment): New.
	(class iterable_cluster): New.
	(region_model::get_store_bytes): New.
	(get_tree_for_byte_offset): New.
	(region_model::scan_for_null_terminator): New.
	(region_model::check_for_null_terminated_string_arg): Convert
	return type from void to const svalue *.  Add param "out_sval".
	Reimplement in terms of scan_for_null_terminator, dropping the
	special-case for -Wanalyzer-unterminated-string.
	* region-model.h (region_model::get_store_bytes): New decl.
	(region_model::scan_for_null_terminator): New decl.
	(region_model::check_for_null_terminated_string_arg): Convert
	return type from void to const svalue *.  Add param "out_sval".
	* store.cc (concrete_binding::get_byte_range): New.
	* store.h (concrete_binding::get_byte_range): New decl.
	(store_manager::get_concrete_binding): New overload.

gcc/ChangeLog:
	PR analyzer/105899
	* doc/invoke.texi: Remove -Wanalyzer-unterminated-string.

gcc/testsuite/ChangeLog:
	PR analyzer/105899
	* gcc.dg/analyzer/error-1.c: Update expected results to reflect
	reimplementation of unterminated string detection.  Add test
	coverage for uninitialized buffers.
	* gcc.dg/analyzer/null-terminated-strings-1.c: Likewise.
	* gcc.dg/analyzer/putenv-1.c: Likewise.
	* gcc.dg/analyzer/strchr-1.c: Likewise.
	* gcc.dg/analyzer/strcpy-1.c: Likewise.
	* gcc.dg/analyzer/strdup-1.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-08-21 21:13:19 -04:00
David Malcolm
1e7b0a5d7a analyzer: handle NULL inner context in region_model_context_decorator
gcc/analyzer/ChangeLog:
	* region-model.cc (region_model_context_decorator::add_event):
	Handle m_inner being NULL.
	* region-model.h (class region_model_context_decorator): Likewise.
	(annotating_context::warn): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-08-21 21:13:18 -04:00
David Malcolm
2503dd59b5 analyzer: add ability for context to add events to a saved_diagnostic
gcc/analyzer/ChangeLog:
	* diagnostic-manager.cc (saved_diagnostic::add_event): New.
	(saved_diagnostic::add_any_saved_events): New.
	(diagnostic_manager::add_event): New.
	(dedupe_winners::emit_best): New.
	(diagnostic_manager::emit_saved_diagnostic): Make "sd" param
	non-const.  Call saved_diagnostic::add_any_saved_events.
	* diagnostic-manager.h (saved_diagnostic::add_event): New decl.
	(saved_diagnostic::add_any_saved_events): New decl.
	(saved_diagnostic::m_saved_events): New field.
	(diagnostic_manager::add_event): New decl.
	(diagnostic_manager::emit_saved_diagnostic): Make "sd" param
	non-const.
	* engine.cc (impl_region_model_context::add_event): New.
	* exploded-graph.h (impl_region_model_context::add_event): New decl.
	* region-model.cc
	(noop_region_model_context::add_event): New.
	(region_model_context_decorator::add_event): New.
	* region-model.h (region_model_context::add_event): New vfunc.
	(noop_region_model_context::add_event): New decl.
	(region_model_context_decorator::add_event): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-08-21 21:13:18 -04:00
David Malcolm
e40a935db2 analyzer: convert note_adding_context to annotating_context
This is enabling work towards the context being able to inject
events into diagnostic paths, rather than just notes after the
warning.

gcc/analyzer/ChangeLog:
	* region-model.cc
	(class check_external_function_for_access_attr::annotating_ctxt):
	Convert to an annotating_context.
	* region-model.h (class note_adding_context): Rename to...
	(class annotating_context): ...this, updating the "warn" method.
	(note_adding_context::make_note): Replace with...
	(annotating_context::add_annotations): ...this.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-08-21 21:13:17 -04:00
GCC Administrator
5f55721049 Daily bump. 2023-08-22 00:18:05 +00:00
Pan Li
1d17e3d667 RISC-V: Support RVV VFWREDUSUM.VS rounding mode intrinsic API
This patch would like to support the rounding mode API for the
VFWREDUSUM.VS as the below samples

* __riscv_vfwredusum_vs_f32m1_f64m1_rm
* __riscv_vfwredusum_vs_f32m1_f64m1_rm_m

Signed-off-by: Pan Li <pan2.li@intel.com>

gcc/ChangeLog:

	* config/riscv/riscv-vector-builtins-bases.cc
	(vfwredusum_frm_obj): New declaration.
	(BASE): Ditto.
	* config/riscv/riscv-vector-builtins-bases.h: Ditto.
	* config/riscv/riscv-vector-builtins-functions.def
	(vfwredusum_frm): New intrinsic function def.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/float-point-wredusum.c: New test.
2023-08-22 08:00:51 +08:00
David Faust
e2c42860b6 bpf: neg instruction does not accept an immediate
The BPF virtual machine does not support neg nor neg32 instructions with
an immediate.

The erroneous instructions were removed from binutils:
https://sourceware.org/pipermail/binutils/2023-August/129135.html

Change the define_insn so that an immediate cannot be accepted.

From testing, a neg-immediate was probably never chosen over a
mov-immediate anyway.

gcc/

	* config/bpf/bpf.md (neg): Second operand must be a register.
2023-08-21 15:10:28 -07:00
Edwin Lu
36788c9ff6 [PATCH] RISC-V: Add Types to Missing Bitmanip Instructions
This patch updates the bitmanip instructions to ensure that no insn is left
without a type attribute. Updates a total of 8 insns to have type "bitmanip"

Tested for regressions using rv32/64 multilib with newlib/linux.

gcc/Changelog:

	* config/riscv/bitmanip.md: Added bitmanip type to insns
	that are missing types.
2023-08-21 15:20:24 -06:00
Thiago Jung Bauermann
b369f0ba87 Remove XFAIL from gcc/testsuite/gcc.dg/unroll-7.c
This test passes since commit e41103081b "Fix undefined behaviour in
profile_count::differs_from_p", so remove the xfail annotation.

Tested on aarch64-linux-gnu, armv8l-linux-gnueabihf and x86_64-linux-gnu.

gcc/testsuite/ChangeLog:
	* gcc.dg/unroll-7.c: Remove xfail.
2023-08-21 20:19:14 +01:00
Jeff Law
39491441a3 [RISCV][committed] Remove spurious newline in ztso sequence
amo-table-ztso-load-3 the coordination branch after merging up the Ztso changes
due to a spurious newline in the output causing scan-function-body to fail.
There's probably an over-zealous .* or similar regexp in the framework.  I
didn't see it in a quick scan, but could have easily missed it.

Regardless, fixing the extraneous newline is easy :-)

gcc/
	* config/riscv/sync-ztso.md (atomic_load_ztso<mode>): Avoid extraenous
	newline.
2023-08-21 11:20:28 -06:00
Francois-Xavier Coudert
04eea1ec33 aarch64: fix format specifier
gcc/ChangeLog:

	* config/aarch64/falkor-tag-collision-avoidance.cc (dump_insn_list):
	Fix format specifier.
2023-08-21 18:49:39 +02:00
Aldy Hernandez
f9ff6fa582 [frange] Return false if nothing changed in union_nans().
When one operand is a known NAN, we always return TRUE from
union_nans(), even if no change occurred.  This patch fixes the
oversight.

gcc/ChangeLog:

	* value-range.cc (frange::union_nans): Return false if nothing
	changed.
	(range_tests_floats): New test.
2023-08-21 15:45:29 +02:00
Tsukasa OI
ab7de14eaf [PATCH 2/2] RISC-V: Add quotes to #error messages (all)
From: Tsukasa OI <research_trasio@irq.a4lg.com>

In commit 1aaf3a64e9 ("[PATCH] RISC-V: Deduplicate #error messages in
testsuite"), the author made a mistake to miss the test after adding
quotes around extension names.  To avoid future errors and for consistency
with other #error uses in the RISC-V testsuite, this commit quotes all
unquoted #error messages.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/xtheadba.c: Quote unquoted #error message.
	* gcc.target/riscv/xtheadbb.c: Ditto.
	* gcc.target/riscv/xtheadbs.c: Ditto.
	* gcc.target/riscv/xtheadcmo.c: Ditto.
	* gcc.target/riscv/xtheadcondmov.c: Ditto.
	* gcc.target/riscv/xtheadfmemidx.c: Ditto.
	* gcc.target/riscv/xtheadfmv.c: Ditto.
	* gcc.target/riscv/xtheadint.c: Ditto.
	* gcc.target/riscv/xtheadmac.c: Ditto.
	* gcc.target/riscv/xtheadmemidx.c: Ditto.
	* gcc.target/riscv/xtheadmempair.c: Ditto.
	* gcc.target/riscv/xtheadsync.c: Ditto.
	* gcc.target/riscv/zawrs.c: Ditto.
	* gcc.target/riscv/zvbb.c: Ditto.
	* gcc.target/riscv/zvbc.c: Ditto.
	* gcc.target/riscv/zvkg.c: Ditto.
	* gcc.target/riscv/zvkned.c: Ditto.
	* gcc.target/riscv/zvknha.c: Ditto.
	* gcc.target/riscv/zvknhb.c: Ditto.
	* gcc.target/riscv/zvksed.c: Ditto.
	* gcc.target/riscv/zvksh.c: Ditto.
	* gcc.target/riscv/zvkt.c: Ditto.
2023-08-21 07:31:52 -06:00
Tsukasa OI
56c28ce7b5 [PATCH 1/2] RISC-V: Add quotes to #error messages
In commit 1aaf3a64e9 ("[PATCH] RISC-V: Deduplicate #error messages in
testsuite"), the author made a mistake to miss the test after adding
quotes around extension names.  To avoid future errors and for consistency
with other #error uses in the RISC-V testsuite, this commit quotes #error
messages where necessary to avoid current test case failures.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/zvkn.c: Quote #error messages.
	* gcc.target/riscv/zvkn-1.c: Ditto.
	* gcc.target/riscv/zvknc.c: Ditto.
	* gcc.target/riscv/zvknc-1.c: Ditto.
	* gcc.target/riscv/zvknc-2.c: Ditto.
	* gcc.target/riscv/zvkng.c: Ditto.
	* gcc.target/riscv/zvkng-1.c: Ditto.
	* gcc.target/riscv/zvkng-2.c: Ditto.
	* gcc.target/riscv/zvks.c: Ditto.
	* gcc.target/riscv/zvks-1.c: Ditto.
	* gcc.target/riscv/zvksc.c: Ditto.
	* gcc.target/riscv/zvksc-1.c: Ditto.
	* gcc.target/riscv/zvksc-2.c: Ditto.
	* gcc.target/riscv/zvksg.c: Ditto.
	* gcc.target/riscv/zvksg-1.c: Ditto.
	* gcc.target/riscv/zvksg-2.c: Ditto.
2023-08-21 07:31:13 -06:00
Richard Biener
2eaebcf3df Fix FAIL: gcc.target/i386/pr87007-5.c
The following fixes the gcc.target/i386/pr87007-5.c testcase which
changed code generation again after the recent sinking improvements.
We now have

        vxorps  %xmm0, %xmm0, %xmm0
        vsqrtsd d2(%rip), %xmm0, %xmm0

and a necessary xor again in one case, the other vsqrtsd has
a register source and a properly zeroing load:

        vmovsd  d3(%rip), %xmm0
        testl   %esi, %esi
        jg      .L11
.L3:
        vsqrtsd %xmm0, %xmm0, %xmm0

the following patch adjusts the scan.

	* gcc.target/i386/pr87007-5.c: Update comment, adjust subtest.
2023-08-21 15:10:06 +02:00
Richard Biener
e4e6a92407 Fix gcc.dg/vect/bb-slp-subgroups-2.c with 256bit vectors
The following adds vect128, vect256 and vect512 effective targets
and adjusts gcc.dg/vect/bb-slp-subgroups-2.c accordingly.

gcc/testsuite/
	* lib/target-supports.exp: Add vect128, vect256 and vect512
	effective targets.
	* gcc.dg/vect/bb-slp-subgroups-2.c: Properly handle the
	vect256 case.
2023-08-21 13:58:52 +02:00
Prathamesh Kulkarni
dd606dc7c7 Fix gcc.dg/vect/pr65947-7.c failures on aarch64.
gcc/testsuite/ChangeLog:
	* gcc.dg/vect/pr65947-7.c: Add target check aarch64*-*-* and scan vect
	dump for pattern "optimizing condition reduction with FOLD_EXTRACT_LAST"
	for targets that support vect_fold_extract_last.
2023-08-21 16:58:58 +05:30
Richard Biener
4c5712ff47 Fix gcc.dg/vect/bb-slp-46.c FAIL
When relaxing vectorization of possibly overflowing reductions I
failed to update a testcase that will now vectorize and no longer
test for what it was written for.  The following replaces the
vectorizable add with a division.

	* gcc.dg/vect/bb-slp-46.c: Use division instead of addition
	to avoid reduction vectorization.
2023-08-21 13:09:31 +02:00
liuhongt
6450397ed0 Adjust testcase for Intel GDS.
gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512f-pr88464-2.c: Add -mgather to
	options.
	* gcc.target/i386/avx512f-pr88464-3.c: Ditto.
	* gcc.target/i386/avx512f-pr88464-4.c: Ditto.
	* gcc.target/i386/avx512f-pr88464-6.c: Ditto.
	* gcc.target/i386/avx512f-pr88464-7.c: Ditto.
	* gcc.target/i386/avx512f-pr88464-8.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-10.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-12.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-13.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-14.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-15.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-16.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-2.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-4.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-5.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-6.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-7.c: Ditto.
	* gcc.target/i386/avx512vl-pr88464-8.c: Ditto.
2023-08-21 18:02:25 +08:00
Prathamesh Kulkarni
649388462e PR111048: Set arg_npatterns correctly.
In valid_mask_for_fold_vec_perm_cst we set arg_npatterns always
to VECTOR_CST_NPATTERNS (arg0) because of (q1 & 0) == 0:

     /* Ensure that the stepped sequence always selects from the same
         input pattern.  */
      unsigned arg_npatterns
        = ((q1 & 0) == 0) ? VECTOR_CST_NPATTERNS (arg0)
                          : VECTOR_CST_NPATTERNS (arg1);

resulting in wrong code-gen issues.
The patch fixes this by changing the condition to (q1 & 1) == 0.

gcc/ChangeLog:
	PR tree-optimization/111048
	* fold-const.cc (valid_mask_for_fold_vec_perm_cst_p): Set arg_npatterns
	correctly.
	(fold_vec_perm_cst): Remove workaround and again call
	valid_mask_fold_vec_perm_cst_p for both VLS and VLA vectors.
	(test_fold_vec_perm_cst::test_nunits_min_4): Add test-case.
2023-08-21 15:25:08 +05:30
Richard Biener
e10cb804e6 tree-optimization/111082 - bogus promoted min
vectorize_slp_instance_root_stmt promotes operations with undefined
overflow to unsigned arithmetic but fails to consider operations
that do not overflow like MIN which it turned into MIN with wrong
signedness and in the case of the PR an unsupported operation.
The following rectifies this.

	PR tree-optimization/111082
	* tree-vect-slp.cc (vectorize_slp_instance_root_stmt): Only
	pun operations that can overflow.

	* gcc.dg/pr111082.c: New testcase.
2023-08-21 11:46:48 +02:00
Jonathan Wakely
03cb6904d1 libstdc++: Remove reliance on unspecified behaviour in std::rethrow_if_nested test
This test case calls std::set_terminate while there is an active
exception. Since LWG 2111 it is unspecified which terminate handler is
used when std::nested_exception::rethrow_nested() calls std::terminate.
With libsupc++ the global handler changed by std::set_terminate is used,
but libc++abi uses the active exception's handler (the one that was
current when the exception was first thrown).

Adjust the test case so that it works with either implementation choice.
So that the process doesn't exit cleanly if std::terminate happens
sooner than expected, use a global variable to control when the "clean
terminate" behaviour happens.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/nested_exception/rethrow_if_nested-term.cc:
	Call std::set_terminate before throwing the nested exception.
2023-08-21 10:43:19 +01:00
Juzhe-Zhong
d5dfba19ae LCM: Export 2 helpful functions as global for VSETVL PASS use in RISC-V backend
This patch exports 'compute_antinout_edge' and 'compute_earliest' as global scope
which is going to be used in VSETVL PASS of RISC-V backend.

The demand fusion is the fusion of VSETVL information to emit VSETVL which dominate and pre-config for most
of the RVV instructions in order to elide redundant VSETVLs.

For exmaple:

for
 for
  for
    if (cond}
      VSETVL demand 1: SEW/LMUL = 16 and TU policy
    else
      VSETVL demand 2: SEW = 32

VSETVL pass should be able to fuse demand 1 and demand 2 into new demand: SEW = 32, LMUL = M2, TU policy.
Then emit such VSETVL at the outmost of the for loop to get the most optimal codegen and run-time execution.

Currenty the VSETVL PASS Phase 3 (demand fusion) is really messy and un-reliable as well as un-maintainable.
And, I recently read dragon book and morgan's book again, I found there "earliest" can allow us to do the
demand fusion in a very reliable and optimal way.

So, this patch exports these 2 functions which are very helpful for VSETVL pass.

gcc/ChangeLog:

	* lcm.cc (compute_antinout_edge): Export as global use.
	(compute_earliest): Ditto.
	(compute_rev_insert_delete): Ditto.
	* lcm.h (compute_antinout_edge): Ditto.
	(compute_earliest): Ditto.
2023-08-21 17:18:14 +08:00
Richard Biener
966b0a9652 tree-optimization/111070 - fix ICE with recent ifcombine fix
We now got test coverage for non-SSA name bits so the following amends
the SSA_NAME_OCCURS_IN_ABNORMAL_PHI checks.

	PR tree-optimization/111070
	* tree-ssa-ifcombine.cc (ifcombine_ifandif): Check we have
	an SSA name before checking SSA_NAME_OCCURS_IN_ABNORMAL_PHI.

	* gcc.dg/pr111070.c: New testcase.
2023-08-21 10:07:30 +02:00
Andrew Pinski
47b833a9ab MATCH: [PR111002] Sink view_convert for vec_cond
Like convert we can sink view_convert into vec_cond but
we can only do it if the element types are nop_conversions.
This is to allow conversion between signed and unsigned types only.
Rather than between integer and float types which mess up the vec_cond
so that isel does not understand `a?-1:0` is still that.

OK? Bootstrapped and tested on x86_64-linux-gnu and aarch64-linux-gnu.

	PR tree-optimization/111002

gcc/ChangeLog:

	* match.pd (view_convert(vec_cond(a,b,c))): New pattern.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/sve/cond_convert_8.c: New test.
2023-08-21 00:45:38 -07:00
Francois-Xavier Coudert
b9426543e8 Testsuite, LTO: silence warning to make test pass on Darwin
gcc/testsuite/ChangeLog:

	* gcc.dg/lto/20091013-1_2.c: Add -Wno-stringop-overread.
2023-08-21 09:39:21 +02:00
liuhongt
f847e0195d Support -march=gracemont
Alderlake-N is E-core only, add it as an alias of Alderlake.

gcc/ChangeLog:

	* common/config/i386/cpuinfo.h (get_intel_cpu): Detect
	Alderlake-N.
	* common/config/i386/i386-common.cc (alias_table): Support
	-march=gracemont as an alias of -march=alderlake.
2023-08-21 09:53:17 +08:00
GCC Administrator
a75932106e Daily bump. 2023-08-21 00:17:21 +00:00
Gaius Mulley
a724c6e93d PR modula2/111085 nexttoward and nexttowardf contain incorrect definitions
The definition for procedures nexttoward and nexttowardf contain
second incorrect parameter and return types.  This bug was
discovered when attempting to resolve PR 108143 and is applied
separately and prior to PR 108143.

gcc/m2/ChangeLog:

	PR modula2/111085
	* gm2-libs/Builtins.def (nexttoward): Alter the second
	parameter to LONGREAL.
	(nexttowardf): Alter the second	parameter to LONGREAL.
	* gm2-libs/Builtins.mod (nexttoward): Alter the second
	parameter to LONGREAL.
	(nexttowardf): Alter the second	parameter to LONGREAL.
	* gm2-libs/cbuiltin.def (nexttoward): Alter the second
	parameter to LONGREAL.
	(nexttowardf): Alter the second	parameter to LONGREAL.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-08-20 23:27:34 +01:00
Francois-Xavier Coudert
6d33602650 Testsuite, darwin: account for macOS 13 and 14
gcc/testsuite/ChangeLog:

	* gcc.dg/darwin-minversion-link.c: Account for macOS 13 and 14.
2023-08-21 00:02:25 +02:00
Thiago Jung Bauermann
40a6803c6d testsuite: Adjust g++.dg/gomp/pr58567.C to new compiler message
Commit 92d1425ca7 "c++: redundant targ coercion for var/alias tmpls"
changed the compiler error message in this testcase from

<source>: In instantiation of 'void foo() [with T = int]':
<source>:14:11:   required from here
<source>:8:22: error: 'int' is not a class, struct, or union type
<source>:8:22: error: 'int' is not a class, struct, or union type
<source>:8:22: error: 'int' is not a class, struct, or union type
<source>:8:3: error: expected iteration declaration or initialization
compiler exited with status 1

to:

<source>: In instantiation of 'void foo() [with T = int]':
<source>:14:11:   required from here
<source>:8:22: error: 'int' is not a class, struct, or union type
<source>:8:3: error: invalid type for iteration variable 'i'
compiler exited with status 1
Excess errors:
<source>:8:3: error: invalid type for iteration variable 'i'

Andrew Pinski analysed the issue in PR 110756 and considered that it was a
testsuite issue in that the error message changed slightly.  Also, it's a
better error message.

Therefore, we only need to adjust the testcase to expect the new message.

gcc/testsuite/ChangeLog:
	PR testsuite/110756
	* g++.dg/gomp/pr58567.C: Adjust to new compiler error message.
2023-08-20 20:46:05 +02:00
Francois-Xavier Coudert
7694d0352a Testsuite, darwin: Fix analyzer testcases
On darwin, system headers are fortified by default and that defeats the
analyzer's warnings on memcpy() calls.  Turn this off for testing.

gcc/testsuite/ChangeLog:

	* gcc.dg/plugin/taint-CVE-2011-0521-5-fixed.c: Use
	_FORTIFY_SOURCE=0 on darwin.
	* gcc.dg/plugin/taint-CVE-2011-0521-5.c: Likewise.
	* gcc.dg/plugin/taint-CVE-2011-0521-6.c: Likewise.
2023-08-20 20:02:43 +02:00
Francois-Xavier Coudert
02393e4b5e Testsuite: mark IPA test as requiring alias support
This was indicated in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85656
but never committed. Without it, the test fails on darwin.

gcc/testsuite/ChangeLog:
	* gcc.dg/ipa/ipa-icf-38.c: Require alias support.
2023-08-20 19:40:28 +02:00
Francois-Xavier Coudert
a037992ca9 Testsuite, plugin: make testcase pattern more flexible
On Darwin, the message recorded in the sarif file contains:
  "message": {"text": "Segmentation fault: 11"}
which is different from, e.g., linux:
  "message": {"text": "Segmentation fault"}

Adjusting the testcase pattern to be a little more flexible.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/crash-test-write-though-null-sarif.c: Update
	expected pattern.
2023-08-20 19:40:17 +02:00
Uros Bizjak
791952ef43 i386: Micro-optimize ix86_expand_sse_extend
Partial vector src is forced to a register as ops[1], we can use it
instead of SRC in the call to ix86_expand_sse_cmp.  This change avoids
forcing operand[1] to a register in sign/zero-extend expanders.

gcc/ChangeLog:

	* config/i386/i386-expand.cc (ix86_expand_sse_extend): Use ops[1]
	instead of src in the call to ix86_expand_sse_cmp.
	* config/i386/sse.md (<any_extend:insn>v8qiv8hi2): Do not
	force operands[1] to a register.
	(<any_extend:insn>v4hiv4si2): Ditto.
	(<any_extend:insn>v2siv2di2): Ditto.
2023-08-20 17:55:51 +02:00
Iain Buclaw
d77c280454 d: Merge upstream dmd, druntime 26f049fb26, phobos 330d6a4fd.
D front-end changes:

	- Import dmd v2.105.0-beta.1.
	- Added predefined version identifier VisionOS (ignored by GDC).
	- Functions can no longer have `enum` storage class.
	- The deprecation of the `body` keyword has been reverted, it is
	  now an obsolete feature.
	- The error for `scope class` has been reverted, it is now an
	  obsolete feature.

D runtime changes:

	- Import druntime v2.105.0-beta.1.

Phobos changes:

	- Import phobos v2.105.0-beta.1.
	- AliasSeq has been removed from std.math.
	- extern(C) getdelim and getline have been removed from
	  std.stdio.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 26f049fb26.
	* dmd/VERSION: Bump version to v2.105.0-beta.1.
	* d-codegen.cc (get_frameinfo): Check useGC in condition.
	* d-lang.cc (d_handle_option): Set obsolete parameter when compiling
	with -Wall.
	(d_post_options): Set useGC to false when compiling with
	-fno-druntime.  Propagate obsolete flag to compileEnv.
	* expr.cc (ExprVisitor::visit (CatExp *)): Check useGC in condition.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime 26f049fb26.
	* src/MERGE: Merge upstream phobos 330d6a4fd.
2023-08-20 11:20:00 +02:00
Francois-Xavier Coudert
ce33bbfcbc Testsuite: fix analyzer tests on Darwin
On macOS, system headers redefine by default some macros (memcpy,
memmove, etc) to checked versions, which defeats the analyzer. We
want to turn this off.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104042

gcc/testsuite/ChangeLog:

	PR analyzer/104042
	* gcc.dg/analyzer/analyzer.exp: Pass -D_FORTIFY_SOURCE=0 on Darwin.
	* gcc.dg/analyzer/fd-bind.c: Add missing <string.h> header.
	* gcc.dg/analyzer/fd-datagram-socket.c: Likewise.
	* gcc.dg/analyzer/fd-listen.c: Likewise.
	* gcc.dg/analyzer/fd-socket-misuse.c: Likewise.
	* gcc.dg/analyzer/fd-stream-socket-active-open.c: Likewise.
	* gcc.dg/analyzer/fd-stream-socket-passive-open.c: Likewise.
	* gcc.dg/analyzer/fd-stream-socket.c: Likewise.
	* gcc.dg/analyzer/fd-symbolic-socket.c: Likewise.
2023-08-20 10:21:19 +02:00
Andrew Pinski
70c50c8727 MATCH: Sink convert for vec_cond
Convert be sinked into a vec_cond if both sides
fold. Unlike other unary operations, we need to check that we still can handle
this vec_cond's first operand is the same as the new truth type.

I tried a few different versions of this patch:
view_convert to the new truth_type but that does not work as we always support all vec_cond
afterwards.
using expand_vec_cond_expr_p; but that would allow too much.

I also tried to see if view_convert can be handled here but we end up with:
  _3 = VEC_COND_EXPR <_2, {  Nan(-1),  Nan(-1),  Nan(-1),  Nan(-1) }, { 0.0, 0.0, 0.0, 0.0 }>;
Which isel does not know how to handle as just being a view_convert from `vector(4) <signed-boolean:32>`
to `vector(4) float` and causes a regression with `g++.target/i386/pr88152.C`

Note, in the case of the SVE testcase, we will sink negate after the convert and be able
to remove a few extra instructions in the end.
Also with this change gcc.target/aarch64/sve/cond_unary_5.c will now pass.

Committed as approved after a bootstrapped and tested on x86_64-linux-gnu and aarch64-linux-gnu.

gcc/ChangeLog:

	PR tree-optimization/111006
	PR tree-optimization/110986
	* match.pd: (op(vec_cond(a,b,c))): Handle convert for op.

gcc/testsuite/ChangeLog:

	PR tree-optimization/111006
	* gcc.target/aarch64/sve/cond_convert_7.c: New test.
2023-08-20 00:26:19 -07:00
Martin Uecker
1e3003ca08 fix misleading identation breaking bootstrap
Fix identation issue introduced by 966f3c13
"Fix format attribute for printf".

gcc/c-family/ChangeLog:

	* c-format.cc: Fix identation.
2023-08-20 09:22:35 +02:00
Eric Gallager
9a5d1fceb8 improve error when /usr/include isn't found [PR90835]
This is a pretty simple patch that ought to help Darwin users understand
better why their build is failing when they forget to pass the
--with-sysroot= flag to configure.

gcc/ChangeLog:

	PR target/90835
	* Makefile.in: improve error message when /usr/include is
	missing
2023-08-19 23:57:01 -04:00
Tomas Kalibera
966f3c134b Fix format attribute for printf
Since a long time (GCC 4.4?) GCC does support annotating functions
with either the format attribute "gnu_printf" or "ms_printf" to
distinguish between different format string interpretations.

However, it seems like the attribute is ignored for the "printf"
symbol; regardless what the function declaration says, GCC treats
it as "ms_printf". This has become an issue now that mingw-w64
supports using the UCRT instead of msvcrt.dll, and in this case
the stdio functions are declared with the gnu_printf attribute,
and inttypes.h uses the same format specifiers as in GNU mode.

A reproducible example of the problem:

$ cat format.c
__attribute__((__format__ (gnu_printf, 1, 2))) int printf (const char *__format, ...);
__attribute__((__format__ (gnu_printf, 1, 2))) int othername (const char *__format, ...);

void function(void) {
    long long unsigned x = 42;
    othername("%llu\n", x);
    printf("%llu\n", x);
}
$ x86_64-w64-mingw32-gcc -c -Wformat format.c
format.c: In function 'function':
format.c:7:15: warning: unknown conversion type character 'l' in format [-Wformat=]
    7 |     printf("%llu\n", x);
      |               ^
format.c:7:12: warning: too many arguments for format [-Wformat-extra-args]
    7 |     printf("%llu\n", x);
      |            ^~~~~~~~

Note how both functions, printf and othername, are declare with
identical gnu_printf format attributes - GCC does take this into
account for "othername" and doesn't produce a warning, but GCC
seems to disregard the attribute in the printf declaration and
behave as if it was declared as ms_printf.

If the printf function declaration is changed into a static inline
function, the actual attribute used is honored though.

gcc/c-family/ChangeLog:

	PR c/95130
	* c-format.cc: skip default format for printf symbol if
	explicitly declared by prototype.

Signed-off-by: Tomas Kalibera <tomas.kalibera@gmail.com>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
2023-08-20 02:22:02 +00:00
GCC Administrator
1ba3363668 Daily bump. 2023-08-20 00:17:38 +00:00
Tobias Burnus
1dc65003b6 omp-expand.cc: Fix wrong code with non-rectangular loop nest [PR111017]
Before commit r12-5295-g47de0b56ee455e, all gimple_build_cond in
expand_omp_for_* were inserted with
  gsi_insert_before (gsi_p, cond_stmt, GSI_SAME_STMT);
except the one dealing with the multiplicative factor that was
  gsi_insert_after (gsi, cond_stmt, GSI_CONTINUE_LINKING);

That commit for PR103208 fixed the issue of some missing regimplify of
operands of GIMPLE_CONDs by moving the condition handling to the new function
expand_omp_build_cond. While that function has an 'bool after = false'
argument to switch between the two variants.

However, all callers ommited this argument. This commit reinstates the
prior behavior by passing 'true' for the factor != 0 condition, fixing
the included testcase.

	PR middle-end/111017
gcc/
	* omp-expand.cc (expand_omp_for_init_vars): Pass after=true
	to expand_omp_build_cond for 'factor != 0' condition, resulting
	in pre-r12-5295-g47de0b56ee455e code for the gimple insert.

libgomp/
	* testsuite/libgomp.c-c++-common/non-rect-loop-1.c: New test.
2023-08-19 07:49:06 +02:00
Guo Jie
3e31573638 Loongarch: Fix plugin header missing install.
gcc/ChangeLog:

	* config/loongarch/t-loongarch: Add loongarch-driver.h into
	TM_H. Add loongarch-def.h and loongarch-tune.h into
	OPTIONS_H_EXTRA.

Co-authored-by: Lulu Cheng <chenglulu@loongson.cn>
2023-08-19 11:46:28 +08:00
GCC Administrator
4acbb51d7f Daily bump. 2023-08-19 00:16:36 +00:00