]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 years agoRISC-V: Support CALL for RVV floating-point dynamic rounding
Pan Li [Wed, 19 Jul 2023 03:00:52 +0000 (11:00 +0800)] 
RISC-V: Support CALL for RVV floating-point dynamic rounding

In basic dynamic rounding mode, we simply ignore call instructions and
we would like to take care of call in this PATCH.

During the call, the frm may be updated or keep as is. Thus, we must
make sure at least 2 things.

1. The static frm before call should not pollute the frm value in call.
2. The updated frm value in call should be sticky after call completed.

We will perfrom some steps to make above happen.

1. Mark call instruction with new mode DYN_CALL.
2. Mark the instruction after CALL from NONE to DYN.
3. When emit for a DYN_CALL, we will restore the frm value.
4. When emit from a DYN_CALL, we will backup the frm value.

Let's take a flow for this.

           +-------------+
           | Entry (DYN) | <- frrm a5
           +-------------+
          /               \
    +-------+             +-----------+
    | VFADD |             | VFADD RTZ |  <- fsrmi 1(RTZ)
    +-------+             +-----------+
          |                    |
    +-------+             +-----------+
    | CALL  |             | CALL      |  <- fsrm a5
    +-------+             +-----------+
          |                       |
+-----------+                 +-------+
| SHIFT     | <- frrm a5      | VFADD |  <- frrm a5
+-----------+                 +-------+
          |                  /
+-----------+               /
| VFADD RUP | <- fsrm1 3(RUP)
+-----------+             /
           \             /
            +-----------------+
            | Exit (DYN_EXIT) | <- fsrm a5
            +-----------------+

When call is the last insn of one bb, we take care of it when needed
for each insn by inserting one frm backup (frrm) insn to the end of
the current bb.

Signed-off-by: Pan Li <pan2.li@intel.com>
Co-Authored-By: Juzhe-Zhong <juzhe.zhong@rivai.ai>
gcc/ChangeLog:

* config/riscv/riscv.cc (DYNAMIC_FRM_RTL): New macro.
(STATIC_FRM_P): Ditto.
(struct mode_switching_info): New struct for mode switching.
(struct machine_function): Add new field mode switching.
(riscv_emit_frm_mode_set): Add DYN_CALL emit.
(riscv_frm_adjust_mode_after_call): New function for call mode.
(riscv_frm_emit_after_call_in_bb_end): New function for emit
insn when call as the end of bb.
(riscv_frm_mode_needed): New function for frm mode needed.
(frm_unknown_dynamic_p): Remove call check.
(riscv_mode_needed): Extrac function for frm.
(riscv_frm_mode_after): Add DYN_CALL after.
(riscv_mode_entry): Remove backup rtl initialization.
* config/riscv/vector.md (frm_mode): Add dyn_call.
(fsrmsi_restore_exit): Rename to _volatile.
(fsrmsi_restore_volatile): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/float-point-frm-insert-7.c: Adjust
test cases.
* gcc.target/riscv/rvv/base/float-point-frm-run-1.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-run-2.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-frm-run-3.c: Ditto.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-33.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-34.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-35.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-36.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-37.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-38.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-39.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-40.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-41.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-42.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-43.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-44.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-45.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-46.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-47.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-48.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-49.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-50.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-51.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-52.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-53.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-54.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-55.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-56.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-57.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-58.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-59.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-60.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-61.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-62.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-63.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-64.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-65.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-66.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-67.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-68.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-69.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-70.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-71.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-72.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-73.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-74.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-75.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-76.c: New test.
* gcc.target/riscv/rvv/base/float-point-dynamic-frm-77.c: New test.
* gcc.target/riscv/rvv/base/float-point-frm-run-4.c: New test.
* gcc.target/riscv/rvv/base/float-point-frm-run-5.c: New test.
* gcc.target/riscv/rvv/base/float-point-frm-run.h: New test.

2 years agoRISC-V: Support RVV VFSUB and VFRSUB rounding mode intrinsic API
Pan Li [Tue, 1 Aug 2023 06:42:31 +0000 (14:42 +0800)] 
RISC-V: Support RVV VFSUB and VFRSUB rounding mode intrinsic API

This patch would like to support the rounding mode API for both the
VFSUB and VFRSUB as below samples.

* __riscv_vfsub_vv_f32m1_rm
* __riscv_vfsub_vv_f32m1_rm_m
* __riscv_vfsub_vf_f32m1_rm
* __riscv_vfsub_vf_f32m1_rm_m
* __riscv_vfrsub_vf_f32m1_rm
* __riscv_vfrsub_vf_f32m1_rm_m

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

* config/riscv/riscv-vector-builtins-bases.cc
(class reverse_binop_frm): Add new template for reversed frm.
(vfsub_frm_obj): New obj.
(vfrsub_frm_obj): Likewise.
* config/riscv/riscv-vector-builtins-bases.h:
(vfsub_frm): New declaration.
(vfrsub_frm): Likewise.
* config/riscv/riscv-vector-builtins-functions.def
(vfsub_frm): New function define.
(vfrsub_frm): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/float-point-single-rsub.c: New test.
* gcc.target/riscv/rvv/base/float-point-single-sub.c: New test.

2 years agoAdjust testcase for more optimal codegen.
liuhongt [Tue, 1 Aug 2023 04:48:21 +0000 (12:48 +0800)] 
Adjust testcase for more optimal codegen.

After
b9d7140c80bd3c7355b8291bb46f0895dcd8c3cb is the first bad commit
commit b9d7140c80bd3c7355b8291bb46f0895dcd8c3cb
Author: Jan Hubicka <jh@suse.cz>
Date:   Fri Jul 28 09:16:09 2023 +0200

    loop-split improvements, part 1

Now we have
    vpbroadcastd %ecx, %xmm0
    vpaddd .LC3(%rip), %xmm0, %xmm0
    vpextrd $3, %xmm0, %eax
    vmovddup %xmm3, %xmm0
    vrndscalepd $9, %xmm0, %xmm0
    vunpckhpd %xmm0, %xmm0, %xmm3

for vrndscalepd, no need to insert pxor since it reuses input register
xmm0 to avoid partial sse dependece.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr87007-4.c: Adjust testcase.
* gcc.target/i386/pr87007-5.c: Ditto.

2 years agoc-family: Implement pragma_lex () for preprocess-only mode
Lewis Hyatt [Fri, 30 Jun 2023 22:23:24 +0000 (18:23 -0400)] 
c-family: Implement pragma_lex () for preprocess-only mode

In order to support processing #pragma in preprocess-only mode (-E or
-save-temps for gcc/g++), we need a way to obtain the #pragma tokens from
libcpp. In full compilation modes, this is accomplished by calling
pragma_lex (), which is a symbol that must be exported by the frontend, and
which is currently implemented for C and C++. Neither of those frontends
initializes its parser machinery in preprocess-only mode, and consequently
pragma_lex () does not work in this case.

Address that by adding a new function c_init_preprocess () for the frontends
to implement, which arranges for pragma_lex () to work in preprocess-only
mode, and adjusting pragma_lex () accordingly.

In preprocess-only mode, the preprocessor is accustomed to controlling the
interaction with libcpp, and it only knows about tokens that it has called
into libcpp itself to obtain. Since it still needs to see the tokens
obtained by pragma_lex () so that they can be streamed to the output, also
adjust c_lex_with_flags () and related functions in c-family/c-lex.cc to
inform the preprocessor about any tokens it won't be aware of.

Currently, there is one place where we are already supporting #pragma in
preprocess-only mode, namely the handling of `#pragma GCC diagnostic'.  That
was done by directly interfacing with libcpp, rather than making use of
pragma_lex (). Now that pragma_lex () works, that code is no longer
necessary; remove it.

gcc/c-family/ChangeLog:

* c-common.h (c_init_preprocess): Declare new function.
* c-opts.cc (c_common_init): Call it.
* c-lex.cc (cb_def_pragma): Add a comment.
(get_token): New function wrapping cpp_get_token.
(c_lex_with_flags): Use the new wrapper function to support
obtaining tokens in preprocess_only mode.
(lex_string): Likewise.
* c-pragma.cc (pragma_diagnostic_lex_normal): Rename to...
(pragma_diagnostic_lex): ...this.
(pragma_diagnostic_lex_pp): Remove.
(handle_pragma_diagnostic_impl): Call pragma_diagnostic_lex () in
all modes.
(c_pp_invoke_early_pragma_handler): Adapt to support pragma_lex ()
usage.
* c-pragma.h (pragma_lex_discard_to_eol): Declare.

gcc/c/ChangeLog:

* c-parser.cc (pragma_lex_discard_to_eol): New function.
(c_init_preprocess): New function.

gcc/cp/ChangeLog:

* parser.cc (c_init_preprocess): New function.
(maybe_read_tokens_for_pragma_lex): New function.
(pragma_lex): Support preprocess-only mode.
(pragma_lex_discard_to_eol): New function.

2 years agoPR modula2/110865 Unable to access copied const array
Gaius Mulley [Tue, 1 Aug 2023 00:42:16 +0000 (01:42 +0100)] 
PR modula2/110865 Unable to access copied const array

This patch allows constants of an array type to be indexed.

gcc/m2/ChangeLog:

PR modula2/110865
* gm2-compiler/M2Quads.mod (BuildDesignatorArray):
Rename t as type and d as dim.  New variable result.
Allow constants of an array type to be indexed.

gcc/testsuite/ChangeLog:

PR modula2/110865
* gm2/iso/pass/constvec.mod: New test.
* gm2/iso/pass/constvec2.mod: New test.
* gm2/iso/run/pass/constvec3.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 years agoDaily bump.
GCC Administrator [Tue, 1 Aug 2023 00:18:39 +0000 (00:18 +0000)] 
Daily bump.

2 years agoFix PR 93044: extra cast is not removed
Andrew Pinski [Sun, 23 Jul 2023 21:44:39 +0000 (21:44 +0000)] 
Fix PR 93044: extra cast is not removed

In this case we are not removing convert to a bigger size
back to the same size (or smaller) if signedness does not
match.
For an example:
```
  signed char _1;
...
  _1 = *a_4(D);
  b_5 = (short unsigned int) _1;
  _2 = (unsigned char) b_5;
