]> gcc.gnu.org Git - gcc.git/log
gcc.git
16 months agotarget/104327: Allow more inlining between different optimization levels.
Georg-Johann Lay [Tue, 23 May 2023 12:54:12 +0000 (14:54 +0200)]
target/104327: Allow more inlining between different optimization levels.

avr-common.cc introduces the following options that are set depending
on optimization level: -mgas-isr-prologues, -mmain-is-OS-task and
-fsplit-wide-types-early.  The inliner thinks that different options
disallow cross-optimization inlining, so provide can_inline_p.

gcc/
PR target/104327
* config/avr/avr.cc (avr_can_inline_p): New static function.
(TARGET_CAN_INLINE_P): Define to that function.

16 months agotarget/82931: Make a pattern more generic to match more bit-transfers.
Georg-Johann Lay [Thu, 25 May 2023 17:02:34 +0000 (19:02 +0200)]
target/82931: Make a pattern more generic to match more bit-transfers.

There is already a pattern in avr.md that matches single-bit transfers
from one register to another one, but it only handled bit 0 of 8-bit
registers.  This change makes that pattern more generic so it matches
more of similar single-bit transfers.

gcc/
PR target/82931
* config/avr/avr.md (*movbitqi.0): Rename to *movbit<mode>.0-6.
Handle any bit position and use mode QISI.
* config/avr/avr.cc (avr_rtx_costs_1) [IOR]: Return a cost
of 2 insns for bit-transfer of respective style.

gcc/testsuite/
PR target/82931
* gcc.target/avr/pr82931.c: New test.

16 months agoarm: merge MVE_5 and MVE_6 iterators
Christophe Lyon [Thu, 25 May 2023 12:19:52 +0000 (12:19 +0000)]
arm: merge MVE_5 and MVE_6 iterators

MVE_5 and MVE_6 iterators are the same: this patch replaces MVE_6 with
MVE_5 everywhere in mve.md and removes MVE_6 from iterators.md.

2023-05-25  Christophe Lyon <christophe.lyon@linaro.org>

gcc/
* config/arm/iterators.md (MVE_6): Remove.
* config/arm/mve.md: Replace MVE_6 with MVE_5.

16 months agoVECT: Add decrement IV iteration loop control by variable amount support
Ju-Zhe Zhong [Thu, 25 May 2023 14:42:35 +0000 (22:42 +0800)]
VECT: Add decrement IV iteration loop control by variable amount support

This patch is supporting decrement IV by following the flow designed by
Richard:

(1) In vect_set_loop_condition_partial_vectors, for the first iteration of:
    call vect_set_loop_controls_directly.

(2) vect_set_loop_controls_directly calculates "step" as in your patch.
If rgc has 1 control, this step is the SSA name created for that
control.  Otherwise the step is a fresh SSA name, as in your patch.

(3) vect_set_loop_controls_directly stores this step somewhere for later
use, probably in LOOP_VINFO.  Let's use "S" to refer to this stored
step.

(4) After the vect_set_loop_controls_directly call above, and outside
the "if" statement that now contains vect_set_loop_controls_directly,
check whether rgc->controls.length () > 1.  If so, use
vect_adjust_loop_lens_control to set the controls based on S.

Then the only caller of vect_adjust_loop_lens_control is
vect_set_loop_condition_partial_vectors.  And the starting
step for vect_adjust_loop_lens_control is always S.

This patch has well tested for single-rgroup and multiple-rgroup (SLP)
and passed all testcase in RISC-V port.

Signed-off-by: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
Co-Authored-By: Richard Sandiford <richard.sandiford@arm.com>
gcc/ChangeLog:

* tree-vect-loop-manip.cc (vect_adjust_loop_lens_control): New
function.
(vect_set_loop_controls_directly): Add decrement IV support.
(vect_set_loop_condition_partial_vectors): Ditto.
* tree-vect-loop.cc (_loop_vec_info::_loop_vec_info): New
variable.
* tree-vectorizer.h (LOOP_VINFO_USING_DECREMENTING_IV_P): New
macro.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-3.c: New test.
* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-4.c: New test.
* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-3.c: New test.
* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-4.c: New test.

16 months agoaarch64: PR target/99195 Annotate complex FP patterns for vec-concat-zero
Kyrylo Tkachov [Thu, 25 May 2023 14:00:16 +0000 (15:00 +0100)]
aarch64: PR target/99195 Annotate complex FP patterns for vec-concat-zero

This patch annotates the complex add and mla patterns for vec-concat-zero.
Testing showed an interesting bug in our MD patterns where they were defined to match:
(plus:VHSDF (match_operand:VHSDF 1 "register_operand" "0")
    (unspec:VHSDF [(match_operand:VHSDF 2 "register_operand" "w")
   (match_operand:VHSDF 3 "register_operand" "w")
   (match_operand:SI 4 "const_int_operand" "n")]
   FCMLA))

but the canonicalisation rules for PLUS require the more "complex" operand to be first so
during combine when the new substituted patterns were attempted to be formed combine/recog would
try to match:
(plus:V2SF (unspec:V2SF [
                        (reg:V2SF 100)
                        (reg:V2SF 101)
                        (const_int 0 [0])
                    ] UNSPEC_FCMLA270)
                (reg:V2SF 99))
instead. This patch fixes the operands of the PLUS RTX in these patterns.
Similar patterns for the dot-product instructions already used the right order.

Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf.

gcc/ChangeLog:

PR target/99195
* config/aarch64/aarch64-simd.md (aarch64_fcadd<rot><mode>): Rename to...
(aarch64_fcadd<rot><mode><vczle><vczbe>): ... This.
Fix canonicalization of PLUS operands.
(aarch64_fcmla<rot><mode>): Rename to...
(aarch64_fcmla<rot><mode><vczle><vczbe>): ... This.
Fix canonicalization of PLUS operands.
(aarch64_fcmla_lane<rot><mode>): Rename to...
(aarch64_fcmla_lane<rot><mode><vczle><vczbe>): ... This.
Fix canonicalization of PLUS operands.
(aarch64_fcmla_laneq<rot>v4hf): Rename to...
(aarch64_fcmla_laneq<rot>v4hf<vczle><vczbe>): ... This.
Fix canonicalization of PLUS operands.
(aarch64_fcmlaq_lane<rot><mode>): Fix canonicalization of PLUS operands.

gcc/testsuite/ChangeLog:

PR target/99195
* gcc.target/aarch64/simd/pr99195_9.c: New test.

16 months agoarm: Implement ACLE Data Intrinsics
Chris Sidebottom [Thu, 25 May 2023 13:57:34 +0000 (14:57 +0100)]
arm: Implement ACLE Data Intrinsics

This patch implements a number of scalar data processing intrinsics from ACLE
that were requested by some users. Some of these have fast single-instruction
sequences for Armv6 and later, but even for earlier versions they can still emit
an inline sequence or a call to libgcc (and ACLE recommends them being unconditionally
available).

Chris Sidebottom wrote most of the patch, I just cleaned it up, wired up some builtins
and adjusted the tests.

Bootstrapped and tested on arm-none-linux-gnueabihf.

Co-authored-by: Chris Sidebottom <chris.sidebottom@arm.com>
gcc/ChangeLog:

* config/arm/arm.md (rbitsi2): Rename to...
(arm_rbit): ... This.
(ctzsi2): Adjust for the above.
(arm_rev16si2): Convert to define_expand.
(arm_rev16si2_alt1): New pattern.
(arm_rev16si2_alt): Rename to...
(*arm_rev16si2_alt2): ... This.
* config/arm/arm_acle.h (__ror, __rorl, __rorll, __clz, __clzl, __clzll,
__cls, __clsl, __clsll, __revsh, __rev, __revl, __revll, __rev16,
__rev16l, __rev16ll, __rbit, __rbitl, __rbitll): Define intrinsics.
* config/arm/arm_acle_builtins.def (rbit, rev16si2): Define builtins.

gcc/testsuite/ChangeLog:

* gcc.target/arm/acle/data-intrinsics-armv6.c: New test.
* gcc.target/arm/acle/data-intrinsics-assembly.c: New test.
* gcc.target/arm/acle/data-intrinsics-rbit.c: New test.
* gcc.target/arm/acle/data-intrinsics.c: New test.

16 months agoarm: Fix ICE due to infinite splitting [PR109800]
Alex Coplan [Thu, 25 May 2023 12:34:46 +0000 (13:34 +0100)]
arm: Fix ICE due to infinite splitting [PR109800]

In r11-966-g9a182ef9ee011935d827ab5c6c9a7cd8e22257d8 we introduce a
simplification to emit_move_insn that attempts to simplify moves of the form:

(set (subreg:M1 (reg:M2 ...)) (constant C))

where M1 and M2 are of equal mode size. That is problematic for the splitter
vfp.md:no_literal_pool_df_immediate in the arm backend, which tries to pun an
lvalue DFmode pseudo into DImode and assign a constant to it with
emit_move_insn, as the new transformation simply undoes this, and we end up
splitting indefinitely.

This patch changes things around in the arm backend so that we use a
DImode temporary (instead of DFmode) and first load the DImode constant
into the pseudo, and then pun the pseudo into DFmode as an rvalue in a
reg -> reg move. I believe this should be semantically equivalent but
avoids the pathalogical behaviour seen in the PR.

gcc/ChangeLog:

PR target/109800
* config/arm/arm.md (movdf): Generate temporary pseudo in DImode
instead of DFmode.
* config/arm/vfp.md (no_literal_pool_df_immediate): Rather than punning an
lvalue DFmode pseudo into DImode, use a DImode pseudo and pun it into
DFmode as an rvalue.

gcc/testsuite/ChangeLog:

PR target/109800
* gcc.target/arm/pure-code/pr109800.c: New test.

16 months agotarget/109955 - handle pattern generated COND_EXPR without vcond
Richard Biener [Thu, 25 May 2023 10:55:11 +0000 (12:55 +0200)]
target/109955 - handle pattern generated COND_EXPR without vcond

The following properly handles pattern matching generated COND_EXPRs
which can still have embedded compares in vectorizable_condition
which will always code generate the masked vector variant.  We
were requiring vcond with embedded comparisons instead of also
allowing (as code generated) split compare and VEC_COND_EXPR.

This fixes some of the fallout when removing vcond{,u,eq} expanders
from the x86 backend.

PR target/109955
* tree-vect-stmts.cc (vectorizable_condition): For
embedded comparisons also handle the case when the target
only provides vec_cmp and vcond_mask.

16 months agoarc: Make TLS Local Dynamic work like Global Dynamic model
Claudiu Zissulescu [Thu, 25 May 2023 09:53:14 +0000 (12:53 +0300)]
arc: Make TLS Local Dynamic work like Global Dynamic model

Current ARC's TLS Local Dynamic model is using two anchors to access
data, namely `.tdata` and `.tbss`. This implementation is unnecessary
complicated. However, the TLS Local Dynamic model has better results
using Global Dynamic model and anchors.

gcc/ChangeLog;

* config/arc/arc.cc (arc_call_tls_get_addr): Simplify access using
TLS Local Dynamic.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
16 months ago[aarch64] Ignore cost of scalar moves for seq in vector initialization.
Prathamesh Kulkarni [Thu, 25 May 2023 09:53:57 +0000 (15:23 +0530)]
[aarch64] Ignore cost of scalar moves for seq in vector initialization.

gcc/ChangeLog:
* config/aarch64/aarch64.cc (scalar_move_insn_p): New function.
(seq_cost_ignoring_scalar_moves): Likewise.
(aarch64_expand_vector_init): Call seq_cost_ignoring_scalar_moves.

16 months agoaarch64: Implement vector FP absolute compare intrinsics with builtins
Kyrylo Tkachov [Thu, 25 May 2023 08:48:33 +0000 (09:48 +0100)]
aarch64: Implement vector FP absolute compare intrinsics with builtins

