]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
9 months agoPrint entry count in print_loop_info
Jan Hubicka [Thu, 3 Aug 2023 20:49:22 +0000 (22:49 +0200)] 
Print entry count in print_loop_info

gcc/ChangeLog:

* tree-cfg.cc (print_loop_info): Print entry count.

9 months agoUpdate loop iteration estimates after splitting
Jan Hubicka [Thu, 3 Aug 2023 20:47:55 +0000 (22:47 +0200)] 
Update loop iteration estimates after splitting

Hmmer's internal function has 4 loops.  The following is the profile at start:

  loop 1:
  estimate 472
  iterations by profile: 473.497707 (reliable) count in:84821 (precise, freq 0.9979)

    loop 2:
    estimate 99
    iterations by profile: 100.000000 (reliable) count in:39848881 (precise, freq 468.8104)

    loop 3:
    estimate 99
    iterations by profile: 100.000000 (reliable) count in:39848881 (precise, freq 468.8104)

  loop 4:
  estimate 100
  iterations by profile: 100.999596 (reliable) execution count:84167 (precise, freq 0.9902)

So the first loops is outer loop and second/third loops are nesed. Fourth loop is not critical.
Precise iteraiton counts are unknown (473 and 100 comes from profile)
Nested loop has following form:

    for (k = 1; k <= M; k++) {
      mc[k] = mpp[k-1]   + tpmm[k-1];
      if ((sc = ip[k-1]  + tpim[k-1]) > mc[k])  mc[k] = sc;
      if ((sc = dpp[k-1] + tpdm[k-1]) > mc[k])  mc[k] = sc;
      if ((sc = xmb  + bp[k])         > mc[k])  mc[k] = sc;
      mc[k] += ms[k];
      if (mc[k] < -INFTY) mc[k] = -INFTY;

      dc[k] = dc[k-1] + tpdd[k-1];
      if ((sc = mc[k-1] + tpmd[k-1]) > dc[k]) dc[k] = sc;
      if (dc[k] < -INFTY) dc[k] = -INFTY;

      if (k < M) {
        ic[k] = mpp[k] + tpmi[k];
        if ((sc = ip[k] + tpii[k]) > ic[k]) ic[k] = sc;
        ic[k] += is[k];
        if (ic[k] < -INFTY) ic[k] = -INFTY;
      }

We do quite some belly dancing here.
 1) loop-ch slightly misupdates profile, so the estimates of 99
    does not match profile setimate of 100.
 2) loops-split splits on if (k < M) and produces two loops.
    It fails to notice that the second loop never iterates.
    It used to misupdate profile a lot which later caused internal
    loop to become cold.  This is fixed now.
 3) loop-dist introduces runtime aliasing checks for both loops
 4) tree vectorizer vectorizes some of the copies of the loop produces
    and drops expected iteration counts
 5) loop peeling peels the loops with expected low iteration counts
 6) complete loop unrolling kills some loops in prologues/epilogues.

We end up with quite many loops and run out of registers:

  iterations by profile: 5.312499 (unreliable, maybe flat)
    this is vectorized internal loops after loop peeling

  iterations by profile: 0.009495 (unreliable, maybe flat)
  iterations by profile: 0.009495 (unreliable, maybe flat)
  iterations by profile: 0.009495 (unreliable, maybe flat)
  iterations by profile: 0.009495 (unreliable, maybe flat)
    Those are all versioned/peeled and vectorized variants of the loop never looping

  iterations by profile: 100.000008 (unreliable)
  iterations by profile: 100.000000 (unreliable)
    Those are variants with failed aliasing checks

  iterations by profile: 9.662853 (unreliable, maybe flat)
  iterations by profile: 4.646072 (unreliable)
  iterations by profile: 100.000007 (unreliable)
  iterations by profile: 5.312500 (unreliable)
  iterations by profile: 473.497707 (reliable)
    This is loop 1

  iterations by profile: 100.999596 (reliable)
    This is the loop 4.

This patch fixes loop iteration estimate update after loop split so we get:

  iterations by profile: 5.312499 (unreliable, maybe flat) entry count:12742188 (guessed, freq 149.9081)
    This is remainder of the peeled vectorized loop 2.  It misses estimate that is correct since after peeling it 6 times it is essentially
    impossible to tell what the remaining loop profile is (without histograms)

  iterations by profile: 0.009496 (unreliable, maybe flat) entry count:374801 (guessed, freq 4.4094)
    Peeled split part of loop 2 (one that never loops).  We ought to work this out
    but at least w

  estimate 99
  iterations by profile: 100.000008 (unreliable) entry count:3945039 (guessed, freq 46.4122)
  estimate 99
  iterations by profile: 100.000000 (unreliable) entry count:35505353 (guessed, freq 417.7100)

  estimate 99
  iterations by profile: 9.662853 (unreliable, maybe flat) entry count:35505353 (guessed, freq 417.7100)
    Profile here mismatches estimate - I will need to work out why.

  estimate 5
  iterations by profile: 4.646072 (unreliable) entry count:31954818 (guessed, freq 375.9390)
    This is vectorized but not peeled loop 3
  estimate 99
  iterations by profile: 100.000007 (unreliable) entry count:7101070 (guessed, freq 83.5420)
    Unvectorized variant of loop 3
  estimate 5
  iterations by profile: 5.312500 (unreliable) entry count:25563855 (guessed, freq 300.7512)
    Another vectorized variant of loop 3
  estimate 472
  iterations by profile: 473.497707 (reliable) entry count:84821 (precise, freq 0.9979)
    Outer loop

  estimate 100
  iterations by profile: 100.999596 (reliable) entry count:84167 (precise, freq 0.9902)
    loop 4, not vectorized/peeled

So there is still work to do on this testcase, but with the patch we prevent 3 useless loops.

Bootstrapped/regtested x86_64-linux, plan to commit it later today.

gcc/ChangeLog:

* tree-ssa-loop-split.cc (split_loop): Update estimated iteration counts.

9 months agoFix profiledbootstrap
Jan Hubicka [Thu, 3 Aug 2023 20:42:27 +0000 (22:42 +0200)] 
Fix profiledbootstrap

Profiledbootstrap fails with ICE in update_loop_exit_probability_scale_dom_bbs
called from loop unroling.
The reason is that under relatively rare situations, we may run into case where
loop has multiple exits and all are considered as likely but then we scale down
the profile and one of the exits becomes unlikely.

We pass around unadjusted_exit_count to scale exit probability correctly.  In this
case we may end up using uninitialized value and profile-count type intentionally
bombs on that.

gcc/ChangeLog:

PR bootstrap/110857
* cfgloopmanip.cc (scale_loop_profile): (Un)initialize
unadjusted_exit_count.

9 months agoRead global value/mask in IPA.
Aldy Hernandez [Fri, 14 Jul 2023 10:38:16 +0000 (12:38 +0200)] 
Read global value/mask in IPA.

Instead of reading the known zero bits in IPA, read the value/mask
pair which is available.

There is a slight change of behavior here.  I have removed the check
for SSA_NAME, as the ranger can calculate the range and value/mask for
INTEGER_CST.  This simplifies the code a bit, since there's no special
casing when setting the jfunc bits.  The default range for VR is
undefined, so I think it's safe just to check for undefined_p().

gcc/ChangeLog:

* ipa-prop.cc (ipa_compute_jump_functions_for_edge): Read global
value/mask.

gcc/testsuite/ChangeLog:

* g++.dg/ipa/pure-const-3.C: Move source to...
* g++.dg/ipa/pure-const-3.h: ...here, and adjust original test
accordingly.
* g++.dg/ipa/pure-const-3b.C: New.

9 months ago[PATCH 3/5] [RISC-V] Generate Zicond instruction for select pattern with condition...
Xiao Zeng [Thu, 3 Aug 2023 20:09:46 +0000 (16:09 -0400)] 
[PATCH 3/5] [RISC-V] Generate Zicond instruction for select pattern with condition eq or neq to 0

[ This is a partial commit.  So not all the cases mentioned by
  Xiao are currently handled. ]

This patch recognizes Zicond patterns when the select pattern
with condition eq or neq to 0 (using eq as an example), namely:

1 rd = (rs2 == 0) ? non-imm : 0
2 rd = (rs2 == 0) ? non-imm : non-imm
3 rd = (rs2 == 0) ? reg : non-imm
4 rd = (rs2 == 0) ? reg : reg

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_expand_conditional_move): Recognize
various Zicond patterns.
* config/riscv/riscv.md (mov<mode>cc): Allow TARGET_ZICOND.  Use
sfb_alu_operand for both arms of the conditional move.

Co-authored-by: Jeff Law <jlaw@ventanamicro.com>
9 months agobpf: CO-RE builtins support tests.
Cupertino Miranda [Thu, 27 Jul 2023 17:05:22 +0000 (18:05 +0100)] 
bpf: CO-RE builtins support tests.

This patch adds tests for the following builtins:
  __builtin_preserve_enum_value
  __builtin_btf_type_id
  __builtin_preserve_type_info

gcc/testsuite/ChangeLog:

* gcc.target/bpf/core-builtin-enumvalue.c: New test.
* gcc.target/bpf/core-builtin-enumvalue-errors.c: New test.
* gcc.target/bpf/core-builtin-enumvalue-opt.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-const-elimination.c: New test.
* gcc.target/bpf/core-builtin-fieldinfo-errors-1.c: Changed.
* gcc.target/bpf/core-builtin-fieldinfo-errors-2.c: Changed.
* gcc.target/bpf/core-builtin-type-based.c: New test.
* gcc.target/bpf/core-builtin-type-id.c: New test.
* gcc.target/bpf/core-support.h: New test.

9 months agobpf: Implementation of BPF CO-RE builtins
Cupertino Miranda [Thu, 6 Apr 2023 14:22:48 +0000 (15:22 +0100)] 
bpf: Implementation of BPF CO-RE builtins

This patch updates the support for the BPF CO-RE builtins
__builtin_preserve_access_index and __builtin_preserve_field_info,
and adds support for the CO-RE builtins __builtin_btf_type_id,
__builtin_preserve_type_info and __builtin_preserve_enum_value.

These CO-RE relocations are now converted to __builtin_core_reloc which
abstracts all of the original builtins in a polymorphic relocation
specific builtin.

The builtin processing is now split in 2 stages, the first (pack) is
executed right after the front-end and the second (process) right before
the asm output.

In expand pass the __builtin_core_reloc is converted to a
unspec:UNSPEC_CORE_RELOC rtx entry.