```
The inner cast is not needed and can be removed but was not.
The match pattern for removing the extra cast is overly
complex so decided to add a new case for rather than trying
to modify the current if statement here.

Committed as approved. Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

PR tree-optimization/93044
* match.pd (nested int casts): A truncation (to the same size or smaller)
can always remove the inner cast.

gcc/testsuite/ChangeLog:

PR tree-optimization/93044
* gcc.dg/tree-ssa/cast-1.c: New test.
* gcc.dg/tree-ssa/cast-2.c: New test.

2 years agolibbacktrace: look for _pgmptr on Windows
Ian Lance Taylor [Mon, 31 Jul 2023 23:14:58 +0000 (16:14 -0700)] 
libbacktrace: look for _pgmptr on Windows

Patch from Andres Freund:
* configure.ac: Check for _pgmptr declaration.
* fileline.c (fileline_initialize): Check for _pgmfptr before
/proc/self/exec.
* configure, config.h.in: Regenerate.

2 years agoc: add -Wmissing-variable-declarations [PR65213]
Hamza Mahfooz [Mon, 31 Jul 2023 19:03:47 +0000 (19:03 +0000)] 
c: add -Wmissing-variable-declarations [PR65213]

Resolves:
PR c/65213 - Extend -Wmissing-declarations to variables [i.e. add
-Wmissing-variable-declarations]

gcc/c-family/ChangeLog:

PR c/65213
* c.opt (-Wmissing-variable-declarations): New option.

gcc/c/ChangeLog:

PR c/65213
* c-decl.cc (start_decl): Handle
-Wmissing-variable-declarations.

gcc/ChangeLog:

PR c/65213
* doc/invoke.texi (-Wmissing-variable-declarations): Document
new option.

gcc/testsuite/ChangeLog:

PR c/65213
* gcc.dg/Wmissing-variable-declarations.c: New test.

Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>
2 years agoMATCH: Add `a == b | a cmp b` and `a != b & a cmp b` simplifications
Andrew Pinski [Sun, 30 Jul 2023 04:52:31 +0000 (21:52 -0700)] 
MATCH: Add `a == b | a cmp b` and `a != b & a cmp b` simplifications

Even though these are done by combine_comparisons, we can add them to match
to allow simplifcations during match rather than just during reassoc/ifcombine.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

PR tree-optimization/106164
* match.pd (`a != b & a <= b`, `a != b & a >= b`,
`a == b | a < b`, `a == b | a > b`): Handle these cases
too.

gcc/testsuite/ChangeLog:

PR tree-optimization/106164
* gcc.dg/tree-ssa/cmpbit-2.c: New test.

2 years agoMATCH: PR 106164 : Optimize `(X CMP1 Y) AND/IOR (X CMP2 Y)`
Andrew Pinski [Sat, 29 Jul 2023 23:59:10 +0000 (16:59 -0700)] 
MATCH: PR 106164 : Optimize `(X CMP1 Y) AND/IOR (X CMP2 Y)`

I noticed that there are patterns that optimize
`(X CMP1 CST1) AND/IOR (X CMP2 CST2)` and we can easily extend
them to support the  `(X CMP1 Y) AND/IOR (X CMP2 Y)` by saying they
compare equal. This allows for this kind of optimization for integral
and pointer types (which have the same semantics).

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

PR tree-optimization/106164
* match.pd: Extend the `(X CMP1 CST1) AND/IOR (X CMP2 CST2)`
patterns to support `(X CMP1 Y) AND/IOR (X CMP2 Y)`.

gcc/testsuite/ChangeLog:

PR tree-optimization/106164
* gcc.dg/tree-ssa/cmpbit-1.c: New test.

2 years agotree-optimization: [PR100864] `(a&!b) | b` is not opimized to `a | b` for comparisons
Andrew Pinski [Sat, 29 Jul 2023 03:27:03 +0000 (20:27 -0700)] 
tree-optimization: [PR100864] `(a&!b) | b` is not opimized to `a | b` for comparisons

This is a new version of the patch.
Instead of doing the matching of inversion comparison directly inside
match, creating a new function (bitwise_inverted_equal_p) to do it.
It is very similar to bitwise_equal_p that was added in r14-2751-g2a3556376c69a1fb
but instead it says `expr1 == ~expr2`. A follow on patch, will
use this function in other patterns where we try to match `@0` and `(bit_not @0)`.

Changed the name bitwise_not_equal_p to bitwise_inverted_equal_p.

Committed as approved after a Bootstrapped and test on x86_64-linux-gnu with no regressions.

PR tree-optimization/100864

gcc/ChangeLog:

* generic-match-head.cc (bitwise_inverted_equal_p): New function.
* gimple-match-head.cc (bitwise_inverted_equal_p): New macro.
(gimple_bitwise_inverted_equal_p): New function.
* match.pd ((~x | y) & x): Use bitwise_inverted_equal_p
instead of direct matching bit_not.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/bitops-3.c: New test.

2 years agoRe: [PATCH] gcc-ar: Handle response files properly [PR77576]
Costas Argyris [Mon, 31 Jul 2023 16:56:20 +0000 (10:56 -0600)] 
Re: [PATCH] gcc-ar: Handle response files properly [PR77576]

Problem: gcc-ar fails when a @file is passed to it:

$ cat rsp
--version
$ gcc-ar @rsp
/usr/bin/ar: invalid option -- '@'

This is because a dash '-' is prepended to the first
argument if it doesn't start with one, resulting in
the wrong call 'ar -@rsp'.

Fix: Expand argv to get rid of any @files and if any
expansions were made, pass everything through a
temporary response file.

$ gcc-ar @rsp
GNU ar (GNU Binutils for Debian) 2.35.2
...

gcc/
PR driver/77576
* gcc-ar.cc (main): Expand argv and use
temporary response file to call ar if any
expansions were made.

2 years agofur_list should not use the range vector for non-ssa operands.
Andrew MacLeod [Mon, 31 Jul 2023 14:08:51 +0000 (10:08 -0400)] 
fur_list should not use the range vector for non-ssa operands.

gcc/
PR tree-optimization/110582
* gimple-range-fold.cc (fur_list::get_operand): Do not use the
range vector for non-ssa names.

gcc/testsuite/
* gcc.dg/pr110582.c: New.

2 years agoUpdate gcc sv.po
Joseph Myers [Mon, 31 Jul 2023 15:59:37 +0000 (15:59 +0000)] 
Update gcc sv.po

* sv.po: Update.

2 years agoSARIF and -ftime-report's output [PR109361]
David Malcolm [Mon, 31 Jul 2023 15:13:02 +0000 (11:13 -0400)] 
SARIF and -ftime-report's output [PR109361]

This patch adds support for embeddding profiling information about the
compiler itself into the SARIF output.

Specifically, if SARIF diagnostic output is requested, via
-fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr,
then any -ftime-report output is written in JSON form into the SARIF
output, rather than to stderr.

In earlier versions of this patch I extended -ftime-report so that
*as well* as writing to stderr, it would embed the information in any
SARIF output.  This turned out to be awkward to use, in that I found
myself needing to get the data in JSON form without also having it
emitted on stderr (which was fouling my build scripts).

The timing information is written to the SARIF as a "gcc/timeReport"
property within a property bag of the "invocation" object.

Here's an example of the output:

  "invocations": [
      {
          "executionSuccessful": true,
          "toolExecutionNotifications": [],
          "properties": {
              "gcc/timeReport": {
                  "timevars": [
                      {
                          "name": "phase setup",
                          "elapsed": {
                              "user": 0.04,
                              "sys": 0,
                              "wall": 0.04,
                              "ggc_mem": 1863472
                          }
                      },

                      [...snip...]

                      {
                          "name": "analyzer: processing worklist",
                          "elapsed": {
                              "user": 0.06,
                              "sys": 0,
                              "wall": 0.06,
                              "ggc_mem": 48
                          }
                      },
                      {
                          "name": "analyzer: emitting diagnostics",
                          "elapsed": {
                              "user": 0.01,
                              "sys": 0,
                              "wall": 0.01,
                              "ggc_mem": 0
                          }
                      },
                      {
                          "name": "TOTAL",
                          "elapsed": {
                              "user": 0.21,
                              "sys": 0.03,
                              "wall": 0.24,
                              "ggc_mem": 3368736
                          }
                      }
                  ],
                  "CHECKING_P": true,
                  "flag_checking": true
              }
          }
      }
  ]

The documentation notes that the precise output format is subject
to change.

I have successfully used this in my analyzer integration tests to get
timing information about which source files get slowed down by the
analyzer.  I've validated the generated .sarif files against the SARIF
schema.

gcc/ChangeLog:
PR analyzer/109361
* diagnostic-client-data-hooks.h (class sarif_object): New forward
decl.
(diagnostic_client_data_hooks::add_sarif_invocation_properties):
New vfunc.
* diagnostic-format-sarif.cc: Include "diagnostic-format-sarif.h".
(class sarif_invocation): Inherit from sarif_object rather than
json::object.
(class sarif_result): Likewise.
(class sarif_ice_notification): Likewise.
(sarif_object::get_or_create_properties): New.
(sarif_invocation::prepare_to_flush): Add "context" param.  Use it
to call the context's add_sarif_invocation_properties hook.
(sarif_builder::flush_to_file): Pass m_context to
sarif_invocation::prepare_to_flush.
* diagnostic-format-sarif.h: New header.
* doc/invoke.texi (Developer Options): Clarify that -ftime-report
writes to stderr.  Document that if SARIF diagnostic output is
requested then any timing information is written in JSON form as
part of the SARIF output, rather than to stderr.
* timevar.cc: Include "json.h".
(timer::named_items::m_hash_map): Split out type into...
(timer::named_items::hash_map_t): ...this new typedef.
(timer::named_items::make_json): New function.
(timevar_diff): New function.
(make_json_for_timevar_time_def): New function.
(timer::timevar_def::make_json): New function.
(timer::make_json): New function.
* timevar.h (class json::value): New forward decl.
(timer::make_json): New decl.
(timer::timevar_def::make_json): New decl.
* tree-diagnostic-client-data-hooks.cc: Include
"diagnostic-format-sarif.h" and "timevar.h".
(compiler_data_hooks::add_sarif_invocation_properties): New vfunc
implementation.

gcc/testsuite/ChangeLog:
PR analyzer/109361
* c-c++-common/diagnostic-format-sarif-file-timevars-1.c: New test.
* c-c++-common/diagnostic-format-sarif-file-timevars-2.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoOpenACC 2.7: host_data must have use_device clause requirement
Chung-Lin Tang [Mon, 31 Jul 2023 14:53:24 +0000 (07:53 -0700)] 
OpenACC 2.7: host_data must have use_device clause requirement

This patch implements the OpenACC 2.7 change requiring the host_data construct
to have at least one use_device clause.

gcc/c/ChangeLog:
* c-parser.cc (c_parser_oacc_host_data): Add checking requiring OpenACC
host_data construct to have an use_device clause.

gcc/cp/ChangeLog:
* parser.cc (cp_parser_oacc_host_data): Add checking requiring OpenACC
host_data construct to have an use_device clause.

gcc/fortran/ChangeLog:
* openmp.cc (resolve_omp_clauses): Add checking requiring
OpenACC host_data construct to have an use_device clause.

gcc/testsuite/ChangeLog:
* c-c++-common/goacc/host_data-2.c: Adjust testcase.
* gfortran.dg/goacc/host_data-error.f90: New testcase.
* gfortran.dg/goacc/pr71704.f90: Adjust testcase.

2 years agocombine: Narrow comparison of memory and constant
Stefan Schulze Frielinghaus [Mon, 31 Jul 2023 14:35:33 +0000 (16:35 +0200)] 
combine: Narrow comparison of memory and constant

Comparisons between memory and constants might be done in a smaller mode
resulting in smaller constants which might finally end up as immediates
instead of in the literal pool.

For example, on s390x a non-symmetric comparison like
  x <= 0x3fffffffffffffff
results in the constant being spilled to the literal pool and an 8 byte
memory comparison is emitted.  Ideally, an equivalent comparison
  x0 <= 0x3f
where x0 is the most significant byte of x, is emitted where the
constant is smaller and more likely to materialize as an immediate.

Similarly, comparisons of the form
  x >= 0x4000000000000000
can be shortened into x0 >= 0x40.

gcc/ChangeLog:

* combine.cc (simplify_compare_const): Narrow comparison of
memory and constant.
(try_combine): Adapt new function signature.
(simplify_comparison): Adapt new function signature.

gcc/testsuite/ChangeLog:

* gcc.dg/cmp-mem-const-1.c: New test.
* gcc.dg/cmp-mem-const-2.c: New test.
* gcc.dg/cmp-mem-const-3.c: New test.
* gcc.dg/cmp-mem-const-4.c: New test.
* gcc.dg/cmp-mem-const-5.c: New test.
* gcc.dg/cmp-mem-const-6.c: New test.
* gcc.target/s390/cmp-mem-const-1.c: New test.

2 years agoRISC-V: Drop unused variable
Kito Cheng [Mon, 31 Jul 2023 13:43:16 +0000 (21:43 +0800)] 
RISC-V: Drop unused variable

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vec_series): Drop unused
variable.
(expand_vector_init_insert_elems): Ditto.

2 years agoAArch64: Do not increase the vect reduction latency by multiplying count [PR110625]
Hao Liu [Mon, 31 Jul 2023 12:53:37 +0000 (20:53 +0800)] 
AArch64: Do not increase the vect reduction latency by multiplying count [PR110625]

The new costs should only count reduction latency by multiplying count for
single_defuse_cycle.  For other situations, this will increase the reduction
latency a lot and miss vectorization opportunities.

Tested on aarch64-linux-gnu.

gcc/ChangeLog:

PR target/110625
* config/aarch64/aarch64.cc (count_ops): Only '* count' for
single_defuse_cycle while counting reduction_latency.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pr110625_1.c: New testcase.
* gcc.target/aarch64/pr110625_2.c: New testcase.

2 years agointernal-fn: Refine macro define of COND_* and COND_LEN_* internal functions
Ju-Zhe Zhong [Tue, 25 Jul 2023 12:58:32 +0000 (20:58 +0800)] 
internal-fn: Refine macro define of COND_* and COND_LEN_* internal functions

Hi, Richard and Richi.

Base on previous disscussions, we should make COND_* and COND_LEN_*
consistent.

So, this patch define these internal function together by these 2
wrappers:

  DEF_INTERNAL_OPTAB_FN (COND_##NAME, FLAGS, cond_##OPTAB, cond_##TYPE)        \
  DEF_INTERNAL_OPTAB_FN (COND_LEN_##NAME, FLAGS, cond_len_##OPTAB,             \
 cond_len_##TYPE)

    UNSIGNED_OPTAB, TYPE)                      \
  DEF_INTERNAL_SIGNED_OPTAB_FN (COND_##NAME, FLAGS, SELECTOR,                  \
cond_##SIGNED_OPTAB, cond_##UNSIGNED_OPTAB,    \
cond_##TYPE)                                   \
  DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_##NAME, FLAGS, SELECTOR,              \
cond_len_##SIGNED_OPTAB,                       \
cond_len_##UNSIGNED_OPTAB, cond_len_##TYPE)

Bootstrap and Regression on X86 passed.
Ok for trunk ?

gcc/ChangeLog:

* internal-fn.def (DEF_INTERNAL_COND_FN): New macro.
(DEF_INTERNAL_SIGNED_COND_FN): Ditto.
(COND_ADD): Remove.
(COND_SUB): Ditto.
(COND_MUL): Ditto.
(COND_DIV): Ditto.
(COND_MOD): Ditto.
(COND_RDIV): Ditto.
(COND_MIN): Ditto.
(COND_MAX): Ditto.
(COND_FMIN): Ditto.
(COND_FMAX): Ditto.
(COND_AND): Ditto.
(COND_IOR): Ditto.
(COND_XOR): Ditto.
(COND_SHL): Ditto.
(COND_SHR): Ditto.
(COND_FMA): Ditto.
(COND_FMS): Ditto.
(COND_FNMA): Ditto.
(COND_FNMS): Ditto.
(COND_NEG): Ditto.
(COND_LEN_ADD): Ditto.
(COND_LEN_SUB): Ditto.
(COND_LEN_MUL): Ditto.
(COND_LEN_DIV): Ditto.
(COND_LEN_MOD): Ditto.
(COND_LEN_RDIV): Ditto.
(COND_LEN_MIN): Ditto.
(COND_LEN_MAX): Ditto.
(COND_LEN_FMIN): Ditto.
(COND_LEN_FMAX): Ditto.
(COND_LEN_AND): Ditto.
(COND_LEN_IOR): Ditto.
(COND_LEN_XOR): Ditto.
(COND_LEN_SHL): Ditto.
(COND_LEN_SHR): Ditto.
(COND_LEN_FMA): Ditto.
(COND_LEN_FMS): Ditto.
(COND_LEN_FNMA): Ditto.
(COND_LEN_FNMS): Ditto.
(COND_LEN_NEG): Ditto.
(ADD): New macro define.
(SUB): Ditto.
(MUL): Ditto.
(DIV): Ditto.
(MOD): Ditto.
(RDIV): Ditto.
(MIN): Ditto.
(MAX): Ditto.
(FMIN): Ditto.
(FMAX): Ditto.
(AND): Ditto.
(IOR): Ditto.
(XOR): Ditto.
(SHL): Ditto.
(SHR): Ditto.
(FMA): Ditto.
(FMS): Ditto.
(FNMA): Ditto.
(FNMS): Ditto.
(NEG): Ditto.

2 years agoUse substituted GDCFLAGS
Andreas Schwab [Sun, 16 Jul 2023 17:43:56 +0000 (19:43 +0200)] 
Use substituted GDCFLAGS

Use the substituted value for GCDFLAGS instead of hardcoding $(CFLAGS) so
that the subdir configure scripts use the configured value.

* configure.ac (GDCFLAGS): Set default from ${CFLAGS}.
* configure: Regenerate.
* Makefile.in (GDCFLAGS): Substitute @GDCFLAGS@.

2 years ago[Committed] PR target/110843: Check TARGET_AVX512VL for V2DI rotates in STV.
Roger Sayle [Mon, 31 Jul 2023 07:08:11 +0000 (08:08 +0100)] 
[Committed] PR target/110843: Check TARGET_AVX512VL for V2DI rotates in STV.

This patch resolves PR target/110843, an ICE caused by my enhancement to
support AVX512 DImode and SImode rotates in the scalar-to-vector (STV) pass.
Although the vprotate instructions are available on all TARGET_AVX512F
microarchitectures, the V2DI and V4SI variants are only available on the
TARGET_AVX512VL subset, leading to problems when command line options
enable AVX512 (i.e. AVX512F) but not the required AVX512VL functionality.
The simple fix is to update/correct the target checks.

2023-07-31  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR target/110843
* config/i386/i386-features.cc (compute_convert_gain): Check
TARGET_AVX512VL (not TARGET_AVX512F) when considering V2DImode
and V4SImode rotates in STV.
(general_scalar_chain::convert_rotate): Likewise.

gcc/testsuite/ChangeLog
PR target/110843
* gcc.target/i386/pr110843.c: New test case.

2 years agoRISC-V: Return machine_mode rather than opt_machine_mode for get_mask_mode, NFC
Kito Cheng [Mon, 31 Jul 2023 03:03:16 +0000 (11:03 +0800)] 
RISC-V: Return machine_mode rather than opt_machine_mode for get_mask_mode, NFC

We always want get_mask_mode return a valid mode, it's something wrong
if it failed, so I think we could just move the `.require ()` into
get_mask_mode, instead of calling that every call-site.

The only exception is riscv_get_mask_mode, it might put supported mode
into get_mask_mode, so added a check with riscv_v_ext_mode_p to make
sure only valid vector mode will ask get_mask_mode.

gcc/ChangeLog:

* config/riscv/autovec.md (abs<mode>2): Remove `.require ()`.
* config/riscv/riscv-protos.h (get_mask_mode): Update return
type.
* config/riscv/riscv-v.cc (rvv_builder::rvv_builder): Remove
`.require ()`.
(emit_vlmax_insn): Ditto.
(emit_vlmax_fp_insn): Ditto.
(emit_vlmax_ternary_insn): Ditto.
(emit_vlmax_fp_ternary_insn): Ditto.
(emit_nonvlmax_fp_ternary_tu_insn): Ditto.
(emit_nonvlmax_insn): Ditto.
(emit_vlmax_slide_insn): Ditto.
(emit_nonvlmax_slide_tu_insn): Ditto.
(emit_vlmax_merge_insn): Ditto.
(emit_vlmax_masked_insn): Ditto.
(emit_nonvlmax_masked_insn): Ditto.
(emit_vlmax_masked_store_insn): Ditto.
(emit_nonvlmax_masked_store_insn): Ditto.
(emit_vlmax_masked_mu_insn): Ditto.
(emit_nonvlmax_tu_insn): Ditto.
(emit_nonvlmax_fp_tu_insn): Ditto.
(emit_scalar_move_insn): Ditto.
(emit_vlmax_compress_insn): Ditto.
(emit_vlmax_reduction_insn): Ditto.
(emit_vlmax_fp_reduction_insn): Ditto.
(emit_nonvlmax_fp_reduction_insn): Ditto.
(expand_vec_series): Ditto.
(expand_vector_init_merge_repeating_sequence): Ditto.
(expand_vec_perm): Ditto.
(shuffle_merge_patterns): Ditto.
(shuffle_compress_patterns): Ditto.
(shuffle_decompress_patterns): Ditto.
(expand_reduction): Ditto.
(get_mask_mode): Update return type.
* config/riscv/riscv.cc (riscv_get_mask_mode): Check vector type
is valid, and use new get_mask_mode interface.

2 years agoRISC-V: Bugfix for RVV floating-point rm suffix sequence
Pan Li [Mon, 31 Jul 2023 02:51:33 +0000 (10:51 +0800)] 
RISC-V: Bugfix for RVV floating-point rm suffix sequence

According to below RVV intrinsic doc, the RVV floating-point intrinsic name
with rounding mode should be:

_rm_m

instead of:

_m_rm

https://github.com/riscv-non-isa/rvv-intrinsic-doc/pull/226

This patch fix this naming sequence issue and adjust the test cases.

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

* config/riscv/riscv-vector-builtins-shapes.cc (struct alu_frm_def):
Move rm suffix before mask.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/float-point-frm-insert-1.c: Adjust
test cases.
* gcc.target/riscv/rvv/base/float-point-frm.c: Ditto.

2 years agoRISC-V: Enable basic VLS auto-vectorization
Juzhe-Zhong [Mon, 31 Jul 2023 02:13:57 +0000 (10:13 +0800)] 
RISC-V: Enable basic VLS auto-vectorization

Consider this following case:
void
foo (int8_t *in, int8_t *out, int8_t x)
{
  for (int i = 0; i < 16; i++)
    in[i] = x;
}

Compile option: --param=riscv-autovec-preference=scalable -fno-builtin

Before this patch:

foo:
        li      a5,16
        csrr    a4,vlenb
        vsetvli a3,zero,e8,m1,ta,ma
        vmv.v.x v1,a2
        bleu    a5,a4,.L2
        mv      a5,a4
.L2:
        vsetvli zero,a5,e8,m1,ta,ma
        vse8.v  v1,0(a0)
        ret

After this patch:

foo:
vsetivli zero,16,e8,mf8,ta,ma
vmv.v.x v1,a2
vse8.v v1,0(a0)
ret

gcc/ChangeLog:

* config/riscv/autovec-vls.md (@vec_duplicate<mode>): New pattern.
* config/riscv/riscv-v.cc (autovectorize_vector_modes): Add VLS autovec
support.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/v-1.c: Adapt test.
* gcc.target/riscv/rvv/autovec/zve32f_zvl128b-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/zve64d_zvl128b-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/zve64f_zvl128b-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/dup-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/dup-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/dup-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/dup-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/dup-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/dup-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/dup-7.c: New test.

2 years agoMAINTAINERS: Add myself to write after approval
xuli [Mon, 31 Jul 2023 01:18:00 +0000 (01:18 +0000)] 
MAINTAINERS: Add myself to write after approval

Signed-off-by: Li Xu <xuli1@eswincomputing.com>
ChangeLog:

* MAINTAINERS: Add myself.

2 years agoDaily bump.
GCC Administrator [Mon, 31 Jul 2023 00:16:58 +0000 (00:16 +0000)] 
Daily bump.

2 years agolibstdc++: Fix several preprocessor directives
François Dumont [Fri, 28 Jul 2023 17:17:03 +0000 (19:17 +0200)] 
libstdc++: Fix several preprocessor directives

A wrong usage of #define in place of a #error seems to have been replicated
at different places in source files.

libstdc++-v3/ChangeLog:

* src/c++11/compatibility-ldbl-facets-aliases.h: Replace #define with
proper #error.
* src/c++11/locale-inst-monetary.h: Likewise.
* src/c++11/locale-inst-numeric.h: Likewise.

2 years agoDaily bump.
GCC Administrator [Sun, 30 Jul 2023 00:17:03 +0000 (00:17 +0000)] 
Daily bump.

2 years ago[Committed] Use QImode for offsets in zero_extract/sign_extract in i386.md
Roger Sayle [Sat, 29 Jul 2023 16:07:58 +0000 (17:07 +0100)] 
[Committed] Use QImode for offsets in zero_extract/sign_extract in i386.md

As suggested by Uros, this patch changes the ZERO_EXTRACTs and SIGN_EXTRACTs
in i386.md to consistently use QImode for bit offsets (i.e. third and fourth
operands), matching the use of QImode for bit counts in shifts and rotates.

This iteration also corrects the "ne:QI" vs "eq:QI" mistake in the previous
version, which was responsible for PR 110787 and PR 110790 and so was
rapidly reverted last weekend.  New test cases have been added to check
the correct behaviour.

2023-07-29  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR target/110790
* config/i386/i386.md (extv<mode>): Use QImode for offsets.
(extzv<mode>): Likewise.
(insv<mode>): Likewise.
(*testqi_ext_3): Likewise.
(*btr<mode>_2): Likewise.
(define_split): Likewise.
(*btsq_imm): Likewise.
(*btrq_imm): Likewise.
(*btcq_imm): Likewise.
(define_peephole2 x3): Likewise.
(*bt<mode>): Likewise
(*bt<mode>_mask): New define_insn_and_split.
(*jcc_bt<mode>): Use QImode for offsets.
(*jcc_bt<mode>_1): Delete obsolete pattern.
(*jcc_bt<mode>_mask): Use QImode offsets.
(*jcc_bt<mode>_mask_1): Likewise.
(define_split): Likewise.
(*bt<mode>_setcqi): Likewise.
(*bt<mode>_setncqi): Likewise.
(*bt<mode>_setnc<mode>): Likewise.
(*bt<mode>_setncqi_2): Likewise.
(*bt<mode>_setc<mode>_mask): New define_insn_and_split.
(bmi2_bzhi_<mode>3): Use QImode offsets.
(*bmi2_bzhi_<mode>3): Likewise.
(*bmi2_bzhi_<mode>3_1): Likewise.
(*bmi2_bzhi_<mode>3_1_ccz): Likewise.
(@tbm_bextri_<mode>): Likewise.

gcc/testsuite/ChangeLog
PR target/110790
* gcc.target/i386/pr110790-1.c: New test case.
* gcc.target/i386/pr110790-2.c: Likewise.

2 years agolibgomp: cuda.h and omp_target_memcpy_rect cleanup
Tobias Burnus [Sat, 29 Jul 2023 11:25:03 +0000 (13:25 +0200)] 
libgomp: cuda.h and omp_target_memcpy_rect cleanup

Fixes for commit r14-2792-g25072a477a56a727b369bf9b20f4d18198ff5894
"OpenMP: Call cuMemcpy2D/cuMemcpy3D for nvptx for omp_target_memcpy_rect",
namely:

In that commit, the code was changed to handle shared-memory devices;
however, as pointed out, omp_target_memcpy_check already set the pointer
to NULL in that case.  Hence, this commit reverts to the prior version.

In cuda.h, it adds cuMemcpyPeer{,Async} for symmetry for cuMemcpy3DPeer
(all currently unused) and in three structs, fixes reserved-member names
and remove a bogus 'const' in three structs.

And it changes a DLSYM to DLSYM_OPT as not all plugins support the new
functions, yet.

include/ChangeLog:

* cuda/cuda.h (CUDA_MEMCPY2D, CUDA_MEMCPY3D, CUDA_MEMCPY3D_PEER):
Remove bogus 'const' from 'const void *dst' and fix reserved-name
name in those structs.
(cuMemcpyPeer, cuMemcpyPeerAsync): Add.

libgomp/ChangeLog:

* target.c (omp_target_memcpy_rect_worker): Undo dim=1 change for
GOMP_OFFLOAD_CAP_SHARED_MEM.
(omp_target_memcpy_rect_copy): Likewise for lock condition.
(gomp_load_plugin_for_device): Use DLSYM_OPT not DLSYM for
memcpy3d/memcpy2d.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_memcpy2d,
GOMP_OFFLOAD_memcpy3d): Use memset 0 to nullify reserved and
unused src/dst fields for that mem type; remove '{src,dst}LOD = 0'.

2 years agoFix profile update after vectorize loop versioning
Jan Hubicka [Sat, 29 Jul 2023 06:19:08 +0000 (08:19 +0200)] 
Fix profile update after vectorize loop versioning

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/vect-profile-upate-2.c: New test.

2 years agoFix profile update after vectorize loop versioning
Jan Hubicka [Sat, 29 Jul 2023 06:18:18 +0000 (08:18 +0200)] 
Fix profile update after vectorize loop versioning

Vectorizer while loop versioning produces a versioned loop
guarded with two conditionals of the form

  if (cond1)
    goto scalar_loop
  else
    goto next_bb
next_bb:
  if (cond2)
    godo scalar_loop
  else
    goto vector_loop

It wants the combined test to be prob (whch is set to likely)
and uses profile_probability::split to determine probability
of cond1 and cond2.

However spliting  is turning:

     if (cond)
       goto lab; // ORIG probability
 into
     if (cond1)
       goto lab; // FIRST = ORIG * CPROB probability
     if (cond2)
       goto lab; // SECOND probability

Which is or instead of and.  As a result we get pretty low probabiility
of entering vectorized loop.

The fixes this by introducing sqrt to profile probability (which is correct
way to split this) and also adding pow that is needed elsewhere.

While loop versioning I now produce code as if there was only one combined
conditional and then update probability of conditional produced (containig
cond1).  Later edge is split and new conditional is added. At that time
it is necessary to update probability of the BB containing second conditional
so everything matches.

gcc/ChangeLog:

* profile-count.cc (profile_probability::sqrt): New member function.
(profile_probability::pow): Likewise.
* profile-count.h: (profile_probability::sqrt): Declare
(profile_probability::pow): Likewise.
* tree-vect-loop-manip.cc (vect_loop_versioning): Fix profile update.

2 years agoDaily bump.
GCC Administrator [Sat, 29 Jul 2023 00:17:43 +0000 (00:17 +0000)] 
Daily bump.

2 years agoAdd a merge_range to ssa_cache and use it. add empty_p and param tweaks.
Andrew MacLeod [Fri, 28 Jul 2023 15:00:57 +0000 (11:00 -0400)] 
Add a merge_range to ssa_cache and use it.  add empty_p and param tweaks.

* gimple-range-cache.cc (ssa_cache::merge_range): New.
(ssa_lazy_cache::merge_range): New.
* gimple-range-cache.h (class ssa_cache): Adjust protoypes.
(class ssa_lazy_cache): Ditto.
* gimple-range.cc (assume_query::calculate_op): Use merge_range.

2 years agoRemove value_query, push into sub&fold class
Andrew MacLeod [Sun, 16 Jul 2023 16:46:00 +0000 (12:46 -0400)] 
Remove value_query, push into sub&fold class

* tree-ssa-propagate.cc (substitute_and_fold_engine::value_on_edge):
Move from value-query.cc.
(substitute_and_fold_engine::value_of_stmt): Ditto.
(substitute_and_fold_engine::range_of_expr): New.
* tree-ssa-propagate.h (substitute_and_fold_engine): Inherit from
range_query.  New prototypes.
* value-query.cc (value_query::value_on_edge): Relocate.
(value_query::value_of_stmt): Ditto.
* value-query.h (class value_query): Remove.
(class range_query): Remove base class.  Adjust prototypes.

2 years agoFix some warnings
Andrew MacLeod [Mon, 10 Jul 2023 17:58:22 +0000 (13:58 -0400)] 
Fix some warnings

PR tree-optimization/110205
* gimple-range-cache.h (ranger_cache::m_estimate): Delete.
* range-op-mixed.h (operator_bitwise_xor::op1_op2_relation_effect):
Add final override.
* range-op.cc (operator_lshift): Add missing final overrides.
(operator_rshift): Ditto.

2 years agoUpdate gcc .po files
Joseph Myers [Fri, 28 Jul 2023 20:09:51 +0000 (20:09 +0000)] 
Update gcc .po files

* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
ja.po, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po,
zh_TW.po: Update.

2 years agobpf: disable tail call optimization in BPF targets
Jose E. Marchesi [Fri, 28 Jul 2023 19:01:08 +0000 (21:01 +0200)] 
bpf: disable tail call optimization in BPF targets

clang disables tail call optimizations in BPF targets.  Do the same in
GCC.

gcc/ChangeLog:

* config/bpf/bpf.cc (bpf_option_override): Disable tail-call
optimizations in BPF target.

2 years agoFortran: do not pass hidden character length for TYPE(*) dummy [PR110825]
Harald Anlauf [Thu, 27 Jul 2023 19:30:26 +0000 (21:30 +0200)] 
Fortran: do not pass hidden character length for TYPE(*) dummy [PR110825]

gcc/fortran/ChangeLog:

PR fortran/110825
* gfortran.texi: Clarify argument passing convention.
* trans-expr.cc (gfc_conv_procedure_call): Do not pass the character
length as hidden argument when the declared dummy argument is
assumed-type.

gcc/testsuite/ChangeLog:

PR fortran/110825
* gfortran.dg/assumed_type_18.f90: New test.

2 years agoCleanup profile updating code in unrolling and splitting
Honza [Fri, 28 Jul 2023 17:39:19 +0000 (19:39 +0200)] 
Cleanup profile updating code in unrolling and splitting

I have noticed that for all these three cases I need same update of
loop exit probability.  While my earlier patch unified it for unrollers,
this patch makes it more general and also simplifies
tree-ssa-loop-split.cc.

I also refactored the code, since with all the special cases for
corrupted profile it gets relatively long.
I now also handle multiple loop exits in RTL unroller.

Bootstrapped/regtested x86_64-linux, comitted.
gcc/ChangeLog:

* cfgloopmanip.cc (loop_count_in): Break out from ...
(loop_exit_for_scaling): Break out from ...
(update_loop_exit_probability_scale_dom_bbs): Break out from ...;
add more sanity check and debug info.
(scale_loop_profile): ... here.
(create_empty_loop_on_edge): Fix whitespac.
* cfgloopmanip.h (update_loop_exit_probability_scale_dom_bbs): Declare.
* loop-unroll.cc (unroll_loop_constant_iterations): Use
update_loop_exit_probability_scale_dom_bbs.
* tree-ssa-loop-manip.cc (update_exit_probability_after_unrolling): Remove.
(tree_transform_and_unroll_loop): Use
update_loop_exit_probability_scale_dom_bbs.
* tree-ssa-loop-split.cc (split_loop): Use
update_loop_exit_probability_scale_dom_bbs.

2 years agoRISC-V: Specify -mabi in rv64 autovec testcase
Patrick O'Neill [Fri, 28 Jul 2023 16:19:33 +0000 (09:19 -0700)] 
RISC-V: Specify -mabi in rv64 autovec testcase

On rv32 targets, this patch fixes:
FAIL: gcc.target/riscv/rvv/autovec/madd-split2-1.c -O3 -ftree-vectorize (test for excess errors)

cc1: error: ABI requires '-march=rv32'

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/madd-split2-1.c: Add -mabi=lp64d
to dg-options.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2 years agoc++: devirtualization of array destruction [PR110057]
Ng YongXiang [Thu, 27 Jul 2023 00:06:14 +0000 (08:06 +0800)] 
c++: devirtualization of array destruction [PR110057]

PR c++/110057
PR ipa/83054

gcc/cp/ChangeLog:

* init.cc (build_vec_delete_1): Devirtualize array destruction.

gcc/testsuite/ChangeLog:

* g++.dg/warn/pr83054.C: Remove devirtualization warning.
* g++.dg/lto/pr89335_0.C: Likewise.
* g++.dg/tree-ssa/devirt-array-destructor-1.C: New test.
* g++.dg/tree-ssa/devirt-array-destructor-2.C: New test.
* g++.dg/warn/pr83054-2.C: New test.

Signed-off-by: Ng Yong Xiang <yongxiangng@gmail.com>
2 years agoloop-split improvements, part 3
Jan Hubicka [Fri, 28 Jul 2023 14:18:32 +0000 (16:18 +0200)] 
loop-split improvements, part 3

extend tree-ssa-loop-split to understand test of the form
 if (i==0)
and
 if (i!=0)
which triggers only during the first iteration.  Naturally we should
also be able to trigger last iteration or split into 3 cases if
the test indeed can fire in the middle of the loop.

Last iteration is bit trickier pattern matching so I want to do it
incrementally, but I implemented easy case using value range that handled
loops with constant iterations.

The testcase gets misupdated profile, I will also fix that incrementally.

gcc/ChangeLog:

PR middle-end/77689
* tree-ssa-loop-split.cc: Include value-query.h.
(split_at_bb_p): Analyze cases where EQ/NE can be turned
into LT/LE/GT/GE; return updated guard code.
(split_loop): Use guard code.

gcc/testsuite/ChangeLog:

PR middle-end/77689
* g++.dg/tree-ssa/loop-split-1.C: New test.

2 years agoPR rtl-optimization/110587: Reduce useless moves in compile-time hog.
Roger Sayle [Fri, 28 Jul 2023 08:39:46 +0000 (09:39 +0100)] 
PR rtl-optimization/110587: Reduce useless moves in compile-time hog.

This patch is one of a series of fixes for PR rtl-optimization/110587,
a compile-time regression with -O0, that attempts to address the underlying
cause.  As noted previously, the pathological test case pr28071.c contains
a large number of useless register-to-register moves that can produce
quadratic behaviour (in LRA).  These moves are generated during RTL
expansion in emit_group_load_1, where the middle-end attempts to simplify
the source before calling extract_bit_field.  This is reasonable if the
source is a complex expression (from before the tree-ssa optimizers), or
a SUBREG, or a hard register, but it's not particularly useful to copy
a pseudo register into a new pseudo register.  This patch eliminates that
redundancy.

The -fdump-tree-expand for pr28071.c compiled with -O0 currently contains
777K lines, with this patch it contains 717K lines, i.e. saving about 60K
lines (admittedly of debugging text output, but it makes the point).

2023-07-28  Roger Sayle  <roger@nextmovesoftware.com>
    Richard Biener  <rguenther@suse.de>

gcc/ChangeLog
PR middle-end/28071
PR rtl-optimization/110587
* expr.cc (emit_group_load_1): Simplify logic for calling
force_reg on ORIG_SRC, to avoid making a copy if the source
is already in a pseudo register.

2 years agoloop-split improvements, part 2
Jan Hubicka [Fri, 28 Jul 2023 07:48:34 +0000 (09:48 +0200)] 
loop-split improvements, part 2

this patch fixes profile update in the first case of loop splitting.
The pass still gives up on very basic testcases:

__attribute__ ((noinline,noipa))
void test1 (int n)
{
  if (n <= 0 || n > 100000)
    return;
  for (int i = 0; i <= n; i++)
    {
      if (i < n)
do_something ();
      if (a[i])
do_something2();
    }
}

Here I needed to do the conditoinal that enforces sane value range of n.
The reason is that it gives up on:
      !number_of_iterations_exit (loop1, exit1, &niter, false, true)
and without the conditonal we get assumption that n>=0 and not INT_MAX.
I think from overflow we shold derive that INT_MAX test is not needed and since
the loop does nothing for n<0 it is also just an paranoia.

I am not sure how to fix this though :(.  In general the pass does not really
need to compute iteration count.  It only needs to know what direction the IVs
go so it can detect tests that fires in first part of iteration space.

Rich, any idea what the correct test should be?

In testcase:
  for (int i = 0; i < 200; i++)
    if (i < 150)
      do_something ();
    else
      do_something2 ();
the old code did wrong update of the exit condition probabilities.
We know that first loop iterates 150 times and the second loop 50 times
and we get it by simply scaling loop body by the probability of inner test.

With the patch we now get:

  <bb 2> [count: 1000]:

  <bb 3> [count: 150000]:    <- loop 1 correctly iterates 149 times
  # i_10 = PHI <i_7(8), 0(2)>
  do_something ();
  i_7 = i_10 + 1;
  if (i_7 <= 149)
    goto <bb 8>; [99.33%]
  else
    goto <bb 17>; [0.67%]

  <bb 8> [count: 149000]:
  goto <bb 3>; [100.00%]

  <bb 16> [count: 1000]:
  # i_15 = PHI <i_18(17)>

  <bb 9> [count: 49975]:    <- loop 2 should iterate 50 times but
       we are slightly wrong
  # i_3 = PHI <i_15(16), i_14(13)>
  do_something2 ();
  i_14 = i_3 + 1;
  if (i_14 != 200)
    goto <bb 13>; [98.00%]
  else
    goto <bb 7>; [2.00%]

  <bb 13> [count: 48975]:
  goto <bb 9>; [100.00%]

  <bb 17> [count: 1000]:   <- this test is always true becuase it is
      reached form bb 3
  # i_18 = PHI <i_7(3)>
  if (i_18 != 200)
    goto <bb 16>; [99.95%]
  else
    goto <bb 7>; [0.05%]

  <bb 7> [count: 1000]:
  return;

The reason why we are slightly wrong is the condtion in bb17 that
is always true but the pass does not konw it.

Rich any idea how to do that?  I think connect_loops should work out
the cas where the loop exit conditon is never satisfied at the time
the splitted condition fails for first time.

Before patch on hmmer we get a lot of mismatches:
Profile report here claims:
dump id |static mismat|dynamic mismatch                                     |
        |in count     |in count                  |time                      |
lsplit  |      5    +5|   8151850567  +8151850567531506481006       +57.9%|
ldist   |      9    +4|  15345493501  +7193642934606848841056       +14.2%|
ifcvt   |     10    +1|  15487514871   +142021370689469797790       +13.6%|
vect    |     35   +25|  17558425961  +2070911090517375405715       -25.0%|
cunroll |     42    +7|  16898736178   -659689783452445796198        -4.9%|
loopdone|     33    -9|   2678017188 -14220718990330969127663             |
tracer  |     34    +1|   2678018710        +1522| 330613415364        +0.0%|
fre     |     33    -1|   2676980249     -1038461330465677073        -0.0%|
expand  |     28    -5|   2497468467   -179511782|--------------------------|

With patch

lsplit  |      0      |            0             | 328723360744        -2.3%|
ldist   |      0      |            0             | 396193562452       +20.6%|
ifcvt   |      1    +1|     71010686    +71010686478743508522       +20.8%|
vect    |     14   +13|    697518955   +626508269299398068323       -37.5%|
cunroll |     13    -1|    489349408   -208169547257777839725       -10.5%|
loopdone|     11    -2|    402558559    -86790849201010712702             |
tracer  |     13    +2|    402977200      +418641| 200651036623        +0.0%|
fre     |     13      |    402622146      -355054| 200344398654        -0.2%|
expand  |     11    -2|    333608636    -69013510|--------------------------|

So no mismatches for lsplit and ldist and also lsplit thinks it improves speed by
2.3% rather than regressig it by 57%.

Update is still not perfect since we do not work out that the second loop
never iterates.

Ifcft wrecks profile by desing since it insert conditonals with both arms 100%
that will be eliminated later after vect.  It is not clear to me what happens
in vect though.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

PR middle-end/106923
* tree-ssa-loop-split.cc (connect_loops): Change probability
of the test preconditioning second loop to very_likely.
(fix_loop_bb_probability): Handle correctly case where
on of the arms of the conditional is empty.
(split_loop): Fold the test guarding first condition to
see if it is constant true; Set correct entry block
probabilities of the split loops; determine correct loop
eixt probabilities.

gcc/testsuite/ChangeLog:

PR middle-end/106293
* gcc.dg/tree-prof/loop-split-1.c: New test.
* gcc.dg/tree-prof/loop-split-2.c: New test.
* gcc.dg/tree-prof/loop-split-3.c: New test.

2 years agoada: Elide the copy in extended returns for nonlimited by-reference types
Eric Botcazou [Tue, 11 Jul 2023 08:59:17 +0000 (10:59 +0200)] 
ada: Elide the copy in extended returns for nonlimited by-reference types

gcc/ada/

* gcc-interface/trans.cc (gnat_to_gnu): Restrict previous change to
the case where the simple return statement has got no storage pool.

2 years agoada: Add an assert in Posix Interrupt_Wait
Clément Chigot [Tue, 13 Jun 2023 08:51:17 +0000 (10:51 +0200)] 
ada: Add an assert in Posix Interrupt_Wait

All functions but Interrupt_Wait in s-inmaop__posix are checking the
result of their syscalls with an assert. However, any return code of
sigwait different than 0 means that something went wrong for it.

From sigwait man:
> RETURN VALUE
>      On success, sigwait() returns 0.  On  error,  it  returns  a
>      positive error number (listed in ERRORS).

gcc/ada/

* libgnarl/s-inmaop__posix.adb: Add assert after sigwait in
Interrupt_Wait

2 years agoada: Fix unsupported dispatching constructor call
Javier Miranda [Sun, 9 Jul 2023 17:34:18 +0000 (17:34 +0000)] 
ada: Fix unsupported dispatching constructor call

Add dummy build-in-place parameters when a BIP function does not
require the BIP parameters but it is a dispatching operation that
inherited them.

gcc/ada/

* einfo-utils.adb (Underlying_Type): Protect recursion call
against non-available attribute Etype.
* einfo.ads (Protected_Subprogram): Fix typo in documentation.
* exp_ch3.adb (BIP_Function_Call_Id): New subprogram.
(Expand_N_Object_Declaration): Improve code that evaluates if the
object is initialized with a BIP function call.
* exp_ch6.adb (Is_True_Build_In_Place_Function_Call): New
subprogram.
(Add_Task_Actuals_To_Build_In_Place_Call): Add dummy actuals if
the function does not require the BIP task actuals but it is a
dispatching operation that inherited them.
(Build_In_Place_Formal): Improve code to avoid never-ending loop
if the BIP formal is not found.
(Add_Dummy_Build_In_Place_Actuals): New subprogram.
(Expand_Call_Helper): Add calls to
Add_Dummy_Build_In_Place_Actuals.
(Expand_N_Extended_Return_Statement): Adjust assertion.
(Expand_Simple_Function_Return): Adjust assertion.
(Make_Build_In_Place_Call_In_Allocator): No action needed if the
called function inherited the BIP extra formals but it is not a
true BIP function.
(Make_Build_In_Place_Call_In_Assignment): Ditto.
* exp_intr.adb (Expand_Dispatching_Constructor_Call): Remove code
reporting unsupported case (since this patch adds support for it).
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Adding assertion
to ensure matching of BIP formals when setting the
Protected_Formal field of a protected subprogram to reference the
corresponding extra formal of the subprogram that implements it.
(Might_Need_BIP_Task_Actuals): New subprogram.
(Create_Extra_Formals): Improve code adding inherited extra
formals.

2 years agoada: Add support for binding to a specific network interface controller.
Pascal Obry [Mon, 26 Jun 2023 17:58:16 +0000 (19:58 +0200)] 
ada: Add support for binding to a specific network interface controller.

gcc/ada/

* s-oscons-tmplt.c: Add support for SO_BINDTODEVICE constant.
* libgnat/g-socket.ads (Set_Socket_Option): Handle SO_BINDTODEVICE option.
(Get_Socket_Option): Handle SO_BINDTODEVICE option.
* libgnat/g-socket.adb: Likewise.
(Get_Socket_Option): Handle the case where IF_NAMESIZE is not defined
and so equal to -1.

2 years agoada: Add missing SCO generation for quantified expressions in object decl
Léo Creuse [Thu, 13 Jul 2023 10:30:42 +0000 (12:30 +0200)] 
ada: Add missing SCO generation for quantified expressions in object decl

This change corrects the Has_Decision predicate in par_sco.adb to
properly consider predicates of quantified expressions as
decisions.

gcc/ada/

* par_sco.adb (Has_Decision): Consider that quantified expressions
contain decisions.

2 years agoada: Fix race condition in protected entry call
Ronan Desplanques [Tue, 11 Jul 2023 15:57:14 +0000 (17:57 +0200)] 
ada: Fix race condition in protected entry call

This patch only affects the single-entry implementation of protected
objects.

Before this patch, there was a race condition where a task that
called an entry could put itself to sleep right after another task
had executed the entry as a proxy and signalled the not-yet-waiting
first task, which caused the first task to enter a deadlock.

Note that this race condition has been identified and fixed before
for the implementations of the run-time that live under hie/.

This patch reworks the locking sequence so that it is closer to the
one that's used in the multiple-entry implementation of protected
objects. The code for the multiple-entry implementation is spread
across multiple subprograms. To draw a parallel with the section
this patch modifies, one can read the following subprograms:

- System.Tasking.Protected_Objects.Operations.Protected_Entry_Call
- System.Tasking.Entry_Calls.Wait_For_Completion
- System.Tasking.Entry_Calls.Check_Pending_Actions_For_Entry_Call

This patch also adds a comment that explicitly states the locking
constraint that must hold in the affected section.

gcc/ada/

* libgnarl/s-tposen.adb: Fix race condition. Add comment to justify
the locking timing.

2 years agoada: Small refactor
Viljar Indus [Tue, 11 Jul 2023 12:20:15 +0000 (15:20 +0300)] 
ada: Small refactor

gcc/ada/

* exp_util.adb (Find_Optional_Prim_Op): use "No" instead of "= Empty"

2 years agoada: Add guard for detection of class-wide precondition subprograms
Piotr Trojanek [Tue, 11 Jul 2023 14:37:23 +0000 (16:37 +0200)] 
ada: Add guard for detection of class-wide precondition subprograms

When skipping check on subprograms built for class-wide preconditions
we must deal with the current scope not being a subprogram, e.g. it
could be a declare-block.

gcc/ada/

* sem_res.adb (Resolve_Actuals): Add guard for the call to
Class_Preconditions_Subprogram.

2 years agoada: Fix memory explosion on aggregate of nested packed array type
Eric Botcazou [Tue, 11 Jul 2023 11:29:55 +0000 (13:29 +0200)] 
ada: Fix memory explosion on aggregate of nested packed array type

It occurs at compile time on an aggregate of a 2-dimensional packed array
type whose component type is itself a packed array, because the compiler
is trying to pack the intermediate aggregate and ends up rewriting a bunch
of subcomponents.  This optimization was originally devised for the case of
a scalar component type so the change adds this restriction.

gcc/ada/

* exp_aggr.adb (Is_Two_Dim_Packed_Array): Return true only if the
component type of the array is scalar.

2 years agoada: Leave detection of missing return in functions to GNATprove
Piotr Trojanek [Mon, 10 Jul 2023 13:02:43 +0000 (15:02 +0200)] 
ada: Leave detection of missing return in functions to GNATprove

GNAT has a heuristic to warn about missing return statements in
functions. This warning was escalated to errors when operating in
GNATprove mode and SPARK_Mode was On. However, this heuristic was
imprecise and caused spurious errors. Also, it was applied after the
Push_Scope/End_Scope, so for functions acting as compilation units it
was using the wrong SPARK_Mode.

It is better to simply leave this detection to GNATprove.

gcc/ada/

* sem_ch6.adb (Check_Statement_Sequence): Only warn about missing return
statements and let GNATprove emit a check when needed.

2 years agoada: Emit enums rather than defines for various constants
Tom Tromey [Fri, 30 Jun 2023 15:31:40 +0000 (09:31 -0600)] 
ada: Emit enums rather than defines for various constants

This patch changes xsnamest and gen_il-gen to emit various constants
as enums rather than a sequence of preprocessor defines.  This enables
better debugging and somewhat better type safety.

gcc/ada/

* fe.h (Convention): Now inline function.
* gen_il-gen.adb (Put_C_Type_And_Subtypes.Put_Enum_Lit)
(Put_C_Type_And_Subtypes.Put_Kind_Subtype, Put_C_Getter):
Emit enum.
* snames.h-tmpl (Name_Id, Name_, Attribute_Id, Attribute_)
(Convention_Id, Convention_, Pragma_Id, Pragma_): Now enum.
(Get_Attribute_Id, Get_Pragma_Id): Now inline functions.
* types.h (Node_Kind, Entity_Kind, Convention_Id, Name_Id):
Now enum.
* xsnamest.adb (Output_Header_Line, Make_Value): Emit enum.

2 years agoada: Fix typo in comment of Ada.Exceptions.Save_Occurrence
Piotr Trojanek [Tue, 25 Apr 2023 15:43:09 +0000 (17:43 +0200)] 
ada: Fix typo in comment of Ada.Exceptions.Save_Occurrence

Minor typo in comment.

gcc/ada/

* libgnat/a-except.ads (Save_Occurrence): Fix typo.

2 years agoada: Allow calls to Number_Formals when no formals are present
Piotr Trojanek [Fri, 16 Jun 2023 07:16:19 +0000 (09:16 +0200)] 
ada: Allow calls to Number_Formals when no formals are present

It is much simpler and safer for the routine Number_Formals to accept
subprogram entities that have no formals.

gcc/ada/

* einfo-utils.adb (Number_Formals): Change types in body.
* einfo-utils.ads (Number_Formals): Change type in spec.
* einfo.ads (Number_Formals): Change type in comment.
* sem_ch13.adb (Is_Property_Function): Fix style in a caller of
Number_Formals that was likely to crash because of missing guards.

2 years agoada: Improve defense against illegal code in check for infinite loops
Piotr Trojanek [Fri, 16 Jun 2023 06:34:27 +0000 (08:34 +0200)] 
ada: Improve defense against illegal code in check for infinite loops

Fix crash occurring when attribute System'To_Address is used without
a WITH clause for package System.

gcc/ada/

* sem_warn.adb (Check_Infinite_Loop_Warning): Don't look at the type of
actual parameter when it has no type at all, e.g. because the entire
subprogram call is illegal.

2 years agoRISC-V: Remove vxrm parameter for vsadd[u] and vssub[u]
xuli [Fri, 28 Jul 2023 05:52:22 +0000 (05:52 +0000)] 
RISC-V: Remove vxrm parameter for vsadd[u] and vssub[u]

Computation of `vsadd`, `vsaddu`, `vssub`, and `vssubu` do not need the
rounding mode, therefore the intrinsics of these instructions do not have
the parameter for rounding mode control.

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins-bases.cc: remove rounding mode of
vsadd[u] and vssub[u].
* config/riscv/vector.md: Ditto.

gcc/testsuite/ChangeLog:

* g++.target/riscv/rvv/base/bug-12.C: Adapt testcase.
* g++.target/riscv/rvv/base/bug-14.C: Ditto.
* g++.target/riscv/rvv/base/bug-18.C: Ditto.
* g++.target/riscv/rvv/base/bug-19.C: Ditto.
* g++.target/riscv/rvv/base/bug-20.C: Ditto.
* g++.target/riscv/rvv/base/bug-21.C: Ditto.
* g++.target/riscv/rvv/base/bug-22.C: Ditto.
* g++.target/riscv/rvv/base/bug-23.C: Ditto.
* g++.target/riscv/rvv/base/bug-3.C: Ditto.
* g++.target/riscv/rvv/base/bug-8.C: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-100.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-101.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-102.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-103.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-104.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-105.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-106.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-107.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-108.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-109.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-110.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-111.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-112.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-113.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-114.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-115.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-116.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-117.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-118.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-119.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-97.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-98.c: Ditto.
* gcc.target/riscv/rvv/base/merge_constraint-1.c: Ditto.
* gcc.target/riscv/rvv/base/fixed-point-vxrm-error.c: New test.
* gcc.target/riscv/rvv/base/fixed-point-vxrm.c: New test.

2 years agoloop-split improvements, part 1
Jan Hubicka [Fri, 28 Jul 2023 07:16:09 +0000 (09:16 +0200)] 
loop-split improvements, part 1

while looking on profile misupdate on hmmer I noticed that loop splitting pass is not
able to handle the loop it has as an example it should apply on:

   One transformation of loops like:

   for (i = 0; i < 100; i++)
     {
       if (i < 50)
         A;
       else
         B;
     }

   into:

   for (i = 0; i < 50; i++)
     {
       A;
     }
   for (; i < 100; i++)
     {
       B;
     }

The problem is that ivcanon turns the test into i != 100 and the pass
explicitly gives up on any loops ending with != test.  It needs to know
the directoin of the induction variable in order to derive right conditions,
but that can be done also from step.

It turns out that there are no testcases for basic loop splitting.  I will add
some with the profile update fix.

gcc/ChangeLog:

* tree-ssa-loop-split.cc (split_loop): Also support NE driven
loops when IV test is not overflowing.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/ifc-12.c: Disable loop splitting.
* gcc.target/i386/avx2-gather-6.c: Likewise.
* gcc.target/i386/avx2-vect-aggressive.c: Likewise.

2 years agoAdd UNSPEC_MASKOP to vpbroadcastm pattern.
liuhongt [Thu, 27 Jul 2023 07:14:39 +0000 (15:14 +0800)] 
Add UNSPEC_MASKOP to vpbroadcastm pattern.

Prevent rtl optimization of vec_duplicate + zero_extend to
vpbroadcastm since there could be an extra kmov after RA.

gcc/ChangeLog:

PR target/110788
* config/i386/sse.md (avx512cd_maskb_vec_dup<mode>): Add
UNSPEC_MASKOP.
(avx512cd_maskw_vec_dup<mode>): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr110788.c: New test.

2 years agoDaily bump.
GCC Administrator [Fri, 28 Jul 2023 00:17:42 +0000 (00:17 +0000)] 
Daily bump.

2 years agobpf: ISA V4 sign-extending move and load insns [PR110782,PR110784]
David Faust [Thu, 27 Jul 2023 20:55:44 +0000 (13:55 -0700)] 
bpf: ISA V4 sign-extending move and load insns [PR110782,PR110784]

BPF ISA V4 introduces sign-extending move and load operations.  This
patch makes the BPF backend generate those instructions, when enabled
and useful.

A new option, -m[no-]smov gates generation of these instructions, and is
enabled by default for -mcpu=v4 and above.  Tests for the new
instructions and documentation for the new options are included.

PR target/110782
PR target/110784

gcc/

* config/bpf/bpf.opt (msmov): New option.
* config/bpf/bpf.cc (bpf_option_override): Handle it here.
* config/bpf/bpf.md (*extendsidi2): New.
(extendhidi2): New.
(extendqidi2): New.
(extendsisi2): New.
(extendhisi2): New.
(extendqisi2): New.
* doc/invoke.texi (Option Summary): Add -msmov eBPF option.
(eBPF Options): Add -m[no-]smov.  Document that -mcpu=v4
also enables -msmov.

gcc/testsuite/

* gcc.target/bpf/sload-1.c: New test.
* gcc.target/bpf/sload-pseudoc-1.c: New test.
* gcc.target/bpf/smov-1.c: New test.
* gcc.target/bpf/smov-pseudoc-1.c: New test.

2 years agobpf: minor doc cleanup for command-line options
David Faust [Thu, 27 Jul 2023 20:49:59 +0000 (13:49 -0700)] 
bpf: minor doc cleanup for command-line options

This patch makes some minor cleanups to eBPF options documented in
invoke.texi:
 - Delete some vestigal docs for removed -mkernel option
 - Add -mbswap and -msdiv to the option summary
 - Note the negative versions of several options
 - Note that -mcpu=v4 also enables -msdiv.

gcc/

* doc/invoke.texi (Option Summary): Remove -mkernel eBPF option.
Add -mbswap and -msdiv eBPF options.
(eBPF Options): Remove -mkernel.  Add -mno-{jmpext, jmp32,
alu32, v3-atomics, bswap, sdiv}.  Document that -mcpu=v4 also
enables -msdiv.

2 years agobpf: correct pseudo-C template for add3 and sub3
David Faust [Thu, 27 Jul 2023 17:56:29 +0000 (10:56 -0700)] 
bpf: correct pseudo-C template for add3 and sub3

The pseudo-C output templates for these instructions were incorrectly
using operand 1 rather than operand 2 on the RHS, which led to some
very incorrect assembly generation with -masm=pseudoc.

gcc/

* config/bpf/bpf.md (add<AM:mode>3): Use %w2 instead of %w1
in pseudo-C dialect output template.
(sub<AM:mode>3): Likewise.

gcc/testsuite/

* gcc.target/bpf/alu-2.c: New test.
* gcc.target/bpf/alu-pseudoc-2.c: Likewise.

2 years agoMake store likely in optimize_mask_stores
Jan Hubicka [Thu, 27 Jul 2023 18:14:19 +0000 (20:14 +0200)] 
Make store likely in optimize_mask_stores

gcc/ChangeLog:

* tree-vect-loop.cc (optimize_mask_stores): Make store
likely.

2 years agoFix profile update after RTL unrolling
Jan Hubicka [Thu, 27 Jul 2023 18:06:37 +0000 (20:06 +0200)] 
Fix profile update after RTL unrolling

This patch fixes profile update after RTL unroll, that is now done same way as
in tree one.  We still produce (slightly) corrupted profile for multiple exit
loops I can try to fix incrementally.

I also updated testcases to look for profile mismatches so they do not creep
back in again.

gcc/ChangeLog:

* cfgloop.h (single_dom_exit): Declare.
* cfgloopmanip.h (update_exit_probability_after_unrolling): Declare.
* cfgrtl.cc (struct cfg_hooks): Fix comment.
* loop-unroll.cc (unroll_loop_constant_iterations): Update exit edge.
* tree-ssa-loop-ivopts.h (single_dom_exit): Do not declare it here.
* tree-ssa-loop-manip.cc (update_exit_probability_after_unrolling):
Break out from ...
(tree_transform_and_unroll_loop): ... here;

gcc/testsuite/ChangeLog:

* gcc.dg/tree-prof/peel-1.c: Test for profile mismatches.
* gcc.dg/tree-prof/unroll-1.c: Test for profile mismatches.
* gcc.dg/tree-ssa/peel1.c: Test for profile mismatches.
* gcc.dg/unroll-1.c: Test for profile mismatches.
* gcc.dg/unroll-3.c: Test for profile mismatches.
* gcc.dg/unroll-4.c: Test for profile mismatches.
* gcc.dg/unroll-5.c: Test for profile mismatches.
* gcc.dg/unroll-6.c: Test for profile mismatches.

2 years agoOpenMP/Fortran: Extend reject code between target + teams [PR71065, PR110725]
Tobias Burnus [Thu, 27 Jul 2023 16:14:11 +0000 (18:14 +0200)] 
OpenMP/Fortran: Extend reject code between target + teams [PR71065, PR110725]

The previous version failed to diagnose when the 'teams' was nested
more deeply inside the target region, e.g. inside a DO or some
block or structured block.

            PR fortran/110725
            PR middle-end/71065

gcc/fortran/ChangeLog:

* openmp.cc (resolve_omp_target): Minor cleanup.
* parse.cc (decode_omp_directive): Find TARGET statement
also higher in the stack.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/teams-6.f90: Extend.

2 years agolibstdc++: Fix std::format alternate form for floating-point [PR108046]
Jonathan Wakely [Thu, 27 Jul 2023 13:07:09 +0000 (14:07 +0100)] 
libstdc++: Fix std::format alternate form for floating-point [PR108046]

A decimal point was being added to the end of the string for {:#.0}
because the __expc character was not being set, for the _Pres_none
presentation type, so __s.find(__expc) didn't the 'e' in "1e+01" and so
we created "1e+01." by appending the radix char to the end.

This can be fixed by ensuring that __expc='e' is set for the _Pres_none
case. I realized we can also set __expc='P' and __expc='E' when needed,
to save a call to std::toupper later.

For the {:#.0g} format, __expc='e' was being set and so the 'e' was
found in "1e+10" but then __z = __prec - __sigfigs would wraparound to
SIZE_MAX. That meant we would decide not to add a radix char because the
number of extra characters to insert would be 1+SIZE_MAX i.e. zero.

This can be fixed by using __z == 0 when __prec == 0.

libstdc++-v3/ChangeLog:

PR libstdc++/108046
* include/std/format (__formatter_fp::format): Ensure __expc is
always set for all presentation types. Set __z correctly for
zero precision.
* testsuite/std/format/functions/format.cc: Check problem cases.

2 years agoFix profile update in tree_transform_and_unroll_loop
Jan Hubicka [Thu, 27 Jul 2023 14:17:59 +0000 (16:17 +0200)] 
Fix profile update in tree_transform_and_unroll_loop

Fixe profile update in tree_transform_and_unroll_loop which is used
by predictive comming.  I stared by attempt to fix
gcc.dg/tree-ssa/update-unroll-1.c I xfailed last week, but it turned to be
harder job.

Unrolling was never fixed for changes in duplicate_loop_body_to_header_edge
which is now smarter on getting profile right when some exists are eliminated.
A lot of manual profile can thus now be done using existing infrastructure.

I also noticed that scale_dominated_blocks_in_loop does job identical
to loop I wrote in scale_loop_profile and thus I commonized the implementaiton
and removed recursion.

I also extended duplicate_loop_body_to_header_edge to handle flat profiles same
way as we do in vectorizer. Without it we end up with less then 0 iteration
count in gcc.dg/tree-ssa/update-unroll-1.c (it is unrolled 32times but predicted
to iterated fewer times) and added missing code to update loop_info.

gcc/ChangeLog:

* cfgloopmanip.cc (scale_dominated_blocks_in_loop): Move here from
tree-ssa-loop-manip.cc and avoid recursion.
(scale_loop_profile): Use scale_dominated_blocks_in_loop.
(duplicate_loop_body_to_header_edge): Add DLTHE_FLAG_FLAT_PROFILE
flag.
* cfgloopmanip.h (DLTHE_FLAG_FLAT_PROFILE): Define.
(scale_dominated_blocks_in_loop): Declare.
* predict.cc (dump_prediction): Do not ICE on uninitialized probability.
(change_edge_frequency): Remove.
* predict.h (change_edge_frequency): Remove.
* tree-ssa-loop-manip.cc (scale_dominated_blocks_in_loop): Move to
cfgloopmanip.cc.
(niter_for_unrolled_loop): Remove.
(tree_transform_and_unroll_loop): Fix profile update.

gcc/testsuite/ChangeLog:

* gcc.dg/pr102385.c: Check for no profile mismatches.
* gcc.dg/pr96931.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-1.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-2.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-3.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-4.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-5.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-7.c: Check for one profile mismatch.
* gcc.dg/tree-ssa/predcom-8.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-1.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-10.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-11.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-12.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-2.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-3.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-4.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-5.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-6.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-7.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-8.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/predcom-dse-9.c: Check for no profile mismatches.
* gcc.dg/tree-ssa/update-unroll-1.c: Unxfail.

2 years agoFix profile update in tree-ssa-loop-im.cc
Jan Hubicka [Thu, 27 Jul 2023 13:58:52 +0000 (15:58 +0200)] 
Fix profile update in tree-ssa-loop-im.cc

This fixes two bugs in tree-ssa-loop-im.cc.  First is that cap probability is not
reliable, but it is constructed with adjusted quality.  Second is that sometimes
the conditional has wrong joiner BB count.  This is visible on
testsuite/gcc.dg/pr102385.c however the testcase triggers another profile
update bug in pcom, so I will update it in followup patch.

gcc/ChangeLog:

* tree-ssa-loop-im.cc (execute_sm_if_changed): Turn cap probability
to guessed; fix count of new_bb.

2 years agoFix profile_count::apply_probability
Jan Hubicka [Thu, 27 Jul 2023 13:57:54 +0000 (15:57 +0200)] 
Fix profile_count::apply_probability

profile_count::apply_probability misses check for uninitialized probability which leads
to completely random results on applying uninitialized probability to initialized scale.
This can make difference when i.e. inlining -fno-guess-branch-probability function
to -fguess-branch-probability one.

gcc/ChangeLog:

* profile-count.h (profile_count::apply_probability): Fix
handling of uninitialized probabilities, optimize scaling
by probability 1.

2 years agotree-optimization/91838 - fix FAIL of g++.dg/opt/pr91838.C
Richard Biener [Thu, 27 Jul 2023 11:08:32 +0000 (13:08 +0200)] 
tree-optimization/91838 - fix FAIL of g++.dg/opt/pr91838.C

The following fixes the lack of simplification of a vector shift
by an out-of-bounds shift value.  For scalars this is done both
by CCP and VRP but vectors are not handled there.  This results
in PR91838 differences in outcome dependent on whether a vector
shift ISA is available and thus vector lowering does or does not
expose scalar shifts here.

The following adds a match.pd pattern to catch uniform out-of-bound
shifts, simplifying them to zero when not sanitizing shift amounts.

PR tree-optimization/91838
* gimple-match-head.cc: Include attribs.h and asan.h.
* generic-match-head.cc: Likewise.
* match.pd (([rl]shift @0 out-of-bounds) -> zero): New pattern.

2 years agoc++: constexpr empty subobject elision [PR110197]
Patrick Palka [Thu, 27 Jul 2023 13:10:07 +0000 (09:10 -0400)] 
c++: constexpr empty subobject elision [PR110197]

Now that init_subob_ctx no longer sets new_ctx.ctor for a subobject of
empty type, it seems we need to ensure its callers also consistently
omit entries in the parent ctx->ctor for such subobjects.  We also need
to allow cxx_eval_array_reference to synthesize an empty subobject even
if the array CONSTRUCTOR has CONSTRUCTOR_NO_CLEARING set.

PR c++/110197

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_array_reference): Allow synthesizing an
empty subobject even if CONSTRUCTOR_NO_CLEARING is set.
(cxx_eval_bare_aggregate): Set 'no_slot' to true more generally
whenever new_ctx.ctor is set to NULL_TREE by init_subob_ctx,
i.e. whenever initializing an subobject of empty type.
(cxx_eval_vec_init_1): Define 'no_slot' as above and use it
accordingly.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-empty18.C: New test.
* g++.dg/cpp0x/constexpr-empty19.C: New test.

2 years agoRISC-V: Enable basic VLS modes support
Juzhe-Zhong [Thu, 27 Jul 2023 11:47:02 +0000 (19:47 +0800)] 
RISC-V: Enable basic VLS modes support

Support && Test VLS modes load/store/reg move as well as LRA spilling

gcc/ChangeLog:

* config/riscv/riscv-modes.def (VECTOR_BOOL_MODE): Add VLS modes.
(ADJUST_ALIGNMENT): Ditto.
(ADJUST_PRECISION): Ditto.
(VLS_MODES): Ditto.
(VECTOR_MODE_WITH_PREFIX): Ditto.
* config/riscv/riscv-opts.h (TARGET_VECTOR_VLS): New macro.
* config/riscv/riscv-protos.h (riscv_v_ext_vls_mode_p): New function.
* config/riscv/riscv-v.cc (INCLUDE_ALGORITHM): Add include.
(legitimize_move): Enable basic VLS modes support.
(get_vlmul): Ditto.
(get_ratio): Ditto.
(get_vector_mode): Ditto.
* config/riscv/riscv-vector-switch.def (VLS_ENTRY): Add vls modes.
* config/riscv/riscv.cc (riscv_v_ext_vls_mode_p): New function.
(VLS_ENTRY): New macro.
(riscv_v_ext_mode_p): Add vls modes.
(riscv_get_v_regno_alignment): New function.
(riscv_print_operand): Add vls modes.
(riscv_hard_regno_nregs): Ditto.
(riscv_hard_regno_mode_ok): Ditto.
(riscv_regmode_natural_size): Ditto.
(riscv_vectorize_preferred_vector_alignment): Ditto.
* config/riscv/riscv.md: Ditto.
* config/riscv/vector-iterators.md: Ditto.
* config/riscv/vector.md: Ditto.
* config/riscv/autovec-vls.md: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/partial/slp-9.c: Add more checks.
* gcc.target/riscv/rvv/rvv.exp: Add VLS modes tests.
* gcc.target/riscv/rvv/autovec/vls/def.h: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-10.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-11.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-12.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-13.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-14.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-15.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-16.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-17.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-7.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-8.c: New test.
* gcc.target/riscv/rvv/autovec/vls/mov-9.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/spill-7.c: New test.

2 years agoRISC-V: Remove unnecessary vread_csr/vwrite_csr intrinsic.
Pan Li [Thu, 27 Jul 2023 02:34:57 +0000 (10:34 +0800)] 
RISC-V: Remove unnecessary vread_csr/vwrite_csr intrinsic.

According to below RVV doc, the related intrinsic is not longer needed.

https://github.com/riscv-non-isa/rvv-intrinsic-doc/pull/249

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

* config/riscv/riscv_vector.h (enum RVV_CSR): Removed.
(vread_csr): Ditto.
(vwrite_csr): Ditto.

2 years agoRISC-V: Fix uninitialized and redundant use of which_alternative
demin.han [Thu, 27 Jul 2023 09:48:59 +0000 (17:48 +0800)] 
RISC-V: Fix uninitialized and redundant use of which_alternative

When pass split2 starts, which_alternative is random depending on
last set of certain pass.

Even initialized, the generated movement is redundant.
The movement can be generated by assembly output template.

Signed-off-by: demin.han <demin.han@starfivetech.com>
gcc/ChangeLog:

* config/riscv/autovec.md: Delete which_alternative use in split

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/madd-split2-1.c: New test.
Signed-off-by: demin.han <demin.han@starfivetech.com>
2 years agoXFAIL parts broken deliberately by r13-1762-gf9d4c3b45c5ed5
Richard Biener [Thu, 27 Jul 2023 10:34:34 +0000 (12:34 +0200)] 
XFAIL parts broken deliberately by r13-1762-gf9d4c3b45c5ed5

The following XFAILs recognizing a complex store as memset.

PR tree-optimization/110829
* gcc.dg/pr56837.c: XFAIL part of the testcase.

2 years agoRemove recursive post-dominator traversal in sinking
Richard Biener [Thu, 27 Jul 2023 08:23:16 +0000 (10:23 +0200)] 
Remove recursive post-dominator traversal in sinking

The following turns the recursive post-dominator traversal in GIMPLE
code sinking to a worklist.

* tree-ssa-sink.cc (sink_code_in_bb): Remove recursion, instead
use a worklist ...
(pass_sink_code::execute): ... in the caller.

2 years agoc++: Fix ICE with parameter pack of decltype(auto) [PR103497]
Nathaniel Shead [Fri, 30 Jun 2023 07:05:24 +0000 (17:05 +1000)] 
c++: Fix ICE with parameter pack of decltype(auto) [PR103497]

This patch ensures 'type_uses_auto' also checks for usages of 'auto' in
parameter packs.

PR c++/103497

gcc/cp/ChangeLog:

* pt.cc (type_uses_auto): Check inside parameter packs.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/decltype-auto-103497.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2 years agovect: Treat VMAT_ELEMENTWISE as scalar load in costing [PR110776]
Kewen Lin [Thu, 27 Jul 2023 02:43:09 +0000 (21:43 -0500)] 
vect: Treat VMAT_ELEMENTWISE as scalar load in costing [PR110776]

PR110776 exposes one issue that we could query unaligned
load for vector type but actually no unaligned vector load
is supported there.  The reason is that the costed load is
with single-lane vector type and its memory access type is
VMAT_ELEMENTWISE, we actually take it as scalar load and
set its alignment_support_scheme as dr_unaligned_supported.

To avoid the ICE as exposed, following Rich's suggestion,
this patch is to make VMAT_ELEMENTWISE be costed as scalar
load.

Co-authored-by: Richard Biener <rguenther@suse.de>
PR tree-optimization/110776

gcc/ChangeLog:

* tree-vect-stmts.cc (vectorizable_load): Always cost VMAT_ELEMENTWISE
as scalar load.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr110776.c: New test.

2 years ago[committed] [RISC-V] Fix expected diagnostic messages in testsuite
Jeff Law [Thu, 27 Jul 2023 01:25:33 +0000 (19:25 -0600)] 
[committed] [RISC-V] Fix expected diagnostic messages in testsuite

Whoops, this should have gone in with the fixes to the RISC-V
diagnostics from earlier this week.

gcc/testsuite
* gcc.target/riscv/arch-23.c: Update expected diagnostic messages.
* gcc.target/riscv/pr102957.c: Likewise.

2 years agoDaily bump.
GCC Administrator [Thu, 27 Jul 2023 00:17:56 +0000 (00:17 +0000)] 
Daily bump.

2 years agoc++: passing partially inst ttp as ttp [PR110566]
Patrick Palka [Wed, 26 Jul 2023 21:21:43 +0000 (17:21 -0400)] 
c++: passing partially inst ttp as ttp [PR110566]

The previous fix doesn't work for partially instantiated ttps mainly
because most_general_template is a no-op for them.  This patch fixes
this by giving such ttps a DECL_TEMPLATE_INFO (extending the
r11-734-g2fb595f8348e16 fix) with which most_general_template can obtain
the original, unlowered ttp.

This patch additionally makes coerce_template_template_parms use the
correct amount of levels from the scope of a ttp argument.

PR c++/110566
PR c++/108179

gcc/cp/ChangeLog:

* pt.cc (reduce_template_parm_level): Set DECL_TEMPLATE_INFO
on the DECL_TEMPLATE_RESULT of the new ttp.
(add_defaults_to_ttp): Make a copy of the original ttp's
DECL_TEMPLATE_RESULT, and update this copy's DECL_TEMPLATE_INFO
as well.
(coerce_template_template_parms): Make sure 'scope_args' has
the right amount of levels for the ttp argument.
(most_general_template): Handle template template parameters.
(rewrite_template_parm): Set DECL_TEMPLATE_RESULT on the
DECL_TEMPLATE_RESULT of the new ttp.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/class-deduction115.C: New test.
* g++.dg/template/ttp39.C: New test.

2 years agoc++: passing partially inst tmpl as ttp [PR110566]
Patrick Palka [Wed, 26 Jul 2023 21:21:26 +0000 (17:21 -0400)] 
c++: passing partially inst tmpl as ttp [PR110566]

Since the template arguments 'pargs' we pass to coerce_template_parms from
coerce_template_template_parms are always a full set, we need to make sure
we always pass the parameters of the most general template because if the
template is partially instantiated then the levels won't match up.  In the
testcase below during said call to coerce_template_parms the parameters are
{X, Y}, both level 1 rather than 2, and the arguments are {{int}, {N, M}},
which results in a crash during auto deduction for parameters' types.

PR c++/110566
PR c++/108179

gcc/cp/ChangeLog:

* pt.cc (coerce_template_template_parms): Simplify by using
DECL_INNERMOST_TEMPLATE_PARMS and removing redundant asserts.
Always pass the parameters of the most general template to
coerce_template_parms.

gcc/testsuite/ChangeLog:

* g++.dg/template/ttp38.C: New test.

2 years ago[PATCH 2/5] [RISC-V] Generate Zicond instruction for basic semantics
Xiao Zeng [Wed, 26 Jul 2023 17:59:59 +0000 (11:59 -0600)] 
[PATCH 2/5] [RISC-V] Generate Zicond instruction for basic semantics

This patch completes the recognition of the basic semantics
defined in the spec, namely:

Conditional zero, if condition is equal to zero
  rd = (rs2 == 0) ? 0 : rs1
Conditional zero, if condition is non zero
  rd = (rs2 != 0) ? 0 : rs1

gcc/ChangeLog:

* config/riscv/riscv.md: Include zicond.md
* config/riscv/zicond.md: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zicond-primitiveSemantics.c: New test.

Co-authored-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
Co-authored-by: Raphael Zinsly <rzinsly@ventanamicro.com>
Co-authored-by: Jeff Law <jlaw@ventanamicro.com>
2 years ago[PATCH 1/5] [RISC-V] Recognize Zicond extension
Xiao Zeng [Wed, 26 Jul 2023 16:07:42 +0000 (10:07 -0600)] 
[PATCH 1/5] [RISC-V] Recognize Zicond extension

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: New extension.
* config/riscv/riscv-opts.h (MASK_ZICOND): New mask.
(TARGET_ZICOND): New target.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/attribute-20.c: New test.
* gcc.target/riscv/attribute-21.c: New test.

Co-authored-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
2 years agoc++: unifying REAL_CSTs [PR110809]
Patrick Palka [Wed, 26 Jul 2023 20:52:13 +0000 (16:52 -0400)] 
c++: unifying REAL_CSTs [PR110809]

This teaches unify how to compare two REAL_CSTs.

PR c++/110809

gcc/cp/ChangeLog:

* pt.cc (unify) <case INTEGER_CST>: Generalize to handle
REAL_CST as well.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-float3.C: New test.

2 years agoFortran: diagnose strings of non-constant length in DATA statements [PR68569]
Harald Anlauf [Wed, 26 Jul 2023 19:12:45 +0000 (21:12 +0200)] 
Fortran: diagnose strings of non-constant length in DATA statements [PR68569]

gcc/fortran/ChangeLog:

PR fortran/68569
* resolve.cc (check_data_variable): Do not accept strings with
deferred length or non-constant length in a DATA statement.
Reject also substrings of string variables of non-constant length.

gcc/testsuite/ChangeLog:

PR fortran/68569
* gfortran.dg/data_char_4.f90: Adjust expected diagnostic.
* gfortran.dg/data_char_5.f90: Likewise.
* gfortran.dg/data_char_6.f90: New test.

2 years agoUpdate gcc uk.po
Joseph Myers [Wed, 26 Jul 2023 19:08:39 +0000 (19:08 +0000)] 
Update gcc uk.po

* uk.po: Update.

2 years agoRegenerate gcc.pot
Joseph Myers [Wed, 26 Jul 2023 18:50:21 +0000 (18:50 +0000)] 
Regenerate gcc.pot

* gcc.pot: Regenerate.

2 years agolibstdc++: Require C++11 for 23_containers/vector/bool/110807.cc [PR110807]
Jonathan Wakely [Wed, 26 Jul 2023 18:08:39 +0000 (19:08 +0100)] 
libstdc++: Require C++11 for 23_containers/vector/bool/110807.cc [PR110807]

This new test uses uniform initialization syntax, so requires C++11 or
later.

libstdc++-v3/ChangeLog:

PR libstdc++/110807
* testsuite/23_containers/vector/bool/110807.cc: Require c++11.

2 years agors6000, add argument to function find_instance
Carl Love [Wed, 26 Jul 2023 17:49:47 +0000 (13:49 -0400)] 
rs6000, add argument to function find_instance

The function find_instance assumes it is called to check a built-in with
only two arguments.  This patch extends the function by adding a parameter
specifying the number of built-in arguments to check.

Note, this patch was supposed to have been applied before commit:

  commit b51795c832cf6e724d61919eb18a383223b76694
  Author: Carl Love <cel@us.ibm.com>
  Date:   Wed Jul 26 11:31:53 2023 -0400

      rs6000, fix vec_replace_unaligned built-in arguments
       ...

gcc/ChangeLog:
* config/rs6000/rs6000-c.cc (find_instance): Add new parameter that
specifies the number of built-in arguments to check.
(altivec_resolve_overloaded_builtin): Update calls to find_instance
to pass the number of built-in arguments to be checked.

2 years agoc++: cp_parser_constant_expression cleanups
Marek Polacek [Tue, 25 Jul 2023 18:03:02 +0000 (14:03 -0400)] 
c++: cp_parser_constant_expression cleanups

It's pointless to call *_rvalue_constant_expression when we're not using
the result.  Also apply some drive-by cleanups.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_constant_expression): Allow non_constant_p to be
nullptr even when allow_non_constant_p is true.  Don't call
_rvalue_constant_expression when not necessary.  Move local variable
declarations closer to their first use.
(cp_parser_static_assert): Don't pass a dummy down to
cp_parser_constant_expression.

2 years agoc++: member vs global template [PR106310]
Jason Merrill [Wed, 26 Jul 2023 14:39:34 +0000 (10:39 -0400)] 
c++: member vs global template [PR106310]

For backward compatibility we still want to allow patterns like
this->A<T>::foo, but the template keyword in a qualified name is
specifically to specify that a dependent name is a template, so don't look
in the enclosing scope at all.

Also fix handling of dependent bases: if member lookup in the current
instantiation fails and we have dependent bases, the lookup is dependent.
We were already handling that for the case where lookup in the enclosing
scope also fails, but we also want it to affect that lookup itself.

PR c++/106310

gcc/cp/ChangeLog:

* parser.cc (cp_parser_template_name): Skip non-member
lookup after the template keyword.
(cp_parser_lookup_name): Pass down template_keyword_p.

gcc/testsuite/ChangeLog:

* g++.dg/template/template-keyword4.C: New test.

2 years agobpf: add v3 atomic instructions
David Faust [Mon, 24 Jul 2023 16:45:17 +0000 (09:45 -0700)] 
bpf: add v3 atomic instructions

This patch adds support for the general atomic operations introduced in
eBPF v3. In addition to the existing atomic add instruction, this adds:
 - Atomic and, or, xor
 - Fetching versions of these operations (including add)
 - Atomic exchange
 - Atomic compare-and-exchange

To control emission of these instructions, a new target option
-m[no-]v3-atomics is added. This option is enabled by -mcpu=v3
and above.

Support for these instructions was recently added in binutils.

gcc/

* config/bpf/bpf.opt (mv3-atomics): New option.
* config/bpf/bpf.cc (bpf_option_override): Handle it here.
* config/bpf/bpf.h (enum_reg_class): Add R0 class.
(REG_CLASS_NAMES): Likewise.
(REG_CLASS_CONTENTS): Likewise.
(REGNO_REG_CLASS): Handle R0.
* config/bpf/bpf.md (UNSPEC_XADD): Rename to UNSPEC_AADD.
(UNSPEC_AAND): New unspec.
(UNSPEC_AOR): Likewise.
(UNSPEC_AXOR): Likewise.
(UNSPEC_AFADD): Likewise.
(UNSPEC_AFAND): Likewise.
(UNSPEC_AFOR): Likewise.
(UNSPEC_AFXOR): Likewise.
(UNSPEC_AXCHG): Likewise.
(UNSPEC_ACMPX): Likewise.
(atomic_add<mode>): Use UNSPEC_AADD and atomic type attribute.
Move to...
* config/bpf/atomic.md: ...Here. New file.
* config/bpf/constraints.md (t): New constraint for R0.
* doc/invoke.texi (eBPF Options): Document -mv3-atomics.

gcc/testsuite/

* gcc.target/bpf/atomic-cmpxchg-1.c: New test.
* gcc.target/bpf/atomic-cmpxchg-2.c: New test.
* gcc.target/bpf/atomic-fetch-op-1.c: New test.
* gcc.target/bpf/atomic-fetch-op-2.c: New test.
* gcc.target/bpf/atomic-fetch-op-3.c: New test.
* gcc.target/bpf/atomic-op-1.c: New test.
* gcc.target/bpf/atomic-op-2.c: New test.
* gcc.target/bpf/atomic-op-3.c: New test.
* gcc.target/bpf/atomic-xchg-1.c: New test.
* gcc.target/bpf/atomic-xchg-2.c: New test.

2 years agolibstdc++: Avoid bogus overflow warnings in std::vector<bool> [PR110807]
Jonathan Wakely [Wed, 26 Jul 2023 13:09:24 +0000 (14:09 +0100)] 
libstdc++: Avoid bogus overflow warnings in std::vector<bool> [PR110807]

GCC thinks the allocation can alter the object being copied if it's
globally reachable, so doesn't realize that [x.begin(), x.end()) after
the allocation is the same as x.size() before it.

This causes a testsuite failure when testing with -D_GLIBCXX_DEBUG:
FAIL: 23_containers/vector/bool/swap.cc (test for excess errors)
A fix is to move the calls to x.begin() and x.end() to before the
allocation.

A similar problem exists in vector<bool>::_M_insert_range where *this is
globally reachable, as reported in PR libstdc++/110807. That can also be
fixed by moving calls to begin() and end() before the allocation.

libstdc++-v3/ChangeLog:

PR libstdc++/110807
* include/bits/stl_bvector.h (vector(const vector&)): Access
iterators before allocating.
* include/bits/vector.tcc (vector<bool>::_M_insert_range):
Likewise.
* testsuite/23_containers/vector/bool/110807.cc: New test.