While optimising some vector math library code with intrinsics we stumbled upon the issue in the testcase.
The compiler should be generating a FACGT instruction but instead we generate:
foo(__Float32x4_t, __Float32x4_t, __Float32x4_t):
        fabs    v0.4s, v0.4s
        adrp    x0, .LC0
        ldr     q31, [x0, #:lo12:.LC0]
        fcmgt   v0.4s, v0.4s, v31.4s
        ret

This is because the vcagtq_f32 intrinsic is open-coded in arm_neon.h as
return vabsq_f32 (__a) > vabsq_f32 (__b)
thus relying on the optimisers to merge it back together. But since one of the arms of the comparison
is a vector constant the combine pass optimises the abs into it and tries matching:
(set (reg:V4SI 101)
    (neg:V4SI (gt:V4SI (reg:V4SF 100)
            (const_vector:V4SF [
                    (const_double:SF 1.0e+2 [0x0.c8p+7]) repeated x4
                ]))))
and
(set (reg:V4SI 101)
    (neg:V4SI (gt:V4SI (abs:V4SF (reg:V4SF 104))
            (reg:V4SF 103))))

instead of what we want:
(insn 13 9 14 2 (set (reg/i:V4SI 32 v0)
        (neg:V4SI (gt:V4SI (abs:V4SF (reg:V4SF 98))
                (abs:V4SF (reg:V4SF 96)))))

I don't really see a good way around that with our current implementation of these intrinsics.
Therefore this patch reimplements these intrinsics with aarch64 builtins that generate the RTL for these
instructions directly. Apparently we already had them defined in aarch64-simd-builtins.def and have been
using them for the fp16 case already.
I realise that this approach is against the general principle of expressing intrinsics in the higher-level constructs,
so I'm willing to listen to counter-arguments.
That said, the FACGT/FACGE instructions are as fast as the non-ABS comparison instructions on all microarchitectures that I know of
so it should always be a win to have them in the merged form rather than split the fabs step separately or try to hoist it.
And the testcase does come from real library code that we're trying to optimise.
With this patch for the testcase we generate:
foo:
        adrp    x0, .LC0
        ldr     q31, [x0, #:lo12:.LC0]
        facgt   v0.4s, v0.4s, v31.4s
        ret

gcc/ChangeLog:

* config/aarch64/arm_neon.h (vcage_f64): Reimplement with builtins.
(vcage_f32): Likewise.
(vcages_f32): Likewise.
(vcageq_f32): Likewise.
(vcaged_f64): Likewise.
(vcageq_f64): Likewise.
(vcagts_f32): Likewise.
(vcagt_f32): Likewise.
(vcagt_f64): Likewise.
(vcagtq_f32): Likewise.
(vcagtd_f64): Likewise.
(vcagtq_f64): Likewise.
(vcale_f32): Likewise.
(vcale_f64): Likewise.
(vcaled_f64): Likewise.
(vcales_f32): Likewise.
(vcaleq_f32): Likewise.
(vcaleq_f64): Likewise.
(vcalt_f32): Likewise.
(vcalt_f64): Likewise.
(vcaltd_f64): Likewise.
(vcaltq_f32): Likewise.
(vcaltq_f64): Likewise.
(vcalts_f32): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/simd/facgt_constpool_1.c: New test.

16 months agoi386: Fix incorrect intrinsic signature for AVX512 s{lli|rai|rli}
Hu, Lin1 [Tue, 23 May 2023 02:08:29 +0000 (10:08 +0800)]
i386: Fix incorrect intrinsic signature for AVX512 s{lli|rai|rli}

This patch aims to fix incorrect intrinsic signature for
_mm{512|256|}_s{lli|rai|rli}_epi*.

gcc/ChangeLog:

PR target/109173
PR target/109174
* config/i386/avx512bwintrin.h (_mm512_srli_epi16): Change type from
int to const int or const int to const unsigned int.
(_mm512_mask_srli_epi16): Ditto.
(_mm512_slli_epi16): Ditto.
(_mm512_mask_slli_epi16): Ditto.
(_mm512_maskz_slli_epi16): Ditto.
(_mm512_srai_epi16): Ditto.
(_mm512_mask_srai_epi16): Ditto.
(_mm512_maskz_srai_epi16): Ditto.
* config/i386/avx512fintrin.h (_mm512_slli_epi64): Ditto.
(_mm512_mask_slli_epi64): Ditto.
(_mm512_maskz_slli_epi64): Ditto.
(_mm512_srli_epi64): Ditto.
(_mm512_mask_srli_epi64): Ditto.
(_mm512_maskz_srli_epi64): Ditto.
(_mm512_srai_epi64): Ditto.
(_mm512_mask_srai_epi64): Ditto.
(_mm512_maskz_srai_epi64): Ditto.
(_mm512_slli_epi32): Ditto.
(_mm512_mask_slli_epi32): Ditto.
(_mm512_maskz_slli_epi32): Ditto.
(_mm512_srli_epi32): Ditto.
(_mm512_mask_srli_epi32): Ditto.
(_mm512_maskz_srli_epi32): Ditto.
(_mm512_srai_epi32): Ditto.
(_mm512_mask_srai_epi32): Ditto.
(_mm512_maskz_srai_epi32): Ditto.
* config/i386/avx512vlbwintrin.h (_mm256_mask_srai_epi16): Ditto.
(_mm256_maskz_srai_epi16): Ditto.
(_mm_mask_srai_epi16): Ditto.
(_mm_maskz_srai_epi16): Ditto.
(_mm256_mask_slli_epi16): Ditto.
(_mm256_maskz_slli_epi16): Ditto.
(_mm_mask_slli_epi16): Ditto.
(_mm_maskz_slli_epi16): Ditto.
(_mm_maskz_srli_epi16): Ditto.
* config/i386/avx512vlintrin.h (_mm256_mask_srli_epi32): Ditto.
(_mm256_maskz_srli_epi32): Ditto.
(_mm_mask_srli_epi32): Ditto.
(_mm_maskz_srli_epi32): Ditto.
(_mm256_mask_srli_epi64): Ditto.
(_mm256_maskz_srli_epi64): Ditto.
(_mm_mask_srli_epi64): Ditto.
(_mm_maskz_srli_epi64): Ditto.
(_mm256_mask_srai_epi32): Ditto.
(_mm256_maskz_srai_epi32): Ditto.
(_mm_mask_srai_epi32): Ditto.
(_mm_maskz_srai_epi32): Ditto.
(_mm256_srai_epi64): Ditto.
(_mm256_mask_srai_epi64): Ditto.
(_mm256_maskz_srai_epi64): Ditto.
(_mm_srai_epi64): Ditto.
(_mm_mask_srai_epi64): Ditto.
(_mm_maskz_srai_epi64): Ditto.
(_mm_mask_slli_epi32): Ditto.
(_mm_maskz_slli_epi32): Ditto.
(_mm_mask_slli_epi64): Ditto.
(_mm_maskz_slli_epi64): Ditto.
(_mm256_mask_slli_epi32): Ditto.
(_mm256_maskz_slli_epi32): Ditto.
(_mm256_mask_slli_epi64): Ditto.
(_mm256_maskz_slli_epi64): Ditto.

gcc/testsuite/ChangeLog:

PR target/109173
PR target/109174
* gcc.target/i386/pr109173-1.c: New test.
* gcc.target/i386/pr109174-1.c: Ditto.

16 months agoada: Missing warning on null-excluding array aggregate component
Javier Miranda [Tue, 28 Feb 2023 18:20:38 +0000 (18:20 +0000)]
ada: Missing warning on null-excluding array aggregate component

The compiler does not report warnings on the initialization
of arrays of null-excluding access type components by means
of iterated component association, when the expression
initializing each component is either a conditional
expression or a case expression that may initialize
some component with a null value.

gcc/ada/

* sem_aggr.adb
(Warn_On_Null_Component_Association): New subprogram.
(Empty_Range): Adding missing support for iterated component
association node.
(Resolve_Array_Aggregate): Report warning on iterated component
association that may initialize some component of an array of
null-excluding access type components with a null value.
* exp_ch4.adb
(Expand_N_Expression_With_Actions): Add missing type check since
the subtype of the EWA node and the subtype of the expression
may differ.

16 months agoada: Expect Exceptional_Cases as a context for attribute Old
Piotr Trojanek [Mon, 13 Mar 2023 09:59:47 +0000 (10:59 +0100)]
ada: Expect Exceptional_Cases as a context for attribute Old

When determining whether attribute Old is evaluated conditionally, we
must also expect it to appear in the recently added contract
Exceptional_Cases.

gcc/ada/

* sem_util.adb (Determining_Expressions): Fix style; fix layout and
ordering of pragma names; expect pragma Exceptional_Cases.

16 months agoada: Use procedural variant of Next_Index where possible
Piotr Trojanek [Thu, 9 Mar 2023 23:14:32 +0000 (00:14 +0100)]
ada: Use procedural variant of Next_Index where possible

Code cleanup; semantics is unaffected.

gcc/ada/

* einfo-utils.adb (Write_Entity_Info): Use procedural Next_Index.
* sem_aggr.adb (Collect_Aggr_Bounds): Reuse local constant.
(Resolve_Null_Array_Aggregate): Use procedural Next_Index.

16 months agoada: Crash on empty aggregate using the Ada 2022 notation
Javier Miranda [Sun, 12 Mar 2023 12:32:34 +0000 (12:32 +0000)]
ada: Crash on empty aggregate using the Ada 2022 notation

The compiler crashes processing an empty aggregate initializing
a component of a discriminated record type using the Ada 2022
notation (that is, []).

gcc/ada/

* exp_aggr.adb (Build_Record_Aggr_Code): Protect access to
aggregate components when the aggregate is empty.

16 months agoada: Enable Support_Atomic_Primitives on VxWorks 7 PPC
Johannes Kliemann [Fri, 10 Mar 2023 15:27:32 +0000 (15:27 +0000)]
ada: Enable Support_Atomic_Primitives on VxWorks 7 PPC

gcc/ada/

* libgnat/system-vxworks7-ppc-kernel.ads: Enable
Support_Atomic_Primitives.
* libgnat/system-vxworks7-ppc-rtp-smp.ads: Likewise.

16 months agoada: Fix internal error on declare-expression in post-condition
Eric Botcazou [Fri, 10 Mar 2023 17:05:13 +0000 (18:05 +0100)]
ada: Fix internal error on declare-expression in post-condition

It comes from an incorrect node sharing in the expanded tree.

gcc/ada/

* sem_ch3.adb (Find_Type_Of_Object): Copy the object definition when
building the subtype declaration in the case of a spec expression.

16 months agoada: Require successful build of xsnamest
Tom Tromey [Wed, 8 Mar 2023 17:21:59 +0000 (10:21 -0700)]
ada: Require successful build of xsnamest

While experimenting, I introduced a compilation error into xsnamest.
This took a little while to track down because, while the error was in
the log, the build did not stop.  This patch changes Make-generated.in
to require a successful build of this program.

gcc/ada/

* Make-generated.in (ada/stamp-snames): Check result of
gnatmake.

16 months agoada: Minor adjustments to Standard_Address
Eric Botcazou [Wed, 8 Mar 2023 22:02:34 +0000 (23:02 +0100)]
ada: Minor adjustments to Standard_Address

Standard_Address is an internal entity that is meant to be a clone of
System.Address built at compilation startup.  It needs to be seen as a
bona-fide address by the code generator.  For the sake of completeness,
it is also given its modulus, although this does not matter in practice.

gcc/ada/

* cstand.adb (Create_Standard): Set the Is_Descendant_Of_Address
flag on Standard_Address.
* freeze.adb (Freeze_Entity): Copy the modulus of System.Address
onto Standard_Address.

16 months agoada: Add size clause to System.Address
Eric Botcazou [Wed, 8 Mar 2023 17:11:31 +0000 (18:11 +0100)]
ada: Add size clause to System.Address

Standard'Address_Size is the value provided by the code generator for the
size of pointers, and it is set as the default size of every thin pointer
by the front-end.  Now it is documented in the GNAT RM as having the value
of System.Address'Size, which is indeed the case on (correctly configured)
platforms where pointers contain exactly the number of bits that are needed
to address the memory space.

However, on platforms where pointers contain additional bits of metadata,
it has a larger value and the documented relation does not hold, which also
means that unchecked conversions between System.Address and pointers are
seen as potentially problematic.  In order to fix the discrepancy on these
platforms, this change adds the obvious size clause to System.Address, which
is confirming on all the other (correctly configured) platforms.

gcc/ada/

* libgnat/system-aix.ads (Address): Likewise.
* libgnat/system-darwin-arm.ads (Address): Likewise.
* libgnat/system-darwin-ppc.ads (Address): Likewise.
* libgnat/system-darwin-x86.ads (Address): Likewise.
* libgnat/system-djgpp.ads (Address): Likewise.
* libgnat/system-dragonfly-x86_64.ads (Address): Likewise.
* libgnat/system-freebsd.ads (Address): Likewise.
* libgnat/system-hpux-ia64.ads (Address): Likewise.
* libgnat/system-hpux.ads (Address): Likewise.
* libgnat/system-linux-alpha.ads (Address): Likewise.
* libgnat/system-linux-arm.ads (Address): Likewise.
* libgnat/system-linux-hppa.ads (Address): Likewise.
* libgnat/system-linux-ia64.ads (Address): Likewise.
* libgnat/system-linux-m68k.ads (Address): Likewise.
* libgnat/system-linux-mips.ads (Address): Likewise.
* libgnat/system-linux-ppc.ads (Address): Likewise.
* libgnat/system-linux-riscv.ads (Address): Likewise.
* libgnat/system-linux-s390.ads (Address): Likewise.
* libgnat/system-linux-sh4.ads (Address): Likewise.
* libgnat/system-linux-sparc.ads (Address): Likewise.
* libgnat/system-linux-x86.ads (Address): Likewise.
* libgnat/system-lynxos178-ppc.ads (Address): Likewise.
* libgnat/system-lynxos178-x86.ads (Address): Likewise.
* libgnat/system-mingw.ads (Address): Likewise.
* libgnat/system-qnx-arm.ads (Address): Likewise.
* libgnat/system-rtems.ads (Address): Likewise.
* libgnat/system-solaris-sparc.ads (Address): Likewise.
* libgnat/system-solaris-x86.ads (Address): Likewise.
* libgnat/system-vxworks-ppc-kernel.ads (Address): Likewise.
* libgnat/system-vxworks-ppc-rtp-smp.ads (Address): Likewise.
* libgnat/system-vxworks-ppc-rtp.ads (Address): Likewise.
* libgnat/system-vxworks7-aarch64-rtp-smp.ads (Address): Likewise.
* libgnat/system-vxworks7-aarch64.ads (Address): Likewise.
* libgnat/system-vxworks7-arm-rtp-smp.ads (Address): Likewise.
* libgnat/system-vxworks7-arm.ads (Address): Likewise.
* libgnat/system-vxworks7-ppc-kernel.ads (Address): Likewise.
* libgnat/system-vxworks7-ppc-rtp-smp.ads (Address): Likewise.
* libgnat/system-vxworks7-ppc64-kernel.ads (Address): Likewise.
* libgnat/system-vxworks7-ppc64-rtp-smp.ads (Address): Likewise.
* libgnat/system-vxworks7-x86-kernel.ads (Address): Likewise.
* libgnat/system-vxworks7-x86-rtp-smp.ads (Address): Likewise.
* libgnat/system-vxworks7-x86_64-kernel.ads (Address): Likewise.
* libgnat/system-vxworks7-x86_64-rtp-smp.ads (Address): Likewise.

16 months agoada: Fix error message for Aggregate aspect
Marc Poulhiès [Wed, 8 Mar 2023 19:39:45 +0000 (20:39 +0100)]
ada: Fix error message for Aggregate aspect

The error message was wrongly using % instead of & in the format string,
causing the displayed message to refer to incorrect names in some cases.

gcc/ada/

* sem_ch13.adb (Check_Aspect_At_Freeze_Point): fix format string,
use existing local Ident.

16 months agoada: Switch from E_Void to Is_Not_Self_Hidden
Bob Duff [Wed, 8 Mar 2023 17:15:13 +0000 (12:15 -0500)]
ada: Switch from E_Void to Is_Not_Self_Hidden

We had previously used Ekind = E_Void to indicate that a declaration is
self-hidden. We now use the Is_Not_Self_Hidden flag instead. This allows
us to avoid many "vanishing fields", which are (possibly-latent) bugs,
and we now enable the assertions in Atree that detect such bugs.

gcc/ada/

* atree.adb (Check_Vanishing_Fields): Fix bug in the "blah type
only" cases. Remove the special cases for E_Void. Misc cleanup.
(Mutate_Nkind): Disallow mutating to the same kind.
(Mutate_Ekind): Disallow mutating to E_Void.
(From E_Void is still OK -- entities start out as E_Void by
default.) Fix bug in statistics gathering -- was setting the wrong
count. Enable Check_Vanishing_Fields for entities.
* sem_ch8.adb (Is_Self_Hidden): New function.
(Find_Direct_Name): Call Is_Self_Hidden to use the new
Is_Not_Self_Hidden flag to determine whether a declaration is
hidden from all visibility by itself. This replaces the old method
of checking E_Void.
(Find_Expanded_Name): Likewise.
(Find_Selected_Component): Likewise.
* sem_util.adb (Enter_Name): Remove setting of Ekind to E_Void.
* sem_ch3.adb: Set the Is_Not_Self_Hidden flag in appropriate
places. Comment fixes.
(Inherit_Component): Remove setting of Ekind to E_Void.
* sem_ch9.adb
(Analyze_Protected_Type_Declaration): Update comment. Skip Itypes,
which should not be turned into components.
* atree.ads (Mutate_Nkind): Document error case.
(Mutate_Ekind): Remove comments apologizing for E_Void mutations.
Document error cases.

16 months agoada: Decouple size of addresses and pointers from size of memory space
Eric Botcazou [Wed, 8 Mar 2023 14:12:27 +0000 (15:12 +0100)]
ada: Decouple size of addresses and pointers from size of memory space

This decouples the size of the types representing addresses and pointers,
which is Standard'Address_Size, from the size of the memory space, which
is System.Memory_Size (more precisely log2 of it).  They are tied through
the definition of System.Address:

  type Address is mod Memory_Size;

so Standard'Address_Size >= log2 (System.Memory_Size) necessarily, but the
equality does not hold on platforms where addresses and pointers contain
additional bits of metadata.

gcc/ada/

* libgnat/a-ststio.adb (Set_Mode): Test System.Memory_Size.
* libgnat/g-debuti.ads (Address_64): Likewise.
* libgnat/i-c.ads: Add with clause for System.
(ptrdiff_t): Define based on the size of memory space.
(size_t): Likewise.
* libgnat/s-crtl.ads (size_t): Likewise.
(ssize_t): Likewise.
* libgnat/s-memory.ads (size_t): Likewise.
* libgnat/s-parame.ads (Size_Type): Likewise.
* libgnat/s-parame__hpux.ads (Size_Type): Likewise.
* libgnat/s-parame__posix2008.ads (Size_Type): Likewise.
* libgnat/s-parame__vxworks.ads (Size_Type): Likewise.
* libgnat/s-putima.adb (Signed_Address): Likewise.
(Unsigned_Address): Likewise.
* libgnat/s-stoele.ads (Storage_Offset): Likewise.

16 months agoada: Fix copying of quantified expressions
Piotr Trojanek [Wed, 8 Mar 2023 14:30:41 +0000 (15:30 +0100)]
ada: Fix copying of quantified expressions

While visiting the AST as part of routine New_Copy_Tree we maintain
an EWA_Level variable in a stack-like fashion. This worked fine for
expression with actions nodes but not for quantified expressions.

gcc/ada/

* sem_util.adb (Visit_Node): Decrement EWA_Level with the same condition
as when it was incremented.

16 months agoada: Deconstruct a no longer used parameter of New_Copy_Tree
Piotr Trojanek [Wed, 8 Mar 2023 10:41:42 +0000 (11:41 +0100)]
ada: Deconstruct a no longer used parameter of New_Copy_Tree

Parameter Scopes_In_EWA_OK of New_Copy_Tree was introduced in 2018 to
deal with expressions-with-actions (EWA) in the build-in-place
machinery. However, after changes made in 2022 it is no longer used by
any caller.

Cleanup related to handling of expression functions in GNATprove;
semantics is unaffected.

gcc/ada/

* sem_util.ads (New_Copy_Tree): Remove Scopes_In_EWA_OK from spec;
adapt comment.
* sem_util.adb (New_Copy_Tree): Remove Scopes_In_EWA_OK from body;
adapt code.

16 months agoada: Clean up copying of node trees
Piotr Trojanek [Tue, 7 Mar 2023 20:00:46 +0000 (21:00 +0100)]
ada: Clean up copying of node trees

Before calling routine In_Entity_Map we checked if the entity map is
present; inside this routine we checked this again.

Code cleanup; semantics is unaffected.

gcc/ada/

* sem_util.adb (Update_New_Entities): Remove redundant check for entity
map being present.

16 months agoada: Simplify copying of node lists
Piotr Trojanek [Tue, 7 Mar 2023 18:52:40 +0000 (19:52 +0100)]
ada: Simplify copying of node lists

When creating a copy of a node list we called Copy_Entity for entities
and Copy_Separate_Tree for other nodes. This was unnecessary, because
the Copy_Separate_Tree when called on entities will just do Copy_Entity.

Code cleanup; semantics is unaffected.

gcc/ada/

* atree.adb (Copy_List): Call Copy_Separate_Tree for both entities and
other nodes.

16 months agoada: Avoid duplicated streaming subprograms
Steve Baird [Fri, 3 Mar 2023 00:51:57 +0000 (16:51 -0800)]
ada: Avoid duplicated streaming subprograms

In some common cases, a reference to Some_Type'Some_Streaming_Attribute
causes the needed subprogram to be generated "on demand". If there are
multiple such references (e.g., two calls to Some_Type'Write) then we
want to avoid generating multiple essentially-identical subprograms.
This change implies that a generated streaming subprogram may now have
multiple call sites, so we can no longer use the source position information
from the (one and only) call site. If an exception is raised during a
streaming operation, this can make a difference in the reported raise location.

gcc/ada/

* exp_attr.adb
(Cached_Streaming_Ops): A new package, providing maps to save
previously-generated Read/Write/Input/Output procedures.
(Expand_N_Attribute_Reference): When a new subprogram is generated
for a Read/Write/Input/Output attribute reference, record that
type/subp pair in the appropriate Cached_Streaming_Ops map.
(Find_Stream_Subprogram): Check the appropriate
Cached_Streaming_Ops map to see if an appropriate subprogram has
already been generated. If so, then return it. The appropriateness
test includes a call to a new nested subprogram,
In_Available_Context.
* exp_strm.ads, exp_strm.adb: Do not pass in a Loc parameter (or a
source-location-bearing Nod parameter) to the 16 procedures
provided for building streaming-related subprograms. Use the
source location of the type instead.
* exp_dist.adb, exp_ch3.adb: Adapt to Exp_Strm spec changes. For
these calls the source location of the type was already being
used.

16 months agoada: Fix crash during function return analysis
Marc Poulhiès [Tue, 7 Mar 2023 15:35:48 +0000 (16:35 +0100)]
ada: Fix crash during function return analysis

The compiler would crash when checking type relation between the
function's return type and the type of the expression used in the return
statement. It would not work if the function's return type is an access
type and the expression is not.

gcc/ada/

* sem_ch6.adb (Analyze_Function_Return): Add missing
Is_Access_Type check before accessing the Designated_Type field.

16 months agoada: Remove unused initial value of a local variable
Piotr Trojanek [Tue, 7 Mar 2023 08:02:23 +0000 (09:02 +0100)]
ada: Remove unused initial value of a local variable

Cleanup related to improved handling of expression functions in
GNATprove; semantics is unaffected.

gcc/ada/

* sem_ch6.adb (Analyze_Return_Type): Remove unused initial value.

16 months agoada: Fix (again) incorrect handling of Aggregate aspect
Marc Poulhiès [Mon, 6 Mar 2023 11:15:13 +0000 (12:15 +0100)]
ada: Fix (again) incorrect handling of Aggregate aspect

Previous fix stopped the processing of the Aggregate aspect early,
skipping the call to Record_Rep_Item, making later call to
Resolve_Container_Aggregate fail.

Also, the previous fix would not handle correctly the case where the
type is private and the check for non-array type can only be done at the
freeze point with the full type.

Adapt the resolving of the aspect when the input is not correct and the
parameters can't be resolved.

gcc/ada/

* sem_ch13.adb (Analyze_One_Aspect): Call Record_Rep_Item.
(Check_Aspect_At_Freeze_Point): Check the aspect is specified on
non-array type only...
(Analyze_One_Aspect): ... instead of doing it too early here.
* sem_aggr.adb (Resolve_Container_Aggregate): Do nothing in case
the parameters failed to resolve.

16 months agoada: Prevent search of calls in preconditions from going too far
Piotr Trojanek [Sat, 4 Mar 2023 17:07:55 +0000 (18:07 +0100)]
ada: Prevent search of calls in preconditions from going too far

When determining whether a call to protected function appears within
a pragma expression we can safely stop at the subprogram body.

Cleanup related to recently added support for a new SPARK aspects,
whose implementation was based on Contract_Cases.

gcc/ada/

* sem_util.adb (Check_Internal_Protected_Use): Add standard protection
against search going too far.

16 months agoada: Fix comments for recently added SPARK aspects
Piotr Trojanek [Sat, 4 Mar 2023 17:07:33 +0000 (18:07 +0100)]
ada: Fix comments for recently added SPARK aspects

Implementation of contract Subprogram_Variant and Exceptional_Cases was
based on the existing code for Contract_Cases, i.e. on the existing
occurrences of Aspect_Contract_Cases, Name_Contract_Cases and
Pragma_Contract_Cases. However, occurrences of "Contract_Cases" itself
in the comments were not updated.

gcc/ada/

* contracts.adb
(Add_Pre_Post_Condition): Mention new aspects in the comment.
* contracts.ads
(Add_Contract_Item): Likewise.
(Analyze_Subprogram_Body_Stub_Contract): Likewise.
* sem_prag.adb
(Contract_Freeze_Error): Likewise.
(Ensure_Aggregate_Form): Likewise.
* sem_prag.ads
(Find_Related_Declaration_Or_Body): Likewise.
* sinfo.ads
(Is_Generic_Contract_Pragma): Likewise.

16 months agoada: Add missing supportive code for recently added SPARK aspects
Piotr Trojanek [Fri, 3 Mar 2023 16:45:20 +0000 (17:45 +0100)]
ada: Add missing supportive code for recently added SPARK aspects

Fix minor inconsistencies with the recently added SPARK aspects
Exceptional_Cases and Subprogram_Variant, whose implementation is based
on Contract_Cases.

gcc/ada/

* aspects.ads
(Implementation_Defined_Aspect): Recently added aspects are
implementation-defined, just like Contract_Cases.
* sem_prag.ads
(Aspect_Specifying_Pragma): Recently added aspects have corresponding
pragmas, just like Contract_Cases.
(Pragma_Significant_To_Subprograms): Recently added aspects are
significant to subprograms, just like Contract_Cases.

16 months agoada: Tune handling of attributes Old in contract Exceptional_Cases
Piotr Trojanek [Mon, 6 Mar 2023 11:50:04 +0000 (12:50 +0100)]
ada: Tune handling of attributes Old in contract Exceptional_Cases

Contract Exceptional_Cases allows formal parameters to appear *in*
prefixes of attributes Old, but the code only allowed them to appear
*as* prefixes of those attributes.

For example, we now accetp expressions like "X.all'Old" that were
previously rejected.

gcc/ada/

* sem_res.adb (Resolve_Entity_Name): Tune handling of formal parameters
in contract Exceptional_Cases.

16 months agoada: Remove redundant guards from calls to Move_Aspects
Piotr Trojanek [Fri, 3 Mar 2023 16:27:40 +0000 (17:27 +0100)]
ada: Remove redundant guards from calls to Move_Aspects

Routine Move_Aspects does nothing if its From parameter has no aspects.
There is no need to check this at the call sites.

Code cleanup related to changes in handling of expressions functions in
GNATprove; semantics is unaffected.

gcc/ada/

* par-ch7.adb (P_Package): Remove redundant guard from call to
Move_Aspects.
* par-ch9.adb (P_Task): Likewise.
* sem_ch6.adb (Analyze_Expression_Function, Is_Inline_Pragma): Likewise.

16 months agoada: Small tweak to implementation of by-copy semantics for storage models
Eric Botcazou [Sat, 4 Mar 2023 14:02:32 +0000 (15:02 +0100)]
ada: Small tweak to implementation of by-copy semantics for storage models

Get_Actual_Subtype can be used to access the Actual_Designated_Subtype of
explicit dereferences with a storage model. As a side effect, this also
handles the case where the prefix of the dereference is a formal parameter.

gcc/ada/

* exp_ch6.adb (Add_Simple_Call_By_Copy_Code): Use Get_Actual_Subtype
to retrieve the actual subtype for all actuals and do it in only one
place for all unconstrained composite formal types.

16 months agoada: Fix copy-paste mistake in analysis of Exceptional_Cases
Piotr Trojanek [Fri, 3 Mar 2023 17:23:58 +0000 (18:23 +0100)]
ada: Fix copy-paste mistake in analysis of Exceptional_Cases

Trivial mistakes in copied code.

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Fix references to Exceptional_Cases in
code copied from handling of Subprogram_Variant.

16 months agoada: Enrich documentation of subprogram
Ronan Desplanques [Fri, 3 Mar 2023 16:48:47 +0000 (17:48 +0100)]
ada: Enrich documentation of subprogram

This patch adds documentation to the subprogram Replace_Type in
Sem_Ch3. In particular, references to relevant parts of the Ada
reference manual are added.

gcc/ada/

* sem_ch3.adb (Replace_Type): Add more documentation.

16 months agoada: Maximize use of existing constant
Ronan Desplanques [Fri, 3 Mar 2023 11:33:21 +0000 (12:33 +0100)]
ada: Maximize use of existing constant

This patch does not change the behavior of the compiler and is
intended as a readability improvement.

gcc/ada/

* sem_ch3.adb (Replace_Type): Use existing constant wherever
possible.

16 months agoada: Reduce span of variable
Ronan Desplanques [Fri, 3 Mar 2023 11:33:21 +0000 (12:33 +0100)]
ada: Reduce span of variable

This patch does not change the behavior of the compiler, but is
intended to improve readability. It seizes an opportunity to move
a variable declaration to a smaller scope, so that it's clearer
that the variable is not used outside of that scope.

gcc/ada/

* sem_ch3.adb (Replace_Type): Reduce span of variable.

16 months agoada: Set Is_Not_Self_Hidden flag in more cases
Bob Duff [Fri, 3 Mar 2023 14:46:34 +0000 (09:46 -0500)]
ada: Set Is_Not_Self_Hidden flag in more cases

More work-in-progress for changing E_Void checks to the flag.

gcc/ada/

* sem_ch9.adb (Analyze_Protected_Type_Declaration): Set the flag
for protected types.
(Analyze_Single_Protected_Declaration): Likewise, for singleton
protected objects.
(Analyze_Task_Type_Declaration): Set the flag for task types.
(Analyze_Single_Task_Declaration): Likewise, for singleton task
objects.
* sem_ch10.adb (Decorate_Type): Set the flag for types treated as
incomplete.
(Build_Shadow_Entity): Set the flag for shadow entities.
(Decorate_State): Set the flag for an abstract state.
(Build_Limited_Views): Set the flag for limited view of package.
* sem_attr.adb (Check_Not_Incomplete_Type): Disable the check when
this is a current instance.

16 months agoada: Handle controlling access parameters in DTWs
Ronan Desplanques [Fri, 3 Mar 2023 14:21:16 +0000 (15:21 +0100)]
ada: Handle controlling access parameters in DTWs

This patch improves the way controlling access parameters are
handled in dispatch table wrappers. The constructions of both the
specifications and the bodies of wrappers are modified.

gcc/ada/

* freeze.adb (Build_DTW_Body): Add appropriate type conversions for
controlling access parameters.
* sem_util.adb (Build_Overriding_Spec): Fix designated types in
controlling access parameters.

16 months agoada: Add Entry_Cancel_Parameter to E_Label
Bob Duff [Thu, 2 Mar 2023 15:12:29 +0000 (10:12 -0500)]
ada: Add Entry_Cancel_Parameter to E_Label

...and other (minor) changes.

gcc/ada/

* gen_il-gen-gen_entities.adb (E_Label): Add
Entry_Cancel_Parameter. This is necessary because
Analyze_Implicit_Label_Declaration set the Ekind to E_Label.
Without this change, this field would fail the vanishing-fields
check in Atree (which is currently commented out).
* einfo.ads (Entry_Cancel_Parameter): Document for E_Label.
* sem_eval.adb (Why_Not_Static): Protect against previous errors
(no need to explain why something is not static if it's already
illegal for other reasons).
* sem_util.ads (Enter_Name): Fix misleading comment.

16 months agoada: Minor fixes in description of scope depth
Eric Botcazou [Thu, 2 Mar 2023 10:51:22 +0000 (11:51 +0100)]
ada: Minor fixes in description of scope depth

In particular, the scope depth of library units is 1 instead of 0.

gcc/ada/

* einfo.ads (Scope_Depth): Fix circular definition.
(Scope_Depth_Value): Fix value for library units.

16 months agoada: Tune warning about assignment just before a raise statement
Piotr Trojanek [Thu, 2 Mar 2023 14:11:40 +0000 (15:11 +0100)]
ada: Tune warning about assignment just before a raise statement

Tune warning about a possibly ineffective assignment to a formal
parameter that happens just before a raise statement.

The warning is now emitted for parameters of all by-copy types and not
just of scalar types (this gives more warnings), but is suppressed for
aliased parameters (this removes some spurious warnings).

gcc/ada/

* sem_ch11.adb (Analyze_Raise_Expression): Tune warning condition.
* libgnat/g-dirope.ads (Open): Remove a potentially inaccurate comment.
* libgnat/g-dirope.adb (Open): Remove a potentially useless assignment;
the Dir output parameter should be assigned a null value anyway by the
preceding call to Free.

16 months agoada: Accept aliased parameters in Exceptional_Cases
Piotr Trojanek [Thu, 2 Mar 2023 14:09:24 +0000 (15:09 +0100)]
ada: Accept aliased parameters in Exceptional_Cases

Aliased parameters, just like parameters by-reference types, can safely
appear in consequences of Exceptional_Cases aspect.

gcc/ada/

* sem_res.adb (Resolve_Entity_Name): Allow aliased parameters; tune
error message.

16 months agoada: Fix incorrect handling of Aggregate aspect
Marc Poulhiès [Tue, 28 Feb 2023 16:10:29 +0000 (17:10 +0100)]
ada: Fix incorrect handling of Aggregate aspect

This change fixes 2 incorrect handlings of the aspect.
The arguments are now correctly resolved and the aspect is rejected on
non array types.

gcc/ada/

* sem_ch13.adb (Analyze_One_Aspect): Mark Aggregate aspect as
needing delayed resolution and reject the aspect on non-array
type.

16 months agoada: Fix obsolete comment in Sinfo.Utils
Bob Duff [Thu, 2 Mar 2023 14:44:03 +0000 (09:44 -0500)]
ada: Fix obsolete comment in Sinfo.Utils

...caused by moving code here from Atree.

gcc/ada/

* sinfo-utils.adb: Update comment to refer to
New_Node_Debugging_Output.

16 months agoada: Fix SPARK context not restored when Load_Unit is failing
Marc Poulhiès [Tue, 28 Feb 2023 10:01:47 +0000 (11:01 +0100)]
ada: Fix SPARK context not restored when Load_Unit is failing

When Load_Unit fails to find the unit or encounters an error, the
Load_Fail procedure is called and an exception is raised, skipping the
restoration of the SPARK/Ghost context stored on procedure entry.

gcc/ada/

* rtsfind.adb (Load_RTU.Restore_SPARK_Context): New.
(Load_RTU): Use Restore_SPARK_Context on all exit paths.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Initialize local
variable to Empty.

16 months agoada: Restrict use of formal parameters within exceptional cases
Piotr Trojanek [Tue, 7 Feb 2023 23:54:06 +0000 (00:54 +0100)]
ada: Restrict use of formal parameters within exceptional cases

Restrict references to formal parameters within the new SPARK aspect
Exceptional_Cases and allow occurrences of 'Old in this aspect.

gcc/ada/

* sem_attr.adb
(Analyze_Attribute_Old_Result): Allow uses of 'Old and 'Result within
the new aspect.
* sem_res.adb
(Within_Exceptional_Cases_Consequence): New utility routine.
(Resolve_Entity_Name): Restrict use of formal parameters within the
new aspect.

16 months agoRISC-V: Remove FRM_REGNUM dependency for rtx conversions
Juzhe-Zhong [Thu, 25 May 2023 06:19:29 +0000 (14:19 +0800)]
RISC-V: Remove FRM_REGNUM dependency for rtx conversions

According to RVV ISA:
The conversions use the dynamic rounding mode in frm, except for the rtz
variants, which round towards zero.

So rtz conversion patterns should not have FRM dependency.

We can't support mode switching for FRM yet since rvv intrinsic doc is
not updated but
I think this patch is correct.

gcc/ChangeLog:

* config/riscv/vector.md: Remove FRM_REGNUM dependency in rtz
instructions.

Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
16 months agotestsuite, analyzer: Fix testcases with fclose
Christophe Lyon [Tue, 23 May 2023 09:20:05 +0000 (09:20 +0000)]
testsuite, analyzer: Fix testcases with fclose

The gcc.dg/analyzer/data-model-4.c and
gcc.dg/analyzer/torture/conftest-1.c fail with recent glibc headers
and succeed with older headers.

The new error message is:
warning: use of possibly-NULL 'f' where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument]

Like similar previous fixes in this area, this patch updates the
testcase so that this warning isn't reported.

2023-05-23  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/testsuite/
* gcc.dg/analyzer/data-model-4.c: Exit if fopen returns NULL.
* gcc.dg/analyzer/torture/conftest-1.c: Likewise.

16 months agoStream out NANs correctly.
Aldy Hernandez [Wed, 24 May 2023 17:57:00 +0000 (19:57 +0200)]
Stream out NANs correctly.

NANs don't have bounds, so there's no need to stream them out.

gcc/ChangeLog:

* data-streamer-in.cc (streamer_read_value_range): Handle NANs.
* data-streamer-out.cc (streamer_write_vrange): Same.
* value-range.h (class vrange): Make streamer_write_vrange a friend.

16 months agoDisallow setting of NANs in frange setter unless setting trees.
Aldy Hernandez [Wed, 24 May 2023 17:55:09 +0000 (19:55 +0200)]
Disallow setting of NANs in frange setter unless setting trees.

frange::set() is confusing in that we can set a NAN by specifying a
bound of +-NAN, even though we tecnically disallow NANs in the setter
because the kind can never be VR_NAN.  This is a wart for
get_tree_range(), which builds a range out of a tree from the source,
to work correctly.  It's ugly, and it showed its limitation while
implementing LTO streaming of ranges.

This patch disallows passing NAN bounds in frange::set() and fixes
get_tree_range.

gcc/ChangeLog:

* value-query.cc (range_query::get_tree_range): Set NAN directly
if necessary.
* value-range.cc (frange::set): Assert that bounds are not NAN.

16 months agoHash known NANs correctly for franges.
Aldy Hernandez [Wed, 24 May 2023 17:53:53 +0000 (19:53 +0200)]
Hash known NANs correctly for franges.

We're ICEing when trying to hash a known NAN.  This is unnoticeable
because the only user would be IPA, and even so, it currently doesn't
handle floats.  However, handling floats is a flip of a switch, so
it's best to handle them already.

gcc/ChangeLog:

* value-range.cc (add_vrange): Handle known NANs.

16 months agoAdd an frange::set_nan() variant that takes a nan_state.
Aldy Hernandez [Wed, 24 May 2023 17:47:02 +0000 (19:47 +0200)]
Add an frange::set_nan() variant that takes a nan_state.

Generalize frange::set_nan() to take a nan_state and make current
set_nan() methods syntactic sugar.

This is in preparation for better streaming of NANs for LTO/IPA.

gcc/ChangeLog:

* value-range.h (frange::set_nan): New.

16 months ago[PR100106] Reject unaligned subregs when strict alignment is required
Alexandre Oliva [Wed, 24 May 2023 06:07:56 +0000 (03:07 -0300)]
[PR100106] Reject unaligned subregs when strict alignment is required

The testcase for pr100106, compiled with optimization for 32-bit
powerpc -mcpu=604 with -mstrict-align expands the initialization of a
union from a float _Complex value into a load from an SCmode
constant pool entry, aligned to 4 bytes, into a DImode pseudo,
requiring 8-byte alignment.

The patch that introduced the testcase modified simplify_subreg to
avoid changing the MEM to outermode, but simplify_gen_subreg still
creates a SUBREG or a MEM that would require stricter alignment than
MEM's, and lra_constraints appears to get confused by that, repeatedly
creating unsatisfiable reloads for the SUBREG until it exceeds the
insn count.

Avoiding the unaligned SUBREG, expand splits the DImode dest into
SUBREGs and loads each SImode word of the constant pool with the
proper alignment.

for  gcc/ChangeLog

PR target/100106
* emit-rtl.cc (validate_subreg): Reject a SUBREG of a MEM that
requires stricter alignment than MEM's.

for  gcc/testsuite/ChangeLog

PR target/100106
* gcc.target/powerpc/pr100106-sa.c: New.

16 months ago[testsuite] require profiling for -pg
Alexandre Oliva [Wed, 24 May 2023 06:07:52 +0000 (03:07 -0300)]
[testsuite] require profiling for -pg

Fix two tests that use -pg but don't declare their requirement for
profiling support.

for  gcc/testsuite/ChangeLog

* gcc.target/i386/mcount_pic.c: Add dg-require-profiling.
* gcc.target/i386/pr104447.c: Likewise.

16 months ago[testsuite] require pthread for openmp
Alexandre Oliva [Wed, 24 May 2023 06:07:49 +0000 (03:07 -0300)]
[testsuite] require pthread for openmp

Fix test that uses -fopenmp without declaring requirement for pthread
support.

for  gcc/testsuite/ChangeLog

* g++.dg/pr80481.C: Add explicit pthread requirement.

16 months ago[testsuite] require pic for pr103074.c
Alexandre Oliva [Wed, 24 May 2023 06:07:47 +0000 (03:07 -0300)]
[testsuite] require pic for pr103074.c

Fix test that uses -fPIC without stating the requirement for PIC
support.

for  gcc/testsuite/ChangeLog

* gcc.target/i386/pr103074.c: Require fpic support.

16 months ago[testsuite] tsvc: skip include malloc.h when unavailable
Alexandre Oliva [Wed, 24 May 2023 06:07:46 +0000 (03:07 -0300)]
[testsuite] tsvc: skip include malloc.h when unavailable

tsvc tests all fail on systems that don't offer a malloc.h, other than
those that explicitly rule that out.  Use the preprocessor to test for
malloc.h's availability.

tsvc.h also expects a definition for struct timeval, but it doesn't
include sys/time.h.  Add a conditional include thereof.

for  gcc/testsuite/ChangeLog

* gcc.dg/vect/tsvc/tsvc.h: Test for and conditionally include
malloc.h and sys/time.h.

16 months ago[libstdc++] [testsuite] xfail to_chars/long_double on x86-vxworks
Alexandre Oliva [Wed, 24 May 2023 06:08:12 +0000 (03:08 -0300)]
[libstdc++] [testsuite] xfail to_chars/long_double on x86-vxworks

Just as on aarch64, x86's wider long double experiences loss of
precision with from_chars implemented in terms of double.  Expect the
execution fail.

for  libstdc++-v3/ChangeLog

* testsuite/20_util/to_chars/long_double.cc: Expect execution
fail on x86-vxworks.

16 months ago[testsuite] [x86] cope with --enable-frame-pointer
Alexandre Oliva [Wed, 24 May 2023 06:08:10 +0000 (03:08 -0300)]
[testsuite] [x86] cope with --enable-frame-pointer

Various x86 tests fail if the toolchain is configured with
--enable-frame-pointer, because the unexpected extra insns mess with
the expected asm counts.  Add -fomit-frame-pointer so that they can
still pass.

for  gcc/testsuite/ChangeLog

* gcc.target/i386/pieces-memcpy-7.c: Add -fomit-frame-pointer.
* gcc.target/i386/pieces-memcpy-8.c: Likewise.
* gcc.target/i386/pieces-memcpy-9.c: Likewise.
* gcc.target/i386/pieces-memset-1.c: Likewise.
* gcc.target/i386/pieces-memset-36.c: Likewise.
* gcc.target/i386/pieces-memset-4.c: Likewise.
* gcc.target/i386/pieces-memset-40.c: Likewise.
* gcc.target/i386/pieces-memset-41.c: Likewise.
* gcc.target/i386/pieces-memset-7.c: Likewise.
* gcc.target/i386/pieces-memset-8.c: Likewise.
* gcc.target/i386/pieces-memset-9.c: Likewise.
* gcc.target/i386/pr102230.c: Likewise.
* gcc.target/i386/pr78103-2.c: Likewise.

16 months agoDaily bump.
GCC Administrator [Thu, 25 May 2023 00:16:49 +0000 (00:16 +0000)]
Daily bump.

16 months agoGimple range PHI analyzer and testcases
Andrew MacLeod [Wed, 24 May 2023 13:52:26 +0000 (09:52 -0400)]
Gimple range PHI analyzer and testcases

Provide a PHI analyzer framework to provive better initial values for
PHI nodes which formk groups with initial values and single statements
which modify the PHI values in some predicatable way.

PR tree-optimization/107822
PR tree-optimization/107986
gcc/
* Makefile.in (OBJS): Add gimple-range-phi.o.
* gimple-range-cache.h (ranger_cache::m_estimate): New
phi_analyzer pointer member.
* gimple-range-fold.cc (fold_using_range::range_of_phi): Use
phi_analyzer if no loop info is available.
* gimple-range-phi.cc: New file.
* gimple-range-phi.h: New file.
* tree-vrp.cc (execute_ranger_vrp): Utililze a phi_analyzer.

gcc/testsuite/
* gcc.dg/pr107822.c: New.
* gcc.dg/pr107986-1.c: New.

16 months agoProvide relation queries for a stmt.
Andrew MacLeod [Wed, 24 May 2023 13:17:32 +0000 (09:17 -0400)]
Provide relation queries for a stmt.

Allow fur_list and fold_stmt to be provided a range_query rather than
always defaultsing to NULL (which becomes a global query).
Also provide a fold_relations () routine which can provide a range_trio
for an arbitrary statement using any range_query

* gimple-range-fold.cc (fur_list::fur_list): Add range_query param
to contructors.
(fold_range): Add range_query parameter.
(fur_relation::fur_relation): New.
(fur_relation::trio): New.
(fur_relation::register_relation): New.
(fold_relations): New.
* gimple-range-fold.h (fold_range): Adjust prototypes.
(fold_relations): New.

16 months agoMake ssa_cache a range_query.
Andrew MacLeod [Wed, 24 May 2023 13:06:26 +0000 (09:06 -0400)]
Make ssa_cache a range_query.

By providing range_of_expr as a range_query, we can fold and do other
interesting things using values from the global table.  Make ranger's
knonw globals available via const_query.

* gimple-range-cache.cc (ssa_cache::range_of_expr): New.
* gimple-range-cache.h (class ssa_cache): Inherit from range_query.
(ranger_cache::const_query): New.
* gimple-range.cc (gimple_ranger::const_query): New.
* gimple-range.h (gimple_ranger::const_query): New prototype.

16 months agoMake ssa_cache and ssa_lazy_cache virtual.
Andrew MacLeod [Wed, 24 May 2023 12:49:30 +0000 (08:49 -0400)]
Make ssa_cache and ssa_lazy_cache virtual.

Making them virtual allows us to interchangebly use the caches.

* gimple-range-cache.cc (ssa_cache::dump): Use get_range.
(ssa_cache::dump_range_query): Delete.
(ssa_lazy_cache::dump_range_query): Delete.
(ssa_lazy_cache::get_range): Move from header file.
(ssa_lazy_cache::clear_range): ditto.
(ssa_lazy_cache::clear): Ditto.
* gimple-range-cache.h (class ssa_cache): Virtualize.
(class ssa_lazy_cache): Inherit and virtualize.

16 months agoFortran: reject bad DIM argument of SIZE intrinsic in simplification [PR104350]
Harald Anlauf [Wed, 24 May 2023 19:04:43 +0000 (21:04 +0200)]
Fortran: reject bad DIM argument of SIZE intrinsic in simplification [PR104350]

gcc/fortran/ChangeLog:

PR fortran/104350
* simplify.cc (simplify_size): Reject DIM argument of intrinsic SIZE
with error when out of valid range.

gcc/testsuite/ChangeLog:

PR fortran/104350
* gfortran.dg/size_dim_2.f90: New test.

16 months agoFortran: checking and simplification of RESHAPE intrinsic [PR103794]
Harald Anlauf [Sun, 21 May 2023 20:25:29 +0000 (22:25 +0200)]
Fortran: checking and simplification of RESHAPE intrinsic [PR103794]

gcc/fortran/ChangeLog:

PR fortran/103794
* check.cc (gfc_check_reshape): Expand constant arguments SHAPE and
ORDER before checking.
* gfortran.h (gfc_is_constant_array_expr): Add prototype.
* iresolve.cc (gfc_resolve_reshape): Expand constant argument SHAPE.
* simplify.cc (is_constant_array_expr): If array is determined to be
constant, expand small array constructors if needed.
(gfc_is_constant_array_expr): Wrapper for is_constant_array_expr.
(gfc_simplify_reshape): Fix check for insufficient elements in SOURCE
when no padding specified.

gcc/testsuite/ChangeLog:

PR fortran/103794
* gfortran.dg/reshape_10.f90: New test.
* gfortran.dg/reshape_11.f90: New test.

16 months agolibstdc++: Fix type of first argument to vec_cntm call
Matthias Kretz [Wed, 24 May 2023 14:43:07 +0000 (16:43 +0200)]
libstdc++: Fix type of first argument to vec_cntm call

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

PR libstdc++/109949
* include/experimental/bits/simd.h (__intrinsic_type): If
__ALTIVEC__ is defined, map gnu::vector_size types to their
corresponding __vector T types without losing unsignedness of
integer types. Also prefer long long over long.
* include/experimental/bits/simd_ppc.h (_S_popcount): Cast mask
object to the expected unsigned vector type.

16 months agoRemove deprecated vrange::kind().
Aldy Hernandez [Wed, 24 May 2023 17:59:20 +0000 (19:59 +0200)]
Remove deprecated vrange::kind().

gcc/ChangeLog:

* value-range.h (vrange::kind): Remove.

16 months agoPR middle-end/109840: Preserve popcount/parity type in match.pd.
Roger Sayle [Wed, 24 May 2023 16:32:20 +0000 (17:32 +0100)]
PR middle-end/109840: Preserve popcount/parity type in match.pd.

PR middle-end/109840 is a regression introduced by my recent patch to
fold popcount(bswap(x)) as popcount(x).  When the bswap and the popcount
have the same precision, everything works fine, but this optimization also
allowed a zero-extension between the two.  The oversight is that we need
to be strict with type conversions, both to avoid accidentally changing
the argument type to popcount, and also to reflect the effects of
argument/return-value promotion in the call to bswap, so this zero extension
needs to be preserved/explicit in the optimized form.

Interestingly, match.pd should (in theory) be able to narrow calls to
popcount and parity, removing a zero-extension from its argument, but
that is an independent optimization, that needs to check IFN_ support.
Many thanks to Andrew Pinski for his help/fixes with these transformations.

2023-05-24  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR middle-end/109840
* match.pd <popcount optimizations>: Preserve zero-extension when
optimizing popcount((T)bswap(x)) and popcount((T)rotate(x,y)) as
popcount((T)x), so the popcount's argument keeps the same type.
<parity optimizations>:  Likewise preserve extensions when
simplifying parity((T)bswap(x)) and parity((T)rotate(x,y)) as
parity((T)x), so that the parity's argument type is the same.

gcc/testsuite/ChangeLog
PR middle-end/109840
* gcc.dg/fold-parity-8.c: New test.
* gcc.dg/fold-popcount-11.c: Likewise.

16 months agoProvide an API for ipa_vr.
Aldy Hernandez [Wed, 17 May 2023 09:29:32 +0000 (11:29 +0200)]
Provide an API for ipa_vr.

This patch encapsulates the ipa_vr internals into an API.  It also
makes it type agnostic, in preparation for upcoming changes to IPA.

Interestingly, there's a 0.44% improvement to IPA-cp, which I'm sure
we'll soak up with future changes in this area :).

gcc/ChangeLog:

* ipa-cp.cc (ipa_value_range_from_jfunc): Use new ipa_vr API.
(ipcp_store_vr_results): Same.
* ipa-prop.cc (ipa_vr::ipa_vr): New.
(ipa_vr::get_vrange): New.
(ipa_vr::set_unknown): New.
(ipa_vr::streamer_read): New.
(ipa_vr::streamer_write): New.
(write_ipcp_transformation_info): Use new ipa_vr API.
(read_ipcp_transformation_info): Same.
(ipa_vr::nonzero_p): Delete.
(ipcp_update_vr): Use new ipa_vr API.
* ipa-prop.h (class ipa_vr): Provide an API and hide internals.
* ipa-sra.cc (zap_useless_ipcp_results): Use new ipa_vr API.

gcc/testsuite/ChangeLog:

* gcc.dg/ipa/pr78121.c: Adjust for vrange::dump use.
* gcc.dg/ipa/vrp1.c: Same.
* gcc.dg/ipa/vrp2.c: Same.
* gcc.dg/ipa/vrp3.c: Same.
* gcc.dg/ipa/vrp4.c: Same.
* gcc.dg/ipa/vrp5.c: Same.
* gcc.dg/ipa/vrp6.c: Same.
* gcc.dg/ipa/vrp7.c: Same.
* gcc.dg/ipa/vrp8.c: Same.

16 months agoFix sprintf length warning
Jan-Benedict Glaw [Wed, 24 May 2023 14:35:22 +0000 (16:35 +0200)]
Fix sprintf length warning

One of the supplied argument strings is unneccesarily long (c-sky, using
basically the same code, fixed it to a shorter length) and this fixes overflow
warnings, as GCC fails to deduce that the full 256 bytes for load_op[] are
not used at all.

gcc/ChangeLog:

* config/mcore/mcore.cc (output_inline_const) Make buffer smaller to
silence overflow warnings later on.

16 months agoi386: Add v<any_shift:insn>v4qi3 expander
Uros Bizjak [Wed, 24 May 2023 14:17:55 +0000 (16:17 +0200)]
i386: Add v<any_shift:insn>v4qi3 expander

Also, move v<any_shift:insn>v8qi3 expander to a better place and enable
it with TARGET_MMX_WITH_SSE.  Remove handling of V8QImode from
ix86_expand_vecop_qihi2 since all partial QI->HI vector modes expand
via ix86_expand_vecop_qihi_partial.

gcc/ChangeLog:

* config/i386/i386-expand.cc (ix86_expand_vecop_qihi2):
Remove handling of V8QImode.
* config/i386/mmx.md (v<insn>v8qi3): Move from sse.md.
Call ix86_expand_vecop_qihi_partial.  Enable for TARGET_MMX_WITH_SSE.
(v<insn>v4qi3): Ditto.
* config/i386/sse.md (v<insn>v8qi3): Remove.

gcc/testsuite/ChangeLog:

* gcc.target/i386/vect-shiftv4qi.c (dg-options):
Remove -ftree-vectorize.
* gcc.target/i386/vect-shiftv8qi.c (dg-options): Ditto.
* gcc.target/i386/vect-vshiftv4qi.c: New test.
* gcc.target/i386/vect-vshiftv8qi.c: New test.

16 months agoaarch64: PR target/99195 Annotate vector shift patterns for vec-concat-zero
Kyrylo Tkachov [Wed, 24 May 2023 13:52:34 +0000 (14:52 +0100)]
aarch64: PR target/99195 Annotate vector shift patterns for vec-concat-zero

Continuing the series of straightforward annotations, this one handles the normal (not widening or narrowing) vector shifts.
Tests included.

Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf.

gcc/ChangeLog:

PR target/99195
* config/aarch64/aarch64-simd.md (aarch64_simd_lshr<mode>): Rename to...
(aarch64_simd_lshr<mode><vczle><vczbe>): ... This.
(aarch64_simd_ashr<mode>): Rename to...
(aarch64_simd_ashr<mode><vczle><vczbe>): ... This.
(aarch64_simd_imm_shl<mode>): Rename to...
(aarch64_simd_imm_shl<mode><vczle><vczbe>): ... This.
(aarch64_simd_reg_sshl<mode>): Rename to...
(aarch64_simd_reg_sshl<mode><vczle><vczbe>): ... This.
(aarch64_simd_reg_shl<mode>_unsigned): Rename to...
(aarch64_simd_reg_shl<mode>_unsigned<vczle><vczbe>): ... This.
(aarch64_simd_reg_shl<mode>_signed): Rename to...
(aarch64_simd_reg_shl<mode>_signed<vczle><vczbe>): ... This.
(vec_shr_<mode>): Rename to...
(vec_shr_<mode><vczle><vczbe>): ... This.
(aarch64_<sur>shl<mode>): Rename to...
(aarch64_<sur>shl<mode><vczle><vczbe>): ... This.
(aarch64_<sur>q<r>shl<mode>): Rename to...
(aarch64_<sur>q<r>shl<mode><vczle><vczbe>): ... This.

gcc/testsuite/ChangeLog:

PR target/99195
* gcc.target/aarch64/simd/pr99195_1.c: Add testing for shifts.
* gcc.target/aarch64/simd/pr99195_6.c: Likewise.
* gcc.target/aarch64/simd/pr99195_8.c: New test.

16 months agotarget/109944 - avoid STLF fail for V16QImode CTOR expansion
Richard Biener [Wed, 24 May 2023 08:07:36 +0000 (10:07 +0200)]
target/109944 - avoid STLF fail for V16QImode CTOR expansion

The following dispatches to V2DImode CTOR expansion instead of
using sets of (subreg:DI (reg:V16QI 146) [08]) which causes
LRA to spill DImode and reload V16QImode.  The same applies for
V8QImode or V4HImode construction from SImode parts which happens
during 32bit libgcc build.

PR target/109944
* config/i386/i386-expand.cc (ix86_expand_vector_init_general):
Perform final vector composition using
ix86_expand_vector_init_general instead of setting
the highpart and lowpart which causes spilling.

* gcc.target/i386/pr109944-1.c: New testcase.
* gcc.target/i386/pr109944-2.c: Likewise.

16 months agoOnly update global value if it changes.
Andrew MacLeod [Tue, 23 May 2023 19:41:03 +0000 (15:41 -0400)]
Only update global value if it changes.

Do not update and propagate a global value if it hasn't changed.

PR tree-optimization/109695
* gimple-range-cache.cc (ranger_cache::get_global_range): Add
changed param.
* gimple-range-cache.h (ranger_cache::get_global_range): Ditto.
* gimple-range.cc (gimple_ranger::range_of_stmt): Pass changed
flag to set_global_range.
(gimple_ranger::prefill_stmt_dependencies): Ditto.

16 months agoUse negative values to reflect always_current in the temporal cache.
Andrew MacLeod [Tue, 23 May 2023 19:20:56 +0000 (15:20 -0400)]
Use negative values to reflect always_current in the temporal cache.

Instead of using 0, use negative timestamps to reflect always_current state.
If the value doesn't change, keep the timestamp rather than creating a new
one and invalidating any dependencies.

PR tree-optimization/109695
* gimple-range-cache.cc (temporal_cache::temporal_value): Return
a positive int.
(temporal_cache::current_p): Check always_current method.
(temporal_cache::set_always_current): Add param and set value
appropriately.
(temporal_cache::always_current_p): New.
(ranger_cache::get_global_range): Adjust.
(ranger_cache::set_global_range): set always current first.

16 months agoChoose better initial values for ranger.
Andrew MacLeod [Tue, 23 May 2023 19:11:44 +0000 (15:11 -0400)]
Choose better initial values for ranger.

Instead of defaulting to VARYING, fold the stmt using just global ranges.

PR tree-optimization/109695
* gimple-range-cache.cc (ranger_cache::get_global_range): Call
fold_range with global query to choose an initial value.

16 months agoRISC-V: Add FRM_ prefix to dynamic rounding mode enum
Juzhe-Zhong [Wed, 24 May 2023 11:40:37 +0000 (19:40 +0800)]
RISC-V: Add FRM_ prefix to dynamic rounding mode enum

An obvious fix to make all enum naming consistent.

gcc/ChangeLog:

* config/riscv/riscv-protos.h (enum frm_field_enum): Add FRM_
prefix.

Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
16 months agotree-optimization/109849 - fix fallout of PRE hoisting change
Richard Biener [Wed, 24 May 2023 10:36:28 +0000 (12:36 +0200)]
tree-optimization/109849 - fix fallout of PRE hoisting change

The PR109849 fix made us no longer hoist some memory loads because
of the expression set intersection.  We can still avoid to compute
the union by simply taking the first sets expressions and leave
the pruning of expressions with values not suitable for hoisting
to sorted_array_from_bitmap_set.

PR tree-optimization/109849
* tree-ssa-pre.cc (do_hoist_insertion): Do not intersect
expressions but take the first sets.

* gcc.dg/tree-ssa/ssa-hoist-9.c: New testcase.

16 months agolibstdc++: Fix SFINAE for __is_intrinsic_type on ARM
Matthias Kretz [Wed, 24 May 2023 10:50:46 +0000 (12:50 +0200)]
libstdc++: Fix SFINAE for __is_intrinsic_type on ARM

On ARM NEON doesn't support double, so __is_intrinsic_type_v<double,
whatever> should say false (instead of being ill-formed).

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

PR libstdc++/109261
* include/experimental/bits/simd.h (__intrinsic_type):
Specialize __intrinsic_type<double, 8> and
__intrinsic_type<double, 16> in any case, but provide the member
type only with __aarch64__.

16 months agolibstdc++: Add missing constexpr to simd_neon
Matthias Kretz [Tue, 23 May 2023 21:48:49 +0000 (23:48 +0200)]
libstdc++: Add missing constexpr to simd_neon

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

PR libstdc++/109261
* include/experimental/bits/simd_neon.h (_S_reduce): Add
constexpr and make NEON implementation conditional on
not __builtin_is_constant_evaluated.

16 months agoPR modula2/109952 Inconsistent HIGH values with 'ARRAY OF CHAR'
Gaius Mulley [Wed, 24 May 2023 10:14:07 +0000 (11:14 +0100)]
PR modula2/109952 Inconsistent HIGH values with 'ARRAY OF CHAR'

This patch fixes the case when a single character constant literal is
passed as a string actual parameter to an ARRAY OF CHAR formal parameter.
To be consistent a single character is promoted to a string and nul
terminated (and its high value is 1).  Previously a single character
string would not be nul terminated and the high value was 0.
The documentation now includes a section describing the expected behavior
and included in this patch is some regression test code matching the
table inside the documentation.

gcc/ChangeLog:

PR modula2/109952
* doc/gm2.texi (High procedure function): New node.
(Using): New menu entry for High procedure function.

gcc/m2/ChangeLog:

PR modula2/109952
* Make-maintainer.in: Change header to include emacs file mode.
* gm2-compiler/M2GenGCC.mod (BuildHighFromChar): Check whether
operand is a constant string and is nul terminated then return one.
* gm2-compiler/PCSymBuild.mod (WalkFunction): Add default return
TRUE.  Static analysis missing return path fix.
* gm2-libs/IO.mod (Init): Rewrite to help static analysis.
* target-independent/m2/gm2-libs.texi: Rebuild.

gcc/testsuite/ChangeLog:

PR modula2/109952
* gm2/pim/run/pass/hightests.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
16 months agoearly-remat: Resync with new DF postorders [PR109940]
Richard Sandiford [Wed, 24 May 2023 08:53:12 +0000 (09:53 +0100)]
early-remat: Resync with new DF postorders [PR109940]

When I wrote early-remat, the DF_FORWARD block order was a postorder
of a reverse/backward walk (i.e. of the inverted cfg), rather than a
reverse postorder of a forward walk.  A postorder of a backward walk
lacked the important property that dominators come before the blocks
they dominate; instead it ensures that postdominators come after
the blocks that they postdominate.

The DF_BACKWARD block order was similarly a postorder of a forward
walk.  Since early-remat wanted a standard postorder and reverse
postorder with normal dominator properties, it used the DF_BACKWARD
order instead of the DF_FORWARD order.

g:53dddbfeb213ac4ec39f fixed the DF orders so that DF_FORWARD was
an RPO of a forward walk and so that DF_BACKWARD was an RPO of a
backward walk.  This meant that iterating backwards over the
DF_BACKWARD order had the exact problem that the original DF_FORWARD
order had, triggering a flurry of ICEs for SVE.

This fixes the build with SVE enabled.  It also fixes an ICE
in g++.target/aarch64/sve/pr99766.C with normal builds.  I've
included the test from the PR as well, for extra coverage.

gcc/
PR rtl-optimization/109940
* early-remat.cc (postorder_index): Rename to...
(rpo_index): ...this.
(compare_candidates): Sort by decreasing rpo_index rather than
increasing postorder_index.
(early_remat::sort_candidates): Calculate the forward RPO from
DF_FORWARD.
(early_remat::local_phase): Follow forward RPO using DF_FORWARD,
rather than DF_BACKWARD in reverse.

gcc/testsuite/
* gcc.dg/torture/pr109940.c: New test.

16 months agoarm: PR target/109939 Correct signedness of return type of __ssat intrinsics
Kyrylo Tkachov [Wed, 24 May 2023 08:33:04 +0000 (09:33 +0100)]
arm: PR target/109939 Correct signedness of return type of __ssat intrinsics

As the PR says we shouldn't be using qualifier_unsigned for the return type of the __ssat intrinsics.
UNSIGNED_SAT_BINOP_UNSIGNED_IMM_QUALIFIERS already exists for that.
This was just a thinko.
This patch fixes this and the warning with -Wconversion goes away.

Bootstrapped and tested on arm-none-linux-gnueabihf.

gcc/ChangeLog:

PR target/109939
* config/arm/arm-builtins.cc (SAT_BINOP_UNSIGNED_IMM_QUALIFIERS): Use
qualifier_none for the return operand.

gcc/testsuite/ChangeLog:

PR target/109939
* gcc.target/arm/pr109939.c: New test.

16 months agoRISC-V: Add RVV mask logic auto-vectorization
Juzhe-Zhong [Wed, 24 May 2023 07:31:46 +0000 (15:31 +0800)]
RISC-V: Add RVV mask logic auto-vectorization

This patch is adding mask logic auto-vectorization, define the pattern
as "define_insn_and_split" to allow combine PASS easily combine series
instructions.

For example:
combine vmxor.mm + vmnot.m into vmxnor.mm

Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
gcc/ChangeLog:

* config/riscv/autovec.md (<optab><mode>3): New pattern.
(one_cmpl<mode>2): Ditto.
(*<optab>not<mode>): Ditto.
(*n<optab><mode>): Ditto.
* config/riscv/riscv-v.cc (expand_vec_cmp_float): Change to
one_cmpl.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/cmp/vcond-4.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/vcond_run-4.c: New test.

16 months ago[testsuite] [ppc] xfail uninit-pred-9_b bogus warn on ppc32 too
Alexandre Oliva [Wed, 24 May 2023 06:07:58 +0000 (03:07 -0300)]
[testsuite] [ppc] xfail uninit-pred-9_b bogus warn on ppc32 too

The bogus warning is present on 32-bit ppc-vx7r2 too, so drop the 64
from the powerpc xfail triplet.

for  gcc/testsuite/ChangeLog

* gcc.dg/uninit-pred-9_b.c: Xfail bogus warning on 32-bit ppc
as well.

16 months ago[testsuite] [i386] enable sse2 for signbit-2.c
Alexandre Oliva [Wed, 24 May 2023 06:07:44 +0000 (03:07 -0300)]
[testsuite] [i386] enable sse2 for signbit-2.c

The expected results for signbit-2 only arise on x86 with avx512f
disabled and sse2 enabled.  The patch already disables avx512f
explicitly, but it fails to enable sse2.

for  gcc/testsuite/ChangeLog

* gcc.dg/signbit-2.c: Add -msse2 on x86.

16 months agoCheck for sysconf decl on vxworks
Alexandre Oliva [Wed, 24 May 2023 06:07:41 +0000 (03:07 -0300)]
Check for sysconf decl on vxworks

The sysconf function is only available in rtp mode on vxworks.  In
kernel mode, it is not even declared, but the feature test macro in
the testsuite doesn't notice its absence because it's a link test, and
vxworks kernel mode uses partial linking.

This patch introduces an alternate test on vxworks targets to check
for a declaration and for an often-used sysconf parameter.

for  gcc/testsuite/ChangeLog

* lib/target-supports.exp (check_effective_target_sysconf):
Check for declaration and _SC_PAGESIZE on vxworks.

16 months agovect: Enhance cost evaluation in vect_transform_slp_perm_load_1
Kewen Lin [Wed, 24 May 2023 05:05:01 +0000 (00:05 -0500)]
vect: Enhance cost evaluation in vect_transform_slp_perm_load_1

Following Richi's suggestion in [1], I'm working on deferring
cost evaluation next to the transformation, this patch is
to enhance function vect_transform_slp_perm_load_1 which
could under-cost for vector permutation, since the costing
doesn't try to consider nvectors_per_build, it's inconsistent
with the transformation part.

Basically it changes the below

  if (index == count)
    {
       if (!noop_p)
         {
           // A ...
           // ++*n_perms;

           if (!analyze_only)
             {
                // B1 ...
                // B2 ...
                for ...
                   // B3 building VEC_PERM_EXPR
             }
         }
       else if (!analyze_only)
         {
            // no B2 since no any further uses here.
            for ...
              // B4 building nothing
         }
        // B5 ...
    }

to:

  if (index == count)
    {
       if (!noop_p)
         {
           // A ...

           if (!analyze_only)
             // B1 ...

           // B2 ... (trivial computations during analyze_only or not)

           for ...
             {
                // now n_perms is consistent with building VEC_PERM_EXPR
                // ++*n_perms;
                if (analyze_only)
                   continue;
                // B3 building VEC_PERM_EXPR
             }
         }
       else if (!analyze_only)
         {
            // no B2 since no any further uses here.
            for ...
              // B4 building nothing
         }
        // B5 ...
    }

[1] https://gcc.gnu.org/pipermail/gcc-patches/2021-January/563624.html

gcc/ChangeLog:

* tree-vect-slp.cc (vect_transform_slp_perm_load_1): Adjust the
calculation on n_perms by considering nvectors_per_build.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/costmodel/ppc/costmodel-slp-perm.c: New test.

16 months agoRISC-V: Add RVV comparison autovectorization
Juzhe-Zhong [Wed, 24 May 2023 03:37:01 +0000 (11:37 +0800)]
RISC-V: Add RVV comparison autovectorization

This patch enable RVV auto-vectorization including floating-point
unorder and order comparison.

The testcases are leveraged from Richard. So include Richard as co-author.

And this patch is the prerequisite patch for my current middle-end work.
Without this patch, I can't support len_mask_xxx middle-end pattern
since the mask is generated by comparison.

For example,
for (int i...; i < n.)
  if (cond[i])
     a[i] = b[i]

We need len_mask_load/len_mask_store for such code and I am gonna
support them in the middle-end after this patch is merged.

Both integer && floating (order and unorder) are tested.
built && regression passed.

Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Co-Authored-By: Richard Sandiford <richard.sandiford@arm.com>
gcc/ChangeLog:

* config/riscv/autovec.md (@vcond_mask_<mode><vm>): New pattern.
(vec_cmp<mode><vm>): New pattern.
(vec_cmpu<mode><vm>): New pattern.
(vcond<V:mode><VI:mode>): New pattern.
(vcondu<V:mode><VI:mode>): New pattern.
* config/riscv/riscv-protos.h (enum insn_type): Add new enum.
(emit_vlmax_merge_insn): New function.
(emit_vlmax_cmp_insn): Ditto.
(emit_vlmax_cmp_mu_insn): Ditto.
(expand_vec_cmp): Ditto.
(expand_vec_cmp_float): Ditto.
(expand_vcond): Ditto.
* config/riscv/riscv-v.cc (emit_vlmax_merge_insn): Ditto.
(emit_vlmax_cmp_insn): Ditto.
(emit_vlmax_cmp_mu_insn): Ditto.
(get_cmp_insn_code): Ditto.
(expand_vec_cmp): Ditto.
(expand_vec_cmp_float): Ditto.
(expand_vcond): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/rvv.exp:
* gcc.target/riscv/rvv/autovec/cmp/vcond-1.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/vcond-2.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/vcond-3.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/vcond_run-1.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/vcond_run-2.c: New test.
* gcc.target/riscv/rvv/autovec/cmp/vcond_run-3.c: New test.

16 months agoRISC-V: Support RVV VREINTERPRET from vbool*_t to vuint*m1_t
Pan Li [Thu, 18 May 2023 06:21:30 +0000 (14:21 +0800)]
RISC-V: Support RVV VREINTERPRET from vbool*_t to vuint*m1_t

This patch support the RVV VREINTERPRET from the vbool*_t to the
vuint*m1_t.  Aka:

vuint*m1_t __riscv_vreinterpret_x_x(vbool*_t);

These APIs help the users to convert vector the vbool*_t to the LMUL=1
unsigned integer vint*_t.  According to the RVV intrinsic SPEC as below,
the reinterpret intrinsics only change the types of the underlying contents.

https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#reinterpret-vbool-o-vintm1

For example, given below code.
vuint8m1_t test_vreinterpret_v_b1_vuint8m1 (vbool1_t src) {
  return __riscv_vreinterpret_v_b1_u8m1 (src);
}

It will generate the assembly code similar as below:
vsetvli a5,zero,e8,m8,ta,ma
vlm.v   v1,0(a1)
vs1r.v  v1,0(a0)
ret

Please NOTE the test files doesn't cover all the possible combinations
of the intrinsic APIs introduced by this PATCH due to too many.
This is the last PATCH for the reinterpret between the signed/unsigned
and the bool vector types.

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

* config/riscv/genrvv-type-indexer.cc (main): Add
unsigned_eew*_lmul1_interpret for indexer.
* config/riscv/riscv-vector-builtins-functions.def (vreinterpret):
Register vuint*m1_t interpret function.
* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_UNSIGNED_EEW8_LMUL1_INTERPRET_OPS):
New macro for vuint8m1_t.
(DEF_RVV_UNSIGNED_EEW16_LMUL1_INTERPRET_OPS): Likewise.
(DEF_RVV_UNSIGNED_EEW32_LMUL1_INTERPRET_OPS): Likewise.
(DEF_RVV_UNSIGNED_EEW64_LMUL1_INTERPRET_OPS): Likewise.
(vbool1_t): Add to unsigned_eew*_interpret_ops.
(vbool2_t): Likewise.
(vbool4_t): Likewise.
(vbool8_t): Likewise.
(vbool16_t): Likewise.
(vbool32_t): Likewise.
(vbool64_t): Likewise.
* config/riscv/riscv-vector-builtins.cc (DEF_RVV_UNSIGNED_EEW8_LMUL1_INTERPRET_OPS):
New macro for vuint*m1_t.
(DEF_RVV_UNSIGNED_EEW16_LMUL1_INTERPRET_OPS): Likewise.
(DEF_RVV_UNSIGNED_EEW32_LMUL1_INTERPRET_OPS): Likewise.
(DEF_RVV_UNSIGNED_EEW64_LMUL1_INTERPRET_OPS): Likewise.
(required_extensions_p): Add vuint*m1_t interpret case.
* config/riscv/riscv-vector-builtins.def (unsigned_eew8_lmul1_interpret):
Add vuint*m1_t interpret to base type.
(unsigned_eew16_lmul1_interpret): Likewise.
(unsigned_eew32_lmul1_interpret): Likewise.
(unsigned_eew64_lmul1_interpret): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/misc_vreinterpret_vbool_vint.c:
Enrich test cases.

16 months agoRISC-V: Support RVV VREINTERPRET from vbool*_t to vint*m1_t
Pan Li [Thu, 18 May 2023 02:46:38 +0000 (10:46 +0800)]
RISC-V: Support RVV VREINTERPRET from vbool*_t to vint*m1_t

This patch support the RVV VREINTERPRET from the vbool*_t to the
vint*m1_t.  Aka:

vint*m1_t __riscv_vreinterpret_x_x(vbool*_t);

These APIs help the users to convert vector the vbool*_t to the LMUL=1
signed integer vint*_t.  According to the RVV intrinsic SPEC as below,
the reinterpret intrinsics only change the types of the underlying contents.

https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#reinterpret-vbool-o-vintm1

For example, given below code.
vint8m1_t test_vreinterpret_v_b1_vint8m1 (vbool1_t src) {
  return __riscv_vreinterpret_v_b1_i8m1 (src);
}

It will generate the assembly code similar as below:
vsetvli a5,zero,e8,m8,ta,ma
vlm.v   v1,0(a1)
vs1r.v  v1,0(a0)
ret

Please NOTE the test files doesn't cover all the possible combinations
of the intrinsic APIs introduced by this PATCH due to too many.
The reinterpret from vbool*_t to vuint*m1_t with lmul=1 will be coverred
in another PATCH.

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

* config/riscv/genrvv-type-indexer.cc (EEW_SIZE_LIST): New macro
for the eew size list.
(LMUL1_LOG2): New macro for the log2 value of lmul=1.
(main): Add signed_eew*_lmul1_interpret for indexer.
* config/riscv/riscv-vector-builtins-functions.def (vreinterpret):
Register vint*m1_t interpret function.
* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_SIGNED_EEW8_LMUL1_INTERPRET_OPS):
New macro for vint8m1_t.
(DEF_RVV_SIGNED_EEW16_LMUL1_INTERPRET_OPS): Likewise.
(DEF_RVV_SIGNED_EEW32_LMUL1_INTERPRET_OPS): Likewise.
(DEF_RVV_SIGNED_EEW64_LMUL1_INTERPRET_OPS): Likewise.
(vbool1_t): Add to signed_eew*_interpret_ops.
(vbool2_t): Likewise.
(vbool4_t): Likewise.
(vbool8_t): Likewise.
(vbool16_t): Likewise.
(vbool32_t): Likewise.
(vbool64_t): Likewise.
* config/riscv/riscv-vector-builtins.cc (DEF_RVV_SIGNED_EEW8_LMUL1_INTERPRET_OPS):
New macro for vint*m1_t.
(DEF_RVV_SIGNED_EEW16_LMUL1_INTERPRET_OPS): Likewise.
(DEF_RVV_SIGNED_EEW32_LMUL1_INTERPRET_OPS): Likewise.
(DEF_RVV_SIGNED_EEW64_LMUL1_INTERPRET_OPS): Likewise.
(required_extensions_p): Add vint8m1_t interpret case.
* config/riscv/riscv-vector-builtins.def (signed_eew8_lmul1_interpret):
Add vint*m1_t interpret to base type.
(signed_eew16_lmul1_interpret): Likewise.
(signed_eew32_lmul1_interpret): Likewise.
(signed_eew64_lmul1_interpret): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/misc_vreinterpret_vbool_vint.c:
Enrich the test cases.

16 months agoRISC-V: Fix incorrect code of reaching inaccessible memory address
Juzhe-Zhong [Wed, 24 May 2023 02:59:02 +0000 (10:59 +0800)]
RISC-V: Fix incorrect code of reaching inaccessible memory address

To fix this issue, we seperate Vl operand and normal operands.

gcc/ChangeLog:

* config/riscv/autovec.md: Adjust for new interface.
* config/riscv/riscv-protos.h (emit_vlmax_insn): Add VL operand.
(emit_nonvlmax_insn): Add AVL operand.
* config/riscv/riscv-v.cc (emit_vlmax_insn): Add VL operand.
(emit_nonvlmax_insn): Add AVL operand.
(sew64_scalar_helper): Adjust for new interface.
(expand_tuple_move): Ditto.
* config/riscv/vector.md: Ditto.

Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
16 months agoRISC-V: Fix magic number of RVV auto-vectorization expander
Juzhe-Zhong [Wed, 24 May 2023 01:49:11 +0000 (09:49 +0800)]
RISC-V: Fix magic number of RVV auto-vectorization expander

This simple patch fixes the magic number, remove magic number make codes
more reasonable.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vec_series): Remove magic number.
(expand_const_vector): Ditto.
(legitimize_move): Ditto.
(sew64_scalar_helper): Ditto.
(expand_tuple_move): Ditto.
(expand_vector_init_insert_elems): Ditto.
* config/riscv/riscv.cc (vector_zero_call_used_regs): Ditto.

Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
This page took 0.106989 seconds and 5 git commands to generate.