The data required to process the builtin is now collected in the packing
stage (after front-end), not allowing the compiler to optimize any of
the relevant information required to compose the relocation when
necessary.
At expansion, that information is recovered and CTF/BTF is queried to
construct the information that will be used in the relocation.
At this point the relocation is added to specific section and the
builtin is expanded to the expected default value for the builtin.

In order to process __builtin_preserve_enum_value, it was necessary to
hook the front-end to collect the original enum value reference.
This is needed since the parser folds all the enum values to its
integer_cst representation.

More details can be found within the core-builtins.cc.

Regtested in host x86_64-linux-gnu and target bpf-unknown-none.

gcc/ChangeLog:

PR target/107844
PR target/107479
PR target/107480
PR target/107481
* config.gcc: Added core-builtins.cc and .o files.
* config/bpf/bpf-passes.def: Removed file.
* config/bpf/bpf-protos.h (bpf_add_core_reloc,
bpf_replace_core_move_operands): New prototypes.
* config/bpf/bpf.cc (enum bpf_builtins, is_attr_preserve_access,
maybe_make_core_relo, bpf_core_field_info, bpf_core_compute,
bpf_core_get_index, bpf_core_new_decl, bpf_core_walk,
bpf_is_valid_preserve_field_info_arg, is_attr_preserve_access,
handle_attr_preserve, pass_data_bpf_core_attr, pass_bpf_core_attr):
Removed.
(def_builtin, bpf_expand_builtin, bpf_resolve_overloaded_builtin): Changed.
* config/bpf/bpf.md (define_expand mov<MM:mode>): Changed.
(mov_reloc_core<mode>): Added.
* config/bpf/core-builtins.cc (struct cr_builtin, enum
cr_decision struct cr_local, struct cr_final, struct
core_builtin_helpers, enum bpf_plugin_states): Added types.
(builtins_data, core_builtin_helpers, core_builtin_type_defs):
Added variables.
(allocate_builtin_data, get_builtin-data, search_builtin_data,
remove_parser_plugin, compare_same_kind, compare_same_ptr_expr,
compare_same_ptr_type, is_attr_preserve_access, core_field_info,
bpf_core_get_index, compute_field_expr,
pack_field_expr_for_access_index, pack_field_expr_for_preserve_field,
process_field_expr, pack_enum_value, process_enum_value, pack_type,
process_type, bpf_require_core_support, make_core_relo, read_kind,
kind_access_index, kind_preserve_field_info, kind_enum_value,
kind_type_id, kind_preserve_type_info, get_core_builtin_fndecl_for_type,
bpf_handle_plugin_finish_type, bpf_init_core_builtins,
construct_builtin_core_reloc, bpf_resolve_overloaded_core_builtin,
bpf_expand_core_builtin, bpf_add_core_reloc,
bpf_replace_core_move_operands): Added functions.
* config/bpf/core-builtins.h (enum bpf_builtins): Added.
(bpf_init_core_builtins, bpf_expand_core_builtin,
bpf_resolve_overloaded_core_builtin): Added functions.
* config/bpf/coreout.cc (struct bpf_core_extra): Added.
(bpf_core_reloc_add, output_asm_btfext_core_reloc): Changed.
* config/bpf/coreout.h (bpf_core_reloc_add) Changed prototype.
* config/bpf/t-bpf: Added core-builtins.o.
* doc/extend.texi: Added documentation for new BPF builtins.

9 months agoAdd operand ranges to op1_op2_relation API.
Andrew MacLeod [Tue, 1 Aug 2023 18:33:09 +0000 (14:33 -0400)] 
Add operand ranges to op1_op2_relation API.

With additional floating point relations in the pipeline, we can no
longer tell based on the LHS what the relation of X < Y is without knowing
the type of X and Y.

* gimple-range-fold.cc (fold_using_range::range_of_range_op): Add
ranges to the call to relation_fold_and_or.
(fold_using_range::relation_fold_and_or): Add op1 and op2 ranges.
(fur_source::register_outgoing_edges): Add op1 and op2 ranges.
* gimple-range-fold.h (relation_fold_and_or): Adjust params.
* gimple-range-gori.cc (gori_compute::compute_operand_range): Add
a varying op1 and op2 to call.
* range-op-float.cc (range_operator::op1_op2_relation): New dafaults.
(operator_equal::op1_op2_relation): New float version.
(operator_not_equal::op1_op2_relation): Ditto.
(operator_lt::op1_op2_relation): Ditto.
(operator_le::op1_op2_relation): Ditto.
(operator_gt::op1_op2_relation): Ditto.
(operator_ge::op1_op2_relation) Ditto.
* range-op-mixed.h (operator_equal::op1_op2_relation): New float
prototype.
(operator_not_equal::op1_op2_relation): Ditto.
(operator_lt::op1_op2_relation): Ditto.
(operator_le::op1_op2_relation): Ditto.
(operator_gt::op1_op2_relation): Ditto.
(operator_ge::op1_op2_relation): Ditto.
* range-op.cc (range_op_handler::op1_op2_relation): Dispatch new
variations.
(range_operator::op1_op2_relation): Add extra params.
(operator_equal::op1_op2_relation): Ditto.
(operator_not_equal::op1_op2_relation): Ditto.
(operator_lt::op1_op2_relation): Ditto.
(operator_le::op1_op2_relation): Ditto.
(operator_gt::op1_op2_relation): Ditto.
(operator_ge::op1_op2_relation): Ditto.
* range-op.h (range_operator): New prototypes.
(range_op_handler): Ditto.

9 months agoProvide a routine for NAME == NAME relation.
Andrew MacLeod [Wed, 2 Aug 2023 14:58:37 +0000 (10:58 -0400)] 
Provide a routine for NAME == NAME relation.

We've been assuming x == x s VREL_EQ in GORI, but this is not always going to
be true with floating point.  Provide an API to return the relation.

* gimple-range-gori.cc (gori_compute::compute_operand1_range):
Use identity relation.
(gori_compute::compute_operand2_range): Ditto.
* value-relation.cc (get_identity_relation): New.
* value-relation.h (get_identity_relation): New prototype.

9 months agoAutomatically set type is certain Value_Range routines.
Andrew MacLeod [Wed, 2 Aug 2023 21:46:58 +0000 (17:46 -0400)] 
Automatically set type is certain Value_Range routines.

Set routines which take a type shouldn't have to pre-set the type of the
underlying range as it is specified as a parameter already.

* value-range.h (Value_Range::set_varying): Set the type.
(Value_Range::set_zero): Ditto.
(Value_Range::set_nonzero): Ditto.

9 months ago[committed][RISC-V] Remove errant hunk of code
Jeff Law [Thu, 3 Aug 2023 14:57:23 +0000 (10:57 -0400)] 
[committed][RISC-V] Remove errant hunk of code

I'm using this hunk locally to more thoroughly exercise the zicond paths
due to inaccuracies elsewhere in the costing model.  It was never
supposed to be part of the costing commit though.  And as we've seen
it's causing problems with the vector bits.

While my testing isn't complete, this hunk was never supposed to be
pushed and it's causing problems.  So I'm just ripping it out.

There's a bigger TODO in this space WRT a top-to-bottom evaluation of
the costing on RISC-V.  I'm still formulating what that evaluation is
going to look like, so don't hold your breath waiting on it.

Pushed to the trunk.

gcc/

* config/riscv/riscv.cc (riscv_rtx_costs): Remove errant hunk from
recent commit.

9 months agotestsuite, analyzer: add test case [PR108171]
David Malcolm [Thu, 3 Aug 2023 14:47:22 +0000 (10:47 -0400)] 
testsuite, analyzer: add test case [PR108171]

The ICE in PR analyzer/108171 appears to be a dup of the recently fixed
PR analyzer/110882 and is likewise fixed by it; adding this test case.

gcc/testsuite/ChangeLog:
PR analyzer/108171
* gcc.dg/analyzer/pr108171.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
9 months agoRISC-V: Fix one comment for binop_frm insn
Pan Li [Thu, 3 Aug 2023 14:27:56 +0000 (22:27 +0800)] 
RISC-V: Fix one comment for binop_frm insn

The previous patch missed the vfsub comment for binop_frm, this
patch would like to fix this.

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

* config/riscv/riscv-vector-builtins-bases.cc: Add vfsub.

9 months agoanalyzer: fix ICE on zero-sized arrays [PR110882]
David Malcolm [Thu, 3 Aug 2023 13:47:44 +0000 (09:47 -0400)] 
analyzer: fix ICE on zero-sized arrays [PR110882]

gcc/analyzer/ChangeLog:
PR analyzer/110882
* region.cc (int_size_in_bits): Fail on zero-sized types.

gcc/testsuite/ChangeLog:
PR analyzer/110882
* gcc.dg/analyzer/pr110882.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
9 months ago[libbacktrace] fix up broken test
Richard Biener [Thu, 3 Aug 2023 13:21:51 +0000 (15:21 +0200)] 
[libbacktrace] fix up broken test

zstdtest has some inline data where some testcases lack the
uncompressed length field.  Thus it computes that but still
ends up allocating memory for the uncompressed buffer based on
that (zero) length.  Oops.  Causes memory corruption if the
allocator returns non-NULL.

libbacktrace/
* zstdtest.c (test_samples): Properly compute the allocation
size for the uncompressed data.

9 months agopoly_int: Handle more can_div_trunc_p cases
Richard Sandiford [Thu, 3 Aug 2023 12:54:11 +0000 (13:54 +0100)] 
poly_int: Handle more can_div_trunc_p cases

can_div_trunc_p (a, b, &Q, &r) tries to compute a Q and r that
satisfy the usual conditions for truncating division:

     (1) a = b * Q + r
     (2) |b * Q| <= |a|
     (3) |r| < |b|

We can compute Q using the constant component (the case when
all indeterminates are zero).  Since |r| < |b| for the constant
case, the requirements for indeterminate xi with coefficients
ai (for a) and bi (for b) are:

     (2') |bi * Q| <= |ai|
     (3') |ai - bi * Q| <= |bi|

(See the big comment for more details, restrictions, and reasoning).

However, the function works on abstract arithmetic types, and so
it has to be careful not to introduce new overflow.  The code
therefore only handled the extreme for (3'), that is:

     |ai - bi * Q| = |bi|

for the case where Q is zero.

Looking at it again, the overflow issue is a bit easier to handle than
I'd originally thought (or so I hope).  This patch therefore extends the
code to handle |ai - bi * Q| = |bi| for all Q, with Q = 0 no longer
being a separate case.

The net effect is to allow the function to succeed for things like:

     (a0 + b1 (Q+1) x) / (b0 + b1 x)

where Q = a0 / b0, with various sign conditions.  E.g. we now handle:

     (7 + 8x) / (4 + 4x)

with Q = 1 and r = 3 + 4x,

gcc/
* poly-int.h (can_div_trunc_p): Succeed for more boundary conditions.

gcc/testsuite/
* gcc.dg/plugin/poly-int-tests.h (test_can_div_trunc_p_const)
(test_can_div_trunc_p_const): Add more tests.

9 months agotree-optimization/110838 - vectorization of widened shifts
Richard Biener [Mon, 31 Jul 2023 12:44:52 +0000 (14:44 +0200)] 
tree-optimization/110838 - vectorization of widened shifts

The following makes sure to limit the shift operand when vectorizing
(short)((int)x >> 31) via (short)x >> 31 as the out of bounds shift
operand otherwise invokes undefined behavior.  When we determine
whether we can demote the operand we know we at most shift in the
sign bit so we can adjust the shift amount.

Note this has the possibility of un-CSEing common shift operands
as there's no good way to share pattern stmts between patterns.
We'd have to separately pattern recognize the definition.

PR tree-optimization/110838
* tree-vect-patterns.cc (vect_recog_over_widening_pattern):
Adjust the shift operand of RSHIFT_EXPRs.

* gcc.dg/torture/pr110838.c: New testcase.

9 months agotree-optimization/110702 - avoid zero-based memory references in IVOPTs
Richard Biener [Thu, 3 Aug 2023 11:11:12 +0000 (13:11 +0200)] 
tree-optimization/110702 - avoid zero-based memory references in IVOPTs

Sometimes IVOPTs chooses a weird induction variable which downstream
leads to issues.  Most of the times we can fend those off during costing
by rejecting the candidate but it looks like the address description
costing synthesizes is different from what we end up generating so
the following fixes things up at code generation time.  Specifically
we avoid the create_mem_ref_raw fallback which uses a literal zero
address base with the actual base in index2.  For the case in question
we have the address

  type = unsigned long
  offset = 0
  elements = {
    [0] = &e * -3,
    [1] = (sizetype) a.9_30 * 232,
    [2] = ivtmp.28_44 * 4
  }

from which we code generate the problematical

  _3 = MEM[(long int *)0B + ivtmp.36_9 + ivtmp.28_44 * 4];

which references the object at address zero.  The patch below
recognizes the fallback after the fact and transforms the
TARGET_MEM_REF memory reference into a LEA for which this form
isn't problematic:

  _24 = &MEM[(long int *)0B + ivtmp.36_34 + ivtmp.28_44 * 4];
  _3 = *_24;

hereby avoiding the correctness issue.  We'd later conclude the
program terminates at the null pointer dereference and make the
function pure, miscompling the main function of the testcase.

PR tree-optimization/110702
* tree-ssa-loop-ivopts.cc (rewrite_use_address): When
we created a NULL pointer based access rewrite that to
a LEA.

* gcc.dg/torture/pr110702.c: New testcase.

9 months agoada: Add pragma Annotate for GNATcheck exemptions
Sheri Bernstein [Tue, 25 Jul 2023 17:16:55 +0000 (17:16 +0000)] 
ada: Add pragma Annotate for GNATcheck exemptions

Exempt the GNATcheck rule "Improper_Returns" with the rationale
"early returns for performance".

gcc/ada/

* libgnat/s-aridou.adb: Add pragma to exempt Improper_Returns.
* libgnat/s-atopri.adb (Lock_Free_Try_Write): Likewise.
* libgnat/s-bitops.adb (Bit_Eq): Likewise.
* libgnat/s-carsi8.adb: Likewise.
* libgnat/s-carun8.adb: Likewise.
* libgnat/s-casi16.adb: Likewise.
* libgnat/s-casi32.adb: Likewise.
* libgnat/s-casi64.adb: Likewise.
* libgnat/s-caun16.adb: Likewise.
* libgnat/s-caun32.adb: Likewise.
* libgnat/s-caun64.adb: Likewise.
* libgnat/s-exponn.adb: Likewise.
* libgnat/s-expont.adb: Likewise.
* libgnat/s-valspe.adb: Likewise.
* libgnat/s-vauspe.adb: Likewise.

9 months agoada: Rewrite Set_Image_*_Unsigned routines to remove recursion.
Vasiliy Fofanov [Wed, 26 Jul 2023 08:33:18 +0000 (08:33 +0000)] 
ada: Rewrite Set_Image_*_Unsigned routines to remove recursion.

This rewriting removes algorithm inefficiencies due to unnecessary
recursion and copying. The new version has much smaller and statically known
stack requirements and is additionally up to 2x faster.

gcc/ada/

* libgnat/s-imageb.adb (Set_Image_Based_Unsigned): Rewritten.
* libgnat/s-imagew.adb (Set_Image_Width_Unsigned): Likewise.

9 months agoada: Fix spurious error on 'Input of private type with Type_Invariant aspect
Eric Botcazou [Tue, 25 Jul 2023 21:03:22 +0000 (23:03 +0200)] 
ada: Fix spurious error on 'Input of private type with Type_Invariant aspect

The problem is that it is necessary to break the privacy during the
expansion of the Input attribute, which may introduce a view mismatch
with the parameter of the routine checking the invariant of the type.

gcc/ada/

* exp_util.adb (Make_Invariant_Call): Convert the expression to
the type of the formal parameter if need be.

9 months agoada: Adjust again address arithmetics in System.Dwarf_Lines
Eric Botcazou [Mon, 24 Jul 2023 13:02:25 +0000 (15:02 +0200)] 
ada: Adjust again address arithmetics in System.Dwarf_Lines

Using the operator of System.Storage_Elements has introduced a range check
that may be tripped on, so this removes the intermediate conversion to the
Storage_Count subtype that is responsible for it.

gcc/ada/

* libgnat/s-dwalin.adb ("-"): New subtraction operator.
(Enable_Cache): Use it to compute the offset.
(Symbolic_Address): Likewise.

9 months agoImprove sinking with unrelated defs
Richard Biener [Wed, 26 Jul 2023 13:23:45 +0000 (15:23 +0200)] 
Improve sinking with unrelated defs

statement_sink_location for loads is currently confused about
stores that are not on the paths we are sinking across.  The
following replaces the logic that tries to ensure we are not
sinking across stores by instead of walking all immediate virtual
uses and then checking whether found stores are on the paths
we sink through with checking the live virtual operand at the
sinking location.  To obtain the live virtual operand we rely
on the new virtual_operand_live class which provides an overall
cheaper and also more precise way to check the constraints.

* tree-ssa-sink.cc: Include tree-ssa-live.h.
(pass_sink_code::execute): Instantiate virtual_operand_live
and pass it down.
(sink_code_in_bb): Pass down virtual_operand_live.
(statement_sink_location): Get virtual_operand_live and
verify we are not sinking loads across stores by looking up
the live virtual operand at the sink location.

* gcc.dg/tree-ssa/ssa-sink-20.c: New testcase.

9 months agoAdd virtual operand global liveness computation class
Richard Biener [Wed, 2 Aug 2023 11:33:43 +0000 (13:33 +0200)] 
Add virtual operand global liveness computation class

The following adds an on-demand global liveness computation class
computing and caching the live-out virtual operand of basic blocks
and answering live-out, live-in and live-on-edge queries.  The flow
is optimized for the intended use in code sinking which will query
live-in and possibly can be optimized further when the originating
query is for live-out.

The code relies on up-to-date immediate dominator information and
on an unchanging virtual operand state.

* tree-ssa-live.h (class virtual_operand_live): New.
* tree-ssa-live.cc (virtual_operand_live::init): New.
(virtual_operand_live::get_live_in): Likewise.
(virtual_operand_live::get_live_out): Likewise.

9 months agoSwap loop splitting and final value replacement
Richard Biener [Thu, 3 Aug 2023 08:59:52 +0000 (10:59 +0200)] 
Swap loop splitting and final value replacement

The following swaps the loop splitting pass and the final value
replacement pass to avoid keeping the IV of the earlier loop
live when not necessary.  The existing gcc.target/i386/pr87007-5.c
testcase shows that we otherwise fail to elide an empty loop
later.  I don't see any good reason why loop splitting would need
final value replacement, all exit values honor the constraints
we place on loop header PHIs automatically.

* passes.def: Exchange loop splitting and final value
replacement passes.

* gcc.target/i386/pr87007-5.c: Make sure we split the loop
and eliminate both in the end.

9 months agos390: Try to emit vlbr/vstbr instead of vperm et al.
Stefan Schulze Frielinghaus [Thu, 3 Aug 2023 08:30:08 +0000 (10:30 +0200)] 
s390: Try to emit vlbr/vstbr instead of vperm et al.

gcc/ChangeLog:

* config/s390/s390.cc (expand_perm_as_a_vlbr_vstbr_candidate):
New function which handles bswap patterns for vec_perm_const.
(vectorize_vec_perm_const_1): Call new function.
* config/s390/vector.md (*bswap<mode>): Fix operands in output
template.
(*vstbr<mode>): New insn.

gcc/testsuite/ChangeLog:

* gcc.target/s390/s390.exp: Add subdirectory vxe2.
* gcc.target/s390/vxe2/vlbr-1.c: New test.
* gcc.target/s390/vxe2/vstbr-1.c: New test.
* gcc.target/s390/vxe2/vstbr-2.c: New test.

9 months agos390: Enable vect_bswap test cases
Stefan Schulze Frielinghaus [Thu, 3 Aug 2023 08:29:51 +0000 (10:29 +0200)] 
s390: Enable vect_bswap test cases

This enables the following tests which rely on instruction vperm which
is available since z13 with the initial vector support.

testsuite/gcc.dg/vect/vect-bswap16.c
42:/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_bswap || sse4_runtime } } } } */

testsuite/gcc.dg/vect/vect-bswap32.c
42:/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_bswap || sse4_runtime } } } } */

testsuite/gcc.dg/vect/vect-bswap64.c
42:/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_bswap || sse4_runtime } } } } */

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_vect_bswap):
Add s390.

9 months agoIntroduce -msmp to select /lib_smp/ on ppc-vx6
Alexandre Oliva [Thu, 3 Aug 2023 06:34:31 +0000 (03:34 -0300)] 
Introduce -msmp to select /lib_smp/ on ppc-vx6

The .spec files used for linking on ppc-vx6, when the rtp-smp runtime
is selected, add -L flags for /lib_smp/ and /lib/.

There was a problem, though: although /lib_smp/ and /lib/ were to be
searched in this order, and the specs files do that correctly, the
compiler would search /lib/ first regardless, because
STARTFILE_PREFIX_SPEC said so, and specs files cannot override that.

With this patch, we arrange for the presence of -msmp to affect
STARTFILE_PREFIX_SPEC, so that the compiler searches /lib_smp/ rather
than /lib/ for crt files.  A separate patch for GNAT ensures that when
the rtp-smp runtime is selected, -msmp is passed to the compiler
driver for linking, along with the --specs flags.

for  gcc/ChangeLog

* config/vxworks-smp.opt: New.  Introduce -msmp.
* config.gcc: Enable it on powerpc* vxworks prior to 7r*.
* config/rs6000/vxworks.h (STARTFILE_PREFIX_SPEC): Choose
lib_smp when -msmp is present in the command line.
* doc/invoke.texi: Document it.

9 months agoRISCV: Add -m(no)-omit-leaf-frame-pointer support.
Yanzhang Wang [Tue, 18 Jul 2023 07:49:58 +0000 (15:49 +0800)] 
RISCV: Add -m(no)-omit-leaf-frame-pointer support.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_save_reg_p): Save ra for leaf
when enabling -mno-omit-leaf-frame-pointer
(riscv_option_override): Override omit-frame-pointer.
(riscv_frame_pointer_required): Save s0 for non-leaf function
(TARGET_FRAME_POINTER_REQUIRED): Override defination
* config/riscv/riscv.opt: Add option support.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/omit-frame-pointer-1.c: New test.
* gcc.target/riscv/omit-frame-pointer-2.c: New test.
* gcc.target/riscv/omit-frame-pointer-3.c: New test.
* gcc.target/riscv/omit-frame-pointer-4.c: New test.
* gcc.target/riscv/omit-frame-pointer-test.c: New test.

Signed-off-by: Yanzhang Wang <yanzhang.wang@intel.com>
9 months agoPR target/110792: Early clobber issues with rot32di2_doubleword on i386.
Roger Sayle [Thu, 3 Aug 2023 06:12:04 +0000 (07:12 +0100)] 
PR target/110792: Early clobber issues with rot32di2_doubleword on i386.

This patch is a conservative fix for PR target/110792, a wrong-code
regression affecting doubleword rotations by BITS_PER_WORD, which
effectively swaps the highpart and lowpart words, when the source to be
rotated resides in memory. The issue is that if the register used to
hold the lowpart of the destination is mentioned in the address of
the memory operand, the current define_insn_and_split unintentionally
clobbers it before reading the highpart.

Hence, for the testcase, the incorrectly generated code looks like:

        salq    $4, %rdi // calculate address
        movq    WHIRL_S+8(%rdi), %rdi // accidentally clobber addr
        movq    WHIRL_S(%rdi), %rbp // load (wrong) lowpart

Traditionally, the textbook way to fix this would be to add an
explicit early clobber to the instruction's constraints.

 (define_insn_and_split "<insn>32di2_doubleword"
- [(set (match_operand:DI 0 "register_operand" "=r,r,r")
+ [(set (match_operand:DI 0 "register_operand" "=r,r,&r")
        (any_rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0,r,o")
                       (const_int 32)))]

but unfortunately this currently generates significantly worse code,
due to a strange choice of reloads (effectively memcpy), which ends up
looking like:

        salq    $4, %rdi // calculate address
        movdqa  WHIRL_S(%rdi), %xmm0 // load the double word in SSE reg.
        movaps  %xmm0, -16(%rsp) // store the SSE reg back to the stack
        movq    -8(%rsp), %rdi // load highpart
        movq    -16(%rsp), %rbp // load lowpart

Note that reload's "&" doesn't distinguish between the memory being
early clobbered, vs the registers used in an addressing mode being
early clobbered.

The fix proposed in this patch is to remove the third alternative, that
allowed offsetable memory as an operand, forcing reload to place the
operand into a register before the rotation.  This results in:

        salq    $4, %rdi
        movq    WHIRL_S(%rdi), %rax
        movq    WHIRL_S+8(%rdi), %rdi
        movq    %rax, %rbp

I believe there's a more advanced solution, by swapping the order of
the loads (if first destination register is mentioned in the address),
or inserting a lea insn (if both destination registers are mentioned
in the address), but this fix is a minimal "safe" solution, that
should hopefully be suitable for backporting.

2023-08-03  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR target/110792
* config/i386/i386.md (<any_rotate>ti3): For rotations by 64 bits
place operand in a register before gen_<insn>64ti2_doubleword.
(<any_rotate>di3): Likewise, for rotations by 32 bits, place
operand in a register before gen_<insn>32di2_doubleword.
(<any_rotate>32di2_doubleword): Constrain operand to be in register.
(<any_rotate>64ti2_doubleword): Likewise.

gcc/testsuite/ChangeLog
PR target/110792
* g++.target/i386/pr110792.C: New 32-bit C++ test case.
* gcc.target/i386/pr110792.c: New 64-bit C test case.

9 months agoRISC-V: Support RVV VFMUL rounding mode intrinsic API
Pan Li [Thu, 3 Aug 2023 01:30:24 +0000 (09:30 +0800)] 
RISC-V: Support RVV VFMUL rounding mode intrinsic API

Update in v2:

* Sync with upstream for the vfmul duplicated declaration.

Original log:

This patch would like to support the rounding mode API for the VFMUL
for the below samples.

* __riscv_vfmul_vv_f32m1_rm
* __riscv_vfmul_vv_f32m1_rm_m
* __riscv_vfmul_vf_f32m1_rm
* __riscv_vfmul_vf_f32m1_rm_m

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

* config/riscv/riscv-vector-builtins-bases.cc
(vfmul_frm_obj): New declaration.
(Base): Likewise.
* config/riscv/riscv-vector-builtins-bases.h: Likewise.
* config/riscv/riscv-vector-builtins-functions.def
(vfmul_frm): New function definition.
* config/riscv/vector.md: Add vfmul to frm_mode.

gcc/testsuite/ChangeLog:

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

9 months agoFix `~X & X` and `~X | X` patterns
Andrew Pinski [Wed, 2 Aug 2023 22:54:20 +0000 (15:54 -0700)] 
Fix `~X & X` and `~X | X` patterns

As Jakub noticed in https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626039.html
what I did was not totally correct because sometimes chosing the wrong type.
So to get back to what the original code but keeping around the use of bitwise_inverted_equal_p,
we just need to check if the types of the two catupures are the same type.

Also adds a testcase for the problem Jakub found.

Committed as obvious after a bootstrap and test.

gcc/ChangeLog:

* match.pd (`~X & X`): Check that the types match.
(`~x | x`, `~x ^ x`): Likewise.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/20230802-1.c: New test.

9 months agoRISC-V: Remove redudant extern declaration in function base
Pan Li [Thu, 3 Aug 2023 02:08:54 +0000 (10:08 +0800)] 
RISC-V: Remove redudant extern declaration in function base

This patch would like to remove the redudant declaration.

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

* config/riscv/riscv-vector-builtins-bases.h: Remove
redudant declaration.

9 months agoRISC-V: Support RVV VFWSUB rounding mode intrinsic API
Pan Li [Wed, 2 Aug 2023 10:15:47 +0000 (18:15 +0800)] 
RISC-V: Support RVV VFWSUB rounding mode intrinsic API

This patch would like to support the rounding mode API for the VFWSUB
for the below samples.

    * __riscv_vfwsub_vv_f64m2_rm
    * __riscv_vfwsub_vv_f64m2_rm_m
    * __riscv_vfwsub_vf_f64m2_rm
    * __riscv_vfwsub_vf_f64m2_rm_m
    * __riscv_vfwsub_wv_f64m2_rm
    * __riscv_vfwsub_wv_f64m2_rm_m
    * __riscv_vfwsub_wf_f64m2_rm
    * __riscv_vfwsub_wf_f64m2_rm_m

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

* config/riscv/riscv-vector-builtins-bases.cc (BASE): Add
vfwsub frm.
* config/riscv/riscv-vector-builtins-bases.h: Add declaration.
* config/riscv/riscv-vector-builtins-functions.def (vfwsub_frm):
Add vfwsub function definitions.

gcc/testsuite/ChangeLog:

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

9 months agoDaily bump.
GCC Administrator [Thu, 3 Aug 2023 00:17:10 +0000 (00:17 +0000)] 
Daily bump.

9 months agoanalyzer: stash values for CPython plugin [PR107646]
Eric Feng [Wed, 2 Aug 2023 20:54:55 +0000 (16:54 -0400)] 
analyzer: stash values for CPython plugin [PR107646]

This patch adds a hook to the end of ana::on_finish_translation_unit
which calls relevant stashing-related callbacks registered during plugin
initialization. This feature is used to stash named types and global
variables for a CPython analyzer plugin [PR107646].

gcc/analyzer/ChangeLog:
PR analyzer/107646
* analyzer-language.cc (run_callbacks): New function.
(on_finish_translation_unit): New function.
* analyzer-language.h (GCC_ANALYZER_LANGUAGE_H): New include.
(class translation_unit): New vfuncs.

gcc/c/ChangeLog:
PR analyzer/107646
* c-parser.cc: New functions on stashing values for the
analyzer.

gcc/testsuite/ChangeLog:
PR analyzer/107646
* gcc.dg/plugin/plugin.exp: Add new plugin and test.
* gcc.dg/plugin/analyzer_cpython_plugin.c: New plugin.
* gcc.dg/plugin/cpython-plugin-test-1.c: New test.

Signed-off-by: Eric Feng <ef2648@columbia.edu>
9 months agortl-optimization/110867 Fix narrow comparison of memory and constant
Stefan Schulze Frielinghaus [Wed, 2 Aug 2023 19:43:22 +0000 (21:43 +0200)] 
rtl-optimization/110867 Fix narrow comparison of memory and constant

In certain cases a constant may not fit into the mode used to perform a
comparison.  This may be the case for sign-extended constants which are
used during an unsigned comparison as e.g. in

(set (reg:CC 100 cc)
    (compare:CC (mem:SI (reg/v/f:SI 115 [ a ]) [1 *a_4(D)+0 S4 A64])
        (const_int -2147483648 [0xffffffff80000000])))

Fixed by ensuring that the constant fits into comparison mode.

Furthermore, on some targets as e.g. sparc the constant used in a
comparison is chopped off before combine which leads to failing test
cases (see PR 110869).  Fixed by not requiring that the source mode has
to be DImode, and excluding sparc from the last two test cases entirely
since there the constant cannot be further reduced.

gcc/ChangeLog:

PR rtl-optimization/110867
* combine.cc (simplify_compare_const): Try the optimization only
in case the constant fits into the comparison mode.

gcc/testsuite/ChangeLog:

PR rtl-optimization/110869
* gcc.dg/cmp-mem-const-1.c: Relax mode for constant.
* gcc.dg/cmp-mem-const-2.c: Relax mode for constant.
* gcc.dg/cmp-mem-const-3.c: Relax mode for constant.
* gcc.dg/cmp-mem-const-4.c: Relax mode for constant.
* gcc.dg/cmp-mem-const-5.c: Exclude sparc since here the
constant is already reduced.
* gcc.dg/cmp-mem-const-6.c: Exclude sparc since here the
constant is already reduced.

9 months ago[committed][RISC-V] Fix 20010221-1.c with zicond
Jeff Law [Wed, 2 Aug 2023 17:16:23 +0000 (13:16 -0400)] 
[committed][RISC-V] Fix 20010221-1.c with zicond

So we're being a bit too aggressive with the .opt zicond patterns.

> (define_insn "*czero.eqz.<GPR:mode><X:mode>.opt1"
>   [(set (match_operand:GPR 0 "register_operand"                   "=r")
>         (if_then_else:GPR (eq (match_operand:X 1 "register_operand" "r")
>                               (const_int 0))
>                           (match_operand:GPR 2 "register_operand" "1")
>                           (match_operand:GPR 3 "register_operand" "r")))]
>   "(TARGET_ZICOND || 1) && rtx_equal_p (operands[1], operands[2])"
>   "czero.eqz\t%0,%3,%1"
> )
The RTL semantics here are op0 = (op1 == 0) ? op1 : op2.  That maps
directly to czero.eqz.  ie, we select op1 when we know it's zero, op2
otherwise.  So this pattern is fine.

> (define_insn "*czero.eqz.<GPR:mode><X:mode>.opt2"
>   [(set (match_operand:GPR 0 "register_operand"                   "=r")
>         (if_then_else:GPR (eq (match_operand:X 1 "register_operand" "r")
>                               (const_int 0))
>                           (match_operand:GPR 2 "register_operand" "r")
>                           (match_operand:GPR 3 "register_operand" "1")))]
>   "(TARGET_ZICOND || 1) && rtx_equal_p (operands[1],  operands[3])"
>   "czero.nez\t%0,%2,%1"
> )

The RTL semantics of this pattern are are: op0 = (op1 == 0) ? op2 : op1;

That's not something that can be expressed by the zicond extension as it
selects op1 if and only if op1 is not equal to zero.

> (define_insn "*czero.nez.<GPR:mode><X:mode>.opt3"
>   [(set (match_operand:GPR 0 "register_operand"                   "=r")
>         (if_then_else:GPR (ne (match_operand:X 1 "register_operand" "r")
>                               (const_int 0))
>                           (match_operand:GPR 2 "register_operand" "r")
>                           (match_operand:GPR 3 "register_operand" "1")))]
>   "(TARGET_ZICOND || 1) && rtx_equal_p (operands[1], operands[3])"
>   "czero.eqz\t%0,%2,%1"
> )
The RTL semantics of this pattern are op0 = (op1 != 0) ? op2 : op1.
That maps to czero.nez.  But the output template uses czero.eqz.  Opps.

> (define_insn "*czero.nez.<GPR:mode><X:mode>.opt4"
>   [(set (match_operand:GPR 0 "register_operand"                   "=r")
>         (if_then_else:GPR (ne (match_operand:X 1 "register_operand" "r")
>                               (const_int 0))
>                           (match_operand:GPR 2 "register_operand" "1")
>                           (match_operand:GPR 3 "register_operand" "r")))]
>   "(TARGET_ZICOND || 1) && rtx_equal_p (operands[1], operands[2])"
>   "czero.nez\t%0,%3,%1"
> )

The RTL semantics of this pattern are op0 = (op1 != 0) ? op1 : op2 which
obviously doesn't match to any zicond instruction as op1 is selected
when it is not zero.

So two of the patterns are just totally bogus as they are not
implementable with zicond.  They are removed.  The asm template for the
.opt3 pattern is fixed to use czero.nez and its name is changed to
.opt2.

gcc/
* config/riscv/zicond.md: Remove incorrect zicond patterns and
renumber/rename them.
(zero.nez.<GPR:MODE><X:mode>.opt2): Fix output string.

9 months agoMake add_phi_node_to_bb static
Richard Biener [Wed, 2 Aug 2023 11:26:06 +0000 (13:26 +0200)] 
Make add_phi_node_to_bb static

The only exported PHI allocation already adds the PHI node to a block.

* tree-phinodes.h (add_phi_node_to_bb): Remove.
* tree-phinodes.cc  (add_phi_node_to_bb): Make static.

9 months agox86: fold two of vec_dupv2df<mask_name>'s alternatives
Jan Beulich [Wed, 2 Aug 2023 09:04:37 +0000 (11:04 +0200)] 
x86: fold two of vec_dupv2df<mask_name>'s alternatives

By using Yvm in the source, both can be expressed in one.

gcc/

* config/i386/sse.md (vec_dupv2df<mask_name>): Fold the middle
two of the alternatives.

9 months agoMAINTAINERS: correct my email address
Jan Beulich [Wed, 2 Aug 2023 09:00:35 +0000 (11:00 +0200)] 
MAINTAINERS: correct my email address

The @novell.com one has been out of use for quite some time.

ChangeLog:

* MAINTAINERS: Correct my email address.

9 months agotree-optimization/92335 - Improve sinking heuristics for vectorization
Richard Biener [Thu, 27 Jul 2023 13:34:12 +0000 (15:34 +0200)] 
tree-optimization/92335 - Improve sinking heuristics for vectorization

The following delays sinking of loads within the same innermost
loop when it was unconditional before.  That's a not uncommon
issue preventing vectorization when masked loads are not available.

PR tree-optimization/92335
* tree-ssa-sink.cc (select_best_block): Before loop
optimizations avoid sinking unconditional loads/stores
in innermost loops to conditional executed places.

* gcc.dg/tree-ssa/ssa-sink-10.c: Disable vectorizing.
* gcc.dg/tree-ssa/predcom-9.c: Clone from ssa-sink-10.c,
expect predictive commoning to happen instead of sinking.
* gcc.dg/vect/pr65947-3.c: Ajdust.

9 months agoSlightly improve bitwise_inverted_equal_p comparisons
Andrew Pinski [Sat, 29 Jul 2023 23:29:09 +0000 (16:29 -0700)] 
Slightly improve bitwise_inverted_equal_p comparisons

This slighly improves bitwise_inverted_equal_p
for comparisons. Instead of just comparing the
comparisons operands also valueize them.
This will allow ccp and others to match the 2 comparisons
without an extra pass happening.

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

gcc/ChangeLog:

* gimple-match-head.cc (gimple_bitwise_inverted_equal_p): Valueize
the comparison operands before comparing them.

9 months agoMove `~X & X` and `~X | X` over to use bitwise_inverted_equal_p
Andrew Pinski [Sat, 29 Jul 2023 20:00:04 +0000 (13:00 -0700)] 
Move `~X & X` and `~X | X` over to use bitwise_inverted_equal_p

This is a simple patch to move these 2 patterns over to use
bitwise_inverted_equal_p. It also allows us to remove 2 other patterns
which were used on comparisons as they are now handled by
the original pattern.

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

gcc/ChangeLog:

* match.pd (`~X & X`, `~X | X`): Move over to
use bitwise_inverted_equal_p, removing :c as bitwise_inverted_equal_p
handles that already.
Remove range test simplifications to true/false as they
are now handled by these patterns.

9 months agoPHIOPT: Mark the conditional lhs and rhs as to look at to see if DCEable
Andrew Pinski [Tue, 13 Jun 2023 16:17:45 +0000 (09:17 -0700)] 
PHIOPT: Mark the conditional lhs and rhs as to look at to see if DCEable

In some cases (usually dealing with bools only), there could be some statements
left behind which are considered trivial dead.
An example is:
```
bool f(bool a, bool b)
{
    if (!a && !b)
        return 0;
    if (!a && b)
        return 0;
    if (a && !b)
        return 0;
    return 1;
}
```
Where during phiopt2, the IR had:
```
  _3 = ~b_7(D);
  _4 = _3 & a_6(D);
  _4 != 0 ? 0 : 1
```
match-and-simplify would transform that into:
```
  _11 = ~a_6(D);
  _12 = b_7(D) | _11;
```
But phiopt would leave around the statements defining _4 and _3.
This helps by marking the conditional's lhs and rhs to see if they are
trivial dead.

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

gcc/ChangeLog:

* tree-ssa-phiopt.cc (match_simplify_replacement): Mark's cond
statement's lhs and rhs to check if trivial dead.
Rename inserted_exprs to exprs_maybe_dce; also move it so
bitmap is not allocated if not needed.

9 months agoRISC-V: Support RVV VFWADD rounding mode intrinsic API
Pan Li [Wed, 2 Aug 2023 02:24:39 +0000 (10:24 +0800)] 
RISC-V: Support RVV VFWADD rounding mode intrinsic API

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

* __riscv_vfwadd_vv_f64m2_rm
* __riscv_vfwadd_vv_f64m2_rm_m
* __riscv_vfwadd_vf_f64m2_rm
* __riscv_vfwadd_vf_f64m2_rm_m
* __riscv_vfwadd_wv_f64m2_rm
* __riscv_vfwadd_wv_f64m2_rm_m
* __riscv_vfwadd_wf_f64m2_rm
* __riscv_vfwadd_wf_f64m2_rm_m

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

* config/riscv/riscv-vector-builtins-bases.cc
(class widen_binop_frm): New class for binop frm.
(BASE): Add vfwadd_frm.
* config/riscv/riscv-vector-builtins-bases.h: New declaration.
* config/riscv/riscv-vector-builtins-functions.def
(vfwadd_frm): New function definition.
* config/riscv/riscv-vector-builtins-shapes.cc
(BASE_NAME_MAX_LEN): New macro.
(struct alu_frm_def): Leverage new base class.
(struct build_frm_base): New build base for frm.
(struct widen_alu_frm_def): New struct for widen alu frm.
(SHAPE): Add widen_alu_frm shape.
* config/riscv/riscv-vector-builtins-shapes.h: New declaration.
* config/riscv/vector.md (frm_mode): Add vfwalu type.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/float-point-widening-add.c: New test.

9 months agoMore profile updating clenaups
Jan Hubicka [Wed, 2 Aug 2023 07:44:06 +0000 (09:44 +0200)] 
More profile updating clenaups

This patch commonizes loop_count_in computatoin with
expected_loop_iterations_by_profile (and moves it to cfgloopanal.cc rather than
manip) and fixes roundoff error in scale_loop_profile.  I alos noticed that
I managed to misapply the template change to gcc.dg/unroll-1.c.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

* cfgloop.h (loop_count_in): Declare.
* cfgloopanal.cc (expected_loop_iterations_by_profile): Use count_in.
(loop_count_in): Move here from ...
* cfgloopmanip.cc (loop_count_in): ... here.
(scale_loop_profile): Improve dumping; cast iteration bound to sreal.

gcc/testsuite/ChangeLog:

* gcc.dg/unroll-1.c: Fix template.

9 months agoFix profile update after cancelled loop distribution
Jan Hubicka [Wed, 2 Aug 2023 07:25:12 +0000 (09:25 +0200)] 
Fix profile update after cancelled loop distribution

Loop distribution and ifcvt introduces verisons of loops which may be removed
later if vectorization fails.  Ifcvt does this by temporarily breaking profile
and producing conditional that has two arms with 100% probability because we
know one of the versions will be removed.

Loop distribution is trickier, since it introduces test for alignment that
either survives to final code if vecotorization suceeds or is turned if it
fails.

Here we need to assign some reasonable probabilities for the case vectorization
goes well, so this code adds logic to scale profile back in case we remove the
call.

This is not perfect since we drop precise BB counts to guessed.  It is not big
deal since we do not use much reliablity of bb counts after this point.  Other
option would be to apply scale only if vectorization succeeds which however
needs bit more work at tree-loop-distribution side and would need all code in
this patch with small change that fold_loop_internal_call will have to know how
to adjust if conditional stays. I decided to go for easier solution for now.

Bootstrapped/regtested x86_64-linux, committed.

gcc/ChangeLog:

* cfg.cc (scale_strictly_dominated_blocks): New function.
* cfg.h (scale_strictly_dominated_blocks): Declare.
* tree-cfg.cc (fold_loop_internal_call): Fixup CFG profile.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/pr98308.c: Check that profile is consistent.

9 months agortl-optimization/110587 - remove quadratic regno_in_use_p
Richard Biener [Tue, 25 Jul 2023 13:32:11 +0000 (15:32 +0200)] 
rtl-optimization/110587 - remove quadratic regno_in_use_p

The following removes the code checking whether a noop copy
is between something involved in the return sequence composed
of a SET and USE.  Instead of checking for this special-case
the following makes us only ever remove noop copies between
pseudos - which is the case that is necessary for IRA/LRA
interfacing to function according to the comment.  That makes
looking for the return reg special case unnecessary, reducing
the compile-time in LRA non-specific to zero for the testcase.

PR rtl-optimization/110587
* lra-spills.cc (return_regno_p): Remove.
(regno_in_use_p): Likewise.
(lra_final_code_change): Do not remove noop moves
between hard registers.

9 months agoSupport vec_fmaddsub/vec_fmsubadd for vector HFmode.
liuhongt [Mon, 31 Jul 2023 08:03:45 +0000 (16:03 +0800)] 
Support vec_fmaddsub/vec_fmsubadd for vector HFmode.

AVX512FP16 supports vfmaddsubXXXph and vfmsubaddXXXph.
Also remove scalar mode from fmaddsub/fmsubadd pattern since there's
no scalar instruction for that.

gcc/ChangeLog:

PR target/81904
* config/i386/sse.md (vec_fmaddsub<mode>4): Extend to vector
HFmode, use mode iterator VFH instead.
(vec_fmsubadd<mode>4): Ditto.
(<sd_mask_codefor>fma_fmaddsub_<mode><sd_maskz_name><round_name>):
Remove scalar mode from iterator, use VFH_AVX512VL instead.
(<sd_mask_codefor>fma_fmsubadd_<mode><sd_maskz_name><round_name>):
Ditto.

gcc/testsuite/ChangeLog:

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

9 months agoOptimize vlddqu + inserti128 to vbroadcasti128
liuhongt [Tue, 18 Jul 2023 08:32:54 +0000 (16:32 +0800)] 
Optimize vlddqu + inserti128 to vbroadcasti128

vlddqu + vinserti128 will use shuffle port in addition to load port
comparing to vbroadcasti128, For latency perspective,vbroadcasti is no
worse than vlddqu + vinserti128.

gcc/ChangeLog:

* config/i386/sse.md (*avx2_lddqu_inserti_to_bcasti): New
pre_reload define_insn_and_split.

gcc/testsuite/ChangeLog:

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

9 months ago[PATCH 3/5] [RISC-V] Cost model for Zicond.
Xiao Zeng [Wed, 2 Aug 2023 06:17:12 +0000 (00:17 -0600)] 
[PATCH 3/5] [RISC-V] Cost model for Zicond.

This patch implements a reasonable cost model for using Zicond to
implement conditional moves.  Essentially the Zicond insns are always
COSTS_N_INSNS (1).

Note there is still a problem with the costing model in general that
results in failure to if-convert as often as we should.  In simplest
terms the insn costing model sums the cost of the SET_SRC and the
cost of the SET_DEST.  Thus the conditional move is considered twice
as costly as it should be.  That will have to be addressed separately.

gcc/
* config/riscv/riscv.cc (riscv_rtx_costs): Add costing for
using Zicond to implement some conditional moves.

9 months ago[committed] [RISC-V] Avoid sub-word mode comparisons with Zicond
Jeff Law [Wed, 2 Aug 2023 05:12:16 +0000 (23:12 -0600)] 
[committed] [RISC-V] Avoid sub-word mode comparisons with Zicond

c-torture/execute/pr59014-2.c fails with the Zicond work on rv64.  We
miscompile the "foo" routine because we have eliminated a required sign
extension.

The key routine looks like this:

foo (long long int x, long long int y)
{
  if (((int) x | (int) y) != 0)
    return 6;
  return x + y;
}

So we kindof do the expected thing.  We IOR X and Y, sign extend the result
from 32 to 64 bits, then emit a suitable conditional branch.  ie:

> (insn 10 4 12 2 (set (reg:DI 142)
>         (ior:DI (reg/v:DI 138 [ x ])
>             (reg/v:DI 139 [ y ]))) "j.c":6:16 99 {iordi3}
>      (nil))
> (insn 12 10 13 2 (set (reg:DI 144)
>         (sign_extend:DI (subreg:SI (reg:DI 142) 0))) "j.c":6:6 116 {extendsidi2}
>      (nil))
> (jump_insn 13 12 14 2 (set (pc)
>         (if_then_else (ne (reg:DI 144)
>                 (const_int 0 [0]))
>             (label_ref:DI 27)
>             (pc))) "j.c":6:6 243 {*branchdi}
>      (expr_list:REG_DEAD (reg:DI 144)
>         (int_list:REG_BR_PROB 233216732 (nil)))
When we if-convert that we generate this sequence:

> (insn 10 4 12 2 (set (reg:DI 142)
>         (ior:DI (reg/v:DI 138 [ x ])
>             (reg/v:DI 139 [ y ]))) "j.c":6:16 99 {iordi3}
>      (nil))
> (insn 12 10 30 2 (set (reg:DI 144)
>         (sign_extend:DI (subreg:SI (reg:DI 142) 0))) "j.c":6:6 116 {extendsidi2}
>      (nil))
> (insn 30 12 31 2 (set (reg:DI 147)
>         (const_int 6 [0x6])) "j.c":8:12 179 {*movdi_64bit}
>      (nil))
> (insn 31 30 33 2 (set (reg:DI 146)
>         (plus:DI (reg/v:DI 138 [ x ])
>             (reg/v:DI 139 [ y ]))) "j.c":8:12 5 {adddi3}
>      (nil))
> (insn 33 31 34 2 (set (reg:DI 149)
>         (if_then_else:DI (ne:DI (reg:DI 144)
>                 (const_int 0 [0]))
>             (const_int 0 [0])
>             (reg:DI 146))) "j.c":8:12 11368 {*czero.nez.didi}
>      (nil))
> (insn 34 33 35 2 (set (reg:DI 148)
>         (if_then_else:DI (eq:DI (reg:DI 144)
>                 (const_int 0 [0]))
>             (const_int 0 [0])
>             (reg:DI 147))) "j.c":8:12 11367 {*czero.eqz.didi}
>      (nil))
> (insn 35 34 21 2 (set (reg:DI 137 [ <retval> ])
>         (ior:DI (reg:DI 148)
>             (reg:DI 149))) "j.c":8:12 99 {iordi3}
>      (nil))
Which looks basically OK.  The sign extended subreg is a bit worrisome though.
And sure enough when we get into combine:

> Failed to match this instruction:
> (parallel [
>         (set (reg:DI 149)
>             (if_then_else:DI (eq:DI (subreg:SI (reg:DI 142) 0)
>                     (const_int 0 [0]))
>                 (reg:DI 146)
>                 (const_int 0 [0])))
>         (set (reg:DI 144)
>             (sign_extend:DI (subreg:SI (reg:DI 142) 0)))
>     ])
> Successfully matched this instruction:
> (set (reg:DI 144)
>     (sign_extend:DI (subreg:SI (reg:DI 142) 0)))
> Successfully matched this instruction:
> (set (reg:DI 149)
>     (if_then_else:DI (eq:DI (subreg:SI (reg:DI 142) 0)
>             (const_int 0 [0]))
>         (reg:DI 146)
>         (const_int 0 [0])))
> allowing combination of insns 12 and 33
Since we need the side effect we first try the PARALLEL with two sets.
That, as expected, fails.  Generic combine code then tries to pull apart
the two sets as distinct insns resulting in this conditional move:

> (insn 33 31 34 2 (set (reg:DI 149)
>         (if_then_else:DI (eq:DI (subreg:SI (reg:DI 142) 0)
>                 (const_int 0 [0]))
>             (reg:DI 146)
>             (const_int 0 [0]))) "j.c":8:12 11347 {*czero.nez.disi}
>      (expr_list:REG_DEAD (reg:DI 146)
>         (nil)))
Bzzt.  We can't actually implement this RTL in the hardware.  Basically
it's asking to do 32bit comparison on rv64, ignoring the upper 32 bits
of the input register.  That's not actually how zicond works.

The operands to the comparison need to be in DImode for rv64 and SImode
for rv32.  That's the X iterator.  Note the mode of the comparison
operands may be different than the mode of the destination.  ie, we might
have a 64bit comparison and produce a 32bit sign extended result much
like the setcc insns support.

This patch changes the 6 zicond patterns to use the X iterator on the
comparison inputs and fixes the testsuite failure.

gcc/

* config/riscv/zicond.md: Use the X iterator instead of ANYI
on the comparison input operands.

9 months ago[PATCH 3/5] [RISC-V] RISC-V Conditional Move costing [was:Generate Zicond instruction...
Xiao Zeng [Mon, 31 Jul 2023 18:26:51 +0000 (12:26 -0600)] 
[PATCH 3/5] [RISC-V] RISC-V Conditional Move costing [was:Generate Zicond instruction for select pattern with condition eq or neq to 0]

This provides some basic costing to conditional moves.  The underlying
primitive of an IF-THEN-ELSE which turns into czero is a single insn
(COSTS_N_INSNS (1)).

But these insns were still consistently showing up with the wrong cost (8
instead of 4).  This was chased down to computing the cost of the destination
and the cost of the source independently, then summing them.  That seems
horribly wrong for register destinations.  So this patch special cases
an INSN that is just a SET of a register destination so that the cost
comes from the SET_SRC.

Long term the whole costing model needs a review.

gcc/
* config/riscv/riscv.cc (riscv_rtx_costs, case IF_THEN_ELSE): Add
Zicond costing.
(case SET): For INSNs that just set a REG, take the cost from the
SET_SRC.

Co-authored-by: Jeff Law <jlaw@ventanamicro.com>
9 months agoi386: refactor macros.
Hu, Lin1 [Tue, 27 Jun 2023 06:06:20 +0000 (14:06 +0800)] 
i386: refactor macros.

gcc/ChangeLog:

* common/config/i386/i386-common.cc (OPTION_MASK_ISA2_AMX_INT8_SET):
Change OPTION_MASK_ISA2_AMX_TILE to OPTION_MASK_ISA2_AMX_TILE_SET.
(OPTION_MASK_ISA2_AMX_BF16_SET): Ditto
(OPTION_MASK_ISA2_AMX_FP16_SET): Ditto
(OPTION_MASK_ISA2_AMX_COMPLEX_SET): Ditto
(OPTION_MASK_ISA_ABM_SET):
Change OPTION_MASK_ISA_POPCNT to OPTION_MASK_ISA_POPCNT_SET.

Signed-off-by: Hu, Lin1 <lin1.hu@intel.com>
10 months agoAdd myself for write after approval
Hu, Lin1 [Wed, 2 Aug 2023 01:58:29 +0000 (09:58 +0800)] 
Add myself for write after approval

ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.

10 months agoDaily bump.
GCC Administrator [Wed, 2 Aug 2023 00:17:45 +0000 (00:17 +0000)] 
Daily bump.

10 months agoPR modula2/110161 Comparing a typed procedure variable to 0 gives ICE or assertion
Gaius Mulley [Tue, 1 Aug 2023 23:34:29 +0000 (00:34 +0100)] 
PR modula2/110161 Comparing a typed procedure variable to 0 gives ICE or assertion

This patch allows a proc type to be compared against an address.

gcc/m2/ChangeLog:

PR modula2/110161
* gm2-compiler/M2Check.mod (checkProcTypeEquivalence): New
procedure function.
(checkTypeKindEquivalence): Call checkProcTypeEquivalence
if either left or right is a proc type.
* gm2-compiler/M2Quads.mod (BuildRelOp): Create
combinedTok prior to creating the range check quadruple.
Use combinedTok when creating the range check quadruple.

gcc/testsuite/ChangeLog:

PR modula2/110161
* gm2/pim/fail/badxproc.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
10 months agoIBM Z: Handle unaligned symbols
Andreas Krebbel [Tue, 1 Aug 2023 19:01:19 +0000 (21:01 +0200)] 
IBM Z: Handle unaligned symbols

The IBM Z ELF ABI mandates every symbol to reside on a 2 byte boundary
in order to be able to use the larl instruction. However, in some
situations it is difficult to enforce this, e.g. for common linker
scripts as used in the Linux kernel. This patch introduces the
-munaligned-symbols option. When that option is used, external symbols
without an explicit alignment are considered unaligned and its address
will be pushed into GOT or the literal pool.

If the symbol in the final linker step turns out end up on a 2 byte
boundary the linker is able to take this back and replace the indirect
reference with larl again. This should minimize the effect to symbols
which are actually unaligned in the end.

gcc/ChangeLog:

* config/s390/s390.cc (s390_encode_section_info): Assume external
symbols without explicit alignment to be unaligned if
-munaligned-symbols has been specified.
* config/s390/s390.opt (-munaligned-symbols): New option.

gcc/testsuite/ChangeLog:

* gcc.target/s390/aligned-1.c: New test.
* gcc.target/s390/unaligned-1.c: New test.

10 months ago[PATCH] Add POLY_INT_CST support to fold_ctor_reference in gimple-fold.cc
Richard Ball [Tue, 1 Aug 2023 15:57:02 +0000 (16:57 +0100)] 
[PATCH] Add POLY_INT_CST support to fold_ctor_reference in gimple-fold.cc

Add POLY_INT_CST support to code within
fold_ctor_reference. This code previously
only supported INTEGER_CST which caused a
bug when using VEC_PERM_EXPR with SVE vectors.

gcc/ChangeLog:

* gimple-fold.cc (fold_ctor_reference):
Add support for poly_int.

10 months agoMAINTAINERS: Add myself to write after approval
Richard Ball [Tue, 1 Aug 2023 13:54:38 +0000 (14:54 +0100)] 
MAINTAINERS: Add myself to write after approval

Sponsored by Richard Sandiford <Richard.Sandiford@arm.com>

ChangeLog:

* MAINTAINERS: Add myself.

10 months agotarget/110220: Set JUMP_LABEL and LABEL_NUSES of new branch insn generated by
Georg-Johann Lay [Tue, 1 Aug 2023 11:49:17 +0000 (13:49 +0200)] 
target/110220: Set JUMP_LABEL and LABEL_NUSES of new branch insn generated by

target specific RTL optimization pass .avr-casesi.

gcc/
PR target/110220
* config/avr/avr.cc (avr_optimize_casesi): Set JUMP_LABEL and
LABEL_NUSES of new conditional branch instruction.

10 months agoFix profile update after prologue peeling in vectorizer
Jan Hubicka [Tue, 1 Aug 2023 10:07:39 +0000 (12:07 +0200)] 
Fix profile update after prologue peeling in vectorizer

This patch fixes update after constant peeling in profilogue.  We now reached 0 profile
update bugs on tramp3d vectorizaiton and also on quite few testcases, so I am enabling the
testuiste checks so we do not regress again.

gcc/ChangeLog:

* tree-vect-loop-manip.cc (vect_do_peeling): Fix profile update after
constant prologue peeling.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/vect-1-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-1.c: Check profile consistency.
* gcc.dg/vect/vect-10-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-10.c: Check profile consistency.
* gcc.dg/vect/vect-100.c: Check profile consistency.
* gcc.dg/vect/vect-103.c: Check profile consistency.
* gcc.dg/vect/vect-104.c: Check profile consistency.
* gcc.dg/vect/vect-105-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-105.c: Check profile consistency.
* gcc.dg/vect/vect-106.c: Check profile consistency.
* gcc.dg/vect/vect-107.c: Check profile consistency.
* gcc.dg/vect/vect-108.c: Check profile consistency.
* gcc.dg/vect/vect-109.c: Check profile consistency.
* gcc.dg/vect/vect-11.c: Check profile consistency.
* gcc.dg/vect/vect-110.c: Check profile consistency.
* gcc.dg/vect/vect-112-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-112.c: Check profile consistency.
* gcc.dg/vect/vect-113.c: Check profile consistency.
* gcc.dg/vect/vect-114.c: Check profile consistency.
* gcc.dg/vect/vect-115.c: Check profile consistency.
* gcc.dg/vect/vect-116.c: Check profile consistency.
* gcc.dg/vect/vect-117.c: Check profile consistency.
* gcc.dg/vect/vect-118.c: Check profile consistency.
* gcc.dg/vect/vect-119.c: Check profile consistency.
* gcc.dg/vect/vect-11a.c: Check profile consistency.
* gcc.dg/vect/vect-12.c: Check profile consistency.
* gcc.dg/vect/vect-120.c: Check profile consistency.
* gcc.dg/vect/vect-121.c: Check profile consistency.
* gcc.dg/vect/vect-122.c: Check profile consistency.
* gcc.dg/vect/vect-123.c: Check profile consistency.
* gcc.dg/vect/vect-124.c: Check profile consistency.
* gcc.dg/vect/vect-126.c: Check profile consistency.
* gcc.dg/vect/vect-13.c: Check profile consistency.
* gcc.dg/vect/vect-14.c: Check profile consistency.
* gcc.dg/vect/vect-15-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-15.c: Check profile consistency.
* gcc.dg/vect/vect-17.c: Check profile consistency.
* gcc.dg/vect/vect-18.c: Check profile consistency.
* gcc.dg/vect/vect-19.c: Check profile consistency.
* gcc.dg/vect/vect-2-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-2.c: Check profile consistency.
* gcc.dg/vect/vect-20.c: Check profile consistency.
* gcc.dg/vect/vect-21.c: Check profile consistency.
* gcc.dg/vect/vect-22.c: Check profile consistency.
* gcc.dg/vect/vect-23.c: Check profile consistency.
* gcc.dg/vect/vect-24.c: Check profile consistency.
* gcc.dg/vect/vect-25.c: Check profile consistency.
* gcc.dg/vect/vect-26.c: Check profile consistency.
* gcc.dg/vect/vect-27.c: Check profile consistency.
* gcc.dg/vect/vect-28.c: Check profile consistency.
* gcc.dg/vect/vect-29.c: Check profile consistency.
* gcc.dg/vect/vect-3.c: Check profile consistency.
* gcc.dg/vect/vect-30.c: Check profile consistency.
* gcc.dg/vect/vect-31-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-31.c: Check profile consistency.
* gcc.dg/vect/vect-32-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-32-chars.c: Check profile consistency.
* gcc.dg/vect/vect-32.c: Check profile consistency.
* gcc.dg/vect/vect-33-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-33.c: Check profile consistency.
* gcc.dg/vect/vect-34-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-34.c: Check profile consistency.
* gcc.dg/vect/vect-35-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-35.c: Check profile consistency.
* gcc.dg/vect/vect-36-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-36.c: Check profile consistency.
* gcc.dg/vect/vect-38.c: Check profile consistency.
* gcc.dg/vect/vect-4.c: Check profile consistency.
* gcc.dg/vect/vect-40.c: Check profile consistency.
* gcc.dg/vect/vect-42.c: Check profile consistency.
* gcc.dg/vect/vect-44.c: Check profile consistency.
* gcc.dg/vect/vect-46.c: Check profile consistency.
* gcc.dg/vect/vect-48.c: Check profile consistency.
* gcc.dg/vect/vect-5.c: Check profile consistency.
* gcc.dg/vect/vect-50.c: Check profile consistency.
* gcc.dg/vect/vect-52.c: Check profile consistency.
* gcc.dg/vect/vect-54.c: Check profile consistency.
* gcc.dg/vect/vect-56.c: Check profile consistency.
* gcc.dg/vect/vect-58.c: Check profile consistency.
* gcc.dg/vect/vect-6-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-6.c: Check profile consistency.
* gcc.dg/vect/vect-60.c: Check profile consistency.
* gcc.dg/vect/vect-62.c: Check profile consistency.
* gcc.dg/vect/vect-63.c: Check profile consistency.
* gcc.dg/vect/vect-64.c: Check profile consistency.
* gcc.dg/vect/vect-65.c: Check profile consistency.
* gcc.dg/vect/vect-66.c: Check profile consistency.
* gcc.dg/vect/vect-67.c: Check profile consistency.
* gcc.dg/vect/vect-68.c: Check profile consistency.
* gcc.dg/vect/vect-7.c: Check profile consistency.
* gcc.dg/vect/vect-70.c: Check profile consistency.
* gcc.dg/vect/vect-71.c: Check profile consistency.
* gcc.dg/vect/vect-72.c: Check profile consistency.
* gcc.dg/vect/vect-73-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-73.c: Check profile consistency.
* gcc.dg/vect/vect-74-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-74.c: Check profile consistency.
* gcc.dg/vect/vect-75-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-75.c: Check profile consistency.
* gcc.dg/vect/vect-76-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-76.c: Check profile consistency.
* gcc.dg/vect/vect-77-alignchecks.c: Check profile consistency.
* gcc.dg/vect/vect-77-global.c: Check profile consistency.
* gcc.dg/vect/vect-77.c: Check profile consistency.
* gcc.dg/vect/vect-78-alignchecks.c: Check profile consistency.
* gcc.dg/vect/vect-78-global.c: Check profile consistency.
* gcc.dg/vect/vect-78.c: Check profile consistency.
* gcc.dg/vect/vect-8.c: Check profile consistency.
* gcc.dg/vect/vect-80-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-80.c: Check profile consistency.
* gcc.dg/vect/vect-82.c: Check profile consistency.
* gcc.dg/vect/vect-82_64.c: Check profile consistency.
* gcc.dg/vect/vect-83.c: Check profile consistency.
* gcc.dg/vect/vect-83_64.c: Check profile consistency.
* gcc.dg/vect/vect-85-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-85.c: Check profile consistency.
* gcc.dg/vect/vect-86.c: Check profile consistency.
* gcc.dg/vect/vect-87.c: Check profile consistency.
* gcc.dg/vect/vect-88.c: Check profile consistency.
* gcc.dg/vect/vect-89-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-89.c: Check profile consistency.
* gcc.dg/vect/vect-9.c: Check profile consistency.
* gcc.dg/vect/vect-91.c: Check profile consistency.
* gcc.dg/vect/vect-92.c: Check profile consistency.
* gcc.dg/vect/vect-93.c: Check profile consistency.
* gcc.dg/vect/vect-95.c: Check profile consistency.
* gcc.dg/vect/vect-96.c: Check profile consistency.
* gcc.dg/vect/vect-97-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-97.c: Check profile consistency.
* gcc.dg/vect/vect-98-big-array.c: Check profile consistency.
* gcc.dg/vect/vect-98.c: Check profile consistency.
* gcc.dg/vect/vect-99.c: Check profile consistency.

10 months agodoc: Fix spelling in arm_v8_1m_main_cde_mve_fp
Christophe Lyon [Tue, 1 Aug 2023 08:40:12 +0000 (08:40 +0000)] 
doc: Fix spelling in arm_v8_1m_main_cde_mve_fp

Fix spelling mistakes introduced by my previous patch in this area.

2023-08-01  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/
* doc/sourcebuild.texi (arm_v8_1m_main_cde_mve_fp): Fix spelling.

10 months agoada: Fix printing of numbers in JSON output for data representation
Yannick Moy [Wed, 19 Jul 2023 15:57:30 +0000 (17:57 +0200)] 
ada: Fix printing of numbers in JSON output for data representation

When calling GNAT with -gnatRj to generate JSON output for the
data representation of types and objects, it could happen that
numbers are printed in the Ada syntax for hexadecimal numbers, which
leads to an invalid JSON file being generated. Now fixed both for
the JSON output and the Ada-like output.

gcc/ada/

* repinfo.adb (Compute_Max_Length): Set parameter to print number
in decimal notation.
(List_Component_Layout): Same.

10 months agoada: Disable inlining of subprograms with Skip(_Flow_And)_Proof in GNATprove
Yannick Moy [Fri, 21 Jul 2023 04:43:10 +0000 (06:43 +0200)] 
ada: Disable inlining of subprograms with Skip(_Flow_And)_Proof in GNATprove

Subprograms with these Skip(_Flow_And)_Proof annotations should not be
inlined in GNATprove, as we want to skip part of the analysis for their
body.

gcc/ada/

* inline.adb (Can_Be_Inlined_In_GNATprove_Mode): Check for
Skip_Proof and Skip_Flow_And_Proof annotations for deciding
whether a subprogram can be inlined.

10 months agoada: Bugbox compiling Constrained_Protected_Object'Image
Steve Baird [Thu, 8 Jun 2023 22:08:11 +0000 (15:08 -0700)] 
ada: Bugbox compiling Constrained_Protected_Object'Image

In some cases, a bugbox is generated when compiling an example
that references X'Image, where X is a constrained object of a
discriminated protected type.

gcc/ada/

* sem_ch3.adb (Constrain_Corresponding_Record): When copying
information from the unconstrained record type to a newly
constructed constrained record subtype, the
Direct_Primitive_Operations attribute must be copied.

10 months agoada: Incorrect optimization for unconstrained limited record component type
Steve Baird [Thu, 8 Jun 2023 21:59:32 +0000 (14:59 -0700)] 
ada: Incorrect optimization for unconstrained limited record component type

If the discriminants of an immutably limited record type have defaults, then
it is safe to assume that a discriminant of an object of this type will never
change once it is initialized. In some cases, this means that the default
discriminant values can be treated like a constraint for purposes of
determining the amount of storage needed for an unconstrained object.
However, it is not safe to perform this optimization when determining
the size needed for an unconstrained component of an enclosing type. This
optimization was sometimes being incorrectly performed in this case. This could
save storage in some cases, but in other cases a constraint check could
incorrectly fail when initializing a component of an aggregate if the
discriminant values of the component differ from the default values.

gcc/ada/

* sem_ch3.adb (Analyze_Component_Declaration): Remove
Build_Default_Subtype_OK call and code that could only executed in
the case where the removed call would have returned True. Other
calls to Build_Default_Subtype_Ok are unaffected by this change.

10 months agoada: Default Put_Image for composite derived types is missing information
Pascal Obry [Thu, 13 Jul 2023 16:03:23 +0000 (16:03 +0000)] 
ada: Default Put_Image for composite derived types is missing information

The output generated by a call to Some_Derived_Composite_Type'Put_Image
(in Ada2022 code) is incomplete in some cases, notably for a type derived
from a container type (i.e., from the Set/Map/List/Vector type declared in
an instance of one of Ada's predefined container generics) with no
user-specified Put_Image procedure.

gcc/ada/

* aspects.ads (Find_Aspect): Add Boolean parameter Or_Rep_Item
(defaulted to False).
* aspects.adb (Find_Aspect): If new Boolean parameter Or_Rep_Item
is True, then instead of returning an empty result if no
appropriate N_Aspect_Specification node is found, return an
appropriate N_Attribute_Definition_Clause if one is found.
* exp_put_image.ads: Change name of Enable_Put_Image function to
Put_Image_Enabled.
* exp_put_image.adb (Build_Record_Put_Image_Procedure): Detect the
case where a call to the Put_Image procedure of a derived type can
be transformed into a call to the parent type's Put_Image
procedure (with a type conversion to the parent type as the actual
parameter).
(Put_Image_Enabled): Change name of function (previously
Enable_Put_Image). Return True in more cases. In particular,
return True for a type with an explicitly specified Put_Image
aspect even if the type is declared in a predefined unit (or in an
instance of a predefined generic unit).
* exp_attr.adb: Changes due to Put_Image_Enabled function name
change.

10 months agoada: Fix generation of JSON output for data representation
Yannick Moy [Tue, 18 Jul 2023 14:52:26 +0000 (16:52 +0200)] 
ada: Fix generation of JSON output for data representation

Using -gnatRj to generate data representation in JSON format could
lead to an ill-formed output or an assertion failure. Now fixed.

gcc/ada/

* repinfo.adb (List_Common_Type_Info): Fix output when alignment
is not statically known, and fix assertion when expansion is not
enabled.

10 months agoada: check Atree.Get/Set_Field_Value
Bob Duff [Wed, 10 May 2023 19:21:15 +0000 (15:21 -0400)] 
ada: check Atree.Get/Set_Field_Value

Get_Field_Value and Set_Field_Value now check that the Nkind or Ekind is
correct. However, the checks are partially disabled, because they
sometimes fail.

gcc/ada/

* atree.adb (Field_Present): New function to detect whether or not
a given field is present in a given node, based on either the node
kind or the entity kind as appropriate.
(Get_Field_Value): Check that the field begin fetched exists.
However, disable the check in the case of Scope_Depth_Value,
because we have failures in that case. Those failures need to be
fixed, and then the check can be enabled for all fields.
(Set_Field_Value): Check that the field begin set exists.

10 months agoada: Emit SCOs for nested decisions in quantified expressions
Léo Creuse [Tue, 18 Jul 2023 09:08:23 +0000 (11:08 +0200)] 
ada: Emit SCOs for nested decisions in quantified expressions

The tree traversal for decision SCO emission did not recurse in the
iterator specification or loop parameter specification of quantified
expressions, resulting in missing coverage obligations for nested
decisions. This change fixes this by traversing all the attributes
of quantified expressions nodes.

gcc/ada/

* par_sco.adb (Process_Decisions): Traverse all attributes of
quantified expressions nodes.

10 months 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.

10 months 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.

10 months 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.

10 months 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.

10 months 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>
10 months agoDaily bump.
GCC Administrator [Tue, 1 Aug 2023 00:18:39 +0000 (00:18 +0000)] 
Daily bump.

10 months 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.

10 months 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.

10 months 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>
10 months 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.

10 months 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.

10 months 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.

10 months 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.

10 months 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.

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

* sv.po: Update.

10 months 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>
10 months 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.

10 months 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.

10 months 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.

10 months 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.

10 months 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.

10 months 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@.

10 months 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.

10 months 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.

10 months 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.

10 months 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.

10 months 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.

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