aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2023-05-30ada: Adjust again the implementation of storage modelsEric Botcazou1-22/+29
The code generator must now be prepared to translate assignment statements to objects allocated with a storage model and that are not initialized yet. gcc/ada/ * gcc-interface/trans.cc (Attribute_to_gnu) <Attr_Size>: Tweak. (gnat_to_gnu) <N_Assignment_Statement>: Declare a local variable. For a target with a storage model, use the Actual_Designated_Subtype to compute the size if it is present.
2023-05-30ada: Simplify the implementation of storage modelsEric Botcazou1-103/+27
As the additional temporaries required by the semantics of nonnative storage models are now created by the front-end, in particular for actual parameters and assignment statements, the corresponding code in gigi can be removed. gcc/ada/ * gcc-interface/trans.cc (Call_to_gnu): Remove code implementing the by-copy semantics for actuals with nonnative storage models. (gnat_to_gnu) <N_Assignment_Statement>: Remove code instantiating a temporary for assignments between nonnative storage models.
2023-05-30ada: Make use of Cannot_Be_Superflat flag on N_Range nodesEric Botcazou2-3/+4
gcc/ada/ * gcc-interface/decl.cc (range_cannot_be_superflat): Return true immediately if Cannot_Be_Superflat is set. * gcc-interface/misc.cc (gnat_post_options): Do not override the -Wstringop-overflow setting.
2023-05-30ada: Disable PIE mode during the build of the Ada front-endEric Botcazou1-13/+3
This also removes some obsolete stuff. gcc/ada/ * gcc-interface/Make-lang.in (ADA_CFLAGS): Move up. (ALL_ADAFLAGS): Add $(NO_PIE_CFLAGS). (ada/mdll.o): Remove. (ada/mdll-fil.o): Likewise. (ada/mdll-utl.o): Likewise.
2023-05-30ada: Fix storage model handling for dereference as lvalue and renamingsMarc Poulhiès1-3/+21
Don't require storage access for explicit dereferences used as lvalue (e.g. Some_Access.all'Address) or for renamings. gcc/ada/ * gcc-interface/trans.cc (get_storage_model_access): Don't require storage model access for dereference used as lvalue or renamings.
2023-05-30ada: Small cleanups and fixes in expansion of aggregatesEric Botcazou1-62/+28
This streamlines the handling of qualified expressions in the expansion of aggregates and plugs a couple of loopholes that may cause memory leaks. gcc/ada/ * exp_aggr.adb (Build_Array_Aggr_Code): Move the declaration of Typ to the beginning. (Initialize_Array_Component): Test the unqualified version of the expression for the nested array case. (Initialize_Ctrl_Array_Component): Do not duplicate the expression here. Do the pattern matching of the unqualified version of it. (Gen_Assign): Call Unqualify to compute Expr_Q and use Expr_Q in subsequent pattern matching. (Initialize_Ctrl_Record_Component): Do the pattern matching of the unqualified version of the aggregate. (Build_Record_Aggr_Code): Call Unqualify. (Convert_Aggr_In_Assignment): Likewise. (Convert_Aggr_In_Object_Decl): Likewise. (Component_OK_For_Backend): Likewise. (Is_Delayed_Aggregate): Likewise.
2023-05-30ada: Fix wrong expansion of array aggregate with noncontiguous choicesEric Botcazou1-20/+18
This extends an earlier fix done for the others choice of an array aggregate to all the choices of the aggregate, since the same sharing issue may happen when the choices are not contiguous. gcc/ada/ * exp_aggr.adb (Build_Array_Aggr_Code.Get_Assoc_Expr): Duplicate the expression here instead of... (Build_Array_Aggr_Code): ...here.
2023-05-30ada: Fix internal error on array constant in expression functionEric Botcazou1-4/+21
This happens when the peculiar check emitted by Check_Large_Modular_Array is applied to an object whose actual subtype is an itype with dynamic size, because the first reference to the itype in the expanded code may turn out to be within the raise statement, which is problematic for the eloboration of this itype by the code generator at library level. gcc/ada/ * freeze.adb (Check_Large_Modular_Array): Fix head comment, use Standard_Long_Long_Integer_Size directly and generate a reference just before the raise statement if the Etype of the object is an itype declared in an open scope.
2023-05-30ada: Fix fallout of recent fix for missing finalizationEric Botcazou1-10/+26
The original fix makes it possible to create transient scopes around return statements in more cases, but it overlooks that transient scopes are reused and, in particular, that they can be promoted to secondary stack management. gcc/ada/ * exp_ch7.adb (Find_Enclosing_Transient_Scope): Return the index in the scope table instead of the scope's entity. (Establish_Transient_Scope): If an enclosing scope already exists, do not set the Uses_Sec_Stack flag on it if the node to be wrapped is a return statement which requires secondary stack management.
2023-05-30ada: Add System.Traceback.Symbolic.Module_Name support on AArch64 LinuxJoel Brobecker1-0/+2
This commit changes the runtime on aarch64-linux to use the Linux version of s-tsmona.adb, so as to add support for this functionality on aarch64-linux. gcc/ada/ * Makefile.rtl: Use libgnat/s-tsmona__linux.adb on aarch64-linux. Link libgnat with -ldl, as the use of s-tsmona__linux.adb requires it.
2023-05-30ada: Only build access-to-subprogram wrappers when expander is activePiotr Trojanek2-14/+2
For access-to-subprogram types with Pre/Post aspects we create a wrapper routine that evaluates these aspects. Spec of this wrapper was created always, while its body was only created when expansion was enabled. Now we only create these wrappers when expansion is enabled. In particular, we don't create them in GNATprove mode; instead, GNATprove picks the Pre/Post expressions directly from the aspects. gcc/ada/ * exp_ch3.adb (Build_Access_Subprogram_Wrapper_Body): Build wrapper body if requested by routine that builds wrapper spec. * sem_ch3.adb (Analyze_Full_Type_Declaration): Only build wrapper when expander is active. (Build_Access_Subprogram_Wrapper): Remove special-case for GNATprove.
2023-05-30ada: Fix minor issues in user's guideRonan Desplanques3-36/+32
gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Fix minor issues. * doc/gnat_ugn/the_gnat_compilation_model.rst: Fix minor issues. * gnat_ugn.texi: Regenerate.
2023-05-30ada: Ensure Default_Stack_Size is greater than Minimum_Stack_SizeJohannes Kliemann3-2/+13
The Default_Stack_Size function does not check that the binder specified default stack size is greater than the minimum stack size for the runtime. This can result in tasks using default stack sizes less than the minimum stack size because the Adjust_Storage_Size only adjusts storages sizes for tasks that explicitly specify a storage size. To avoid this, the binder specified default stack size is round up to the minimum stack size if required. gcc/ada/ * libgnat/s-parame.adb: Check that Default_Stack_Size >= Minimum_Stack_size. * libgnat/s-parame__rtems.adb: Ditto. * libgnat/s-parame__vxworks.adb: Check that Default_Stack_Size >= Minimum_Stack_size and use the proper Minimum_Stack_Size if Stack_Check_Limits is enabled.
2023-05-30ada: Fix regression of secondary stack management in return statementsEric Botcazou1-38/+31
This happens when the expression of the return statement is a call that does not return on the same stack as the enclosing function. gcc/ada/ * sem_res.adb (Resolve_Call): Restrict previous change to calls that return on the same stack as the enclosing function. Tidy up.
2023-05-30ada: Use generalized loop iteration in Put_Image routinesEric Botcazou2-16/+10
gcc/ada/ * libgnat/a-cidlli.adb (Put_Image): Simplify. * libgnat/a-coinve.adb (Put_Image): Likewise.
2023-05-30ada: Fix visibility error with DIC or Type_Invariant aspect on generic typeEric Botcazou1-2/+17
The compiler fails to capture global references during the analysis of the aspect on the generic type because it analyzes a copy of the expression. gcc/ada/ * exp_util.adb (Build_DIC_Procedure_Body.Add_Own_DIC): When inside a generic unit, preanalyze the expression directly. (Build_Invariant_Procedure_Body.Add_Own_Invariants): Likewise.
2023-05-30ada: Fix coding style in init.cCedric Landet1-2/+2
The coding style rules require to avoid using FIXME comments. ??? is preferred. gcc/ada/ * init.c: Replace FIXME by ???
2023-05-30Handle FMA friendly in reassoc passLili Cui3-83/+217
Make some changes in reassoc pass to make it more friendly to fma pass later. Using FMA instead of mult + add reduces register pressure and insruction retired. There are mainly two changes 1. Put no-mult ops and mult ops alternately at the end of the queue, which is conducive to generating more fma and reducing the loss of FMA when breaking the chain. 2. Rewrite the rewrite_expr_tree_parallel function to try to build parallel chains according to the given correlation width, keeping the FMA chance as much as possible. With the patch applied On ICX: 507.cactuBSSN_r: Improved by 1.7% for multi-copy . 503.bwaves_r : Improved by 0.60% for single copy . 507.cactuBSSN_r: Improved by 1.10% for single copy . 519.lbm_r : Improved by 2.21% for single copy . no measurable changes for other benchmarks. On aarch64 507.cactuBSSN_r: Improved by 1.7% for multi-copy. 503.bwaves_r : Improved by 6.00% for single-copy. no measurable changes for other benchmarks. TEST1: float foo (float a, float b, float c, float d, float *e) { return *e + a * b + c * d ; } For "-Ofast -mfpmath=sse -mfma" GCC generates: vmulss %xmm3, %xmm2, %xmm2 vfmadd132ss %xmm1, %xmm2, %xmm0 vaddss (%rdi), %xmm0, %xmm0 ret With this patch GCC generates: vfmadd213ss (%rdi), %xmm1, %xmm0 vfmadd231ss %xmm2, %xmm3, %xmm0 ret TEST2: for (int i = 0; i < N; i++) { a[i] += b[i]* c[i] + d[i] * e[i] + f[i] * g[i] + h[i] * j[i] + k[i] * l[i] + m[i]* o[i] + p[i]; } For "-Ofast -mfpmath=sse -mfma" GCC generates: vmovapd e(%rax), %ymm4 vmulpd d(%rax), %ymm4, %ymm3 addq $32, %rax vmovapd c-32(%rax), %ymm5 vmovapd j-32(%rax), %ymm6 vmulpd h-32(%rax), %ymm6, %ymm2 vmovapd a-32(%rax), %ymm6 vaddpd p-32(%rax), %ymm6, %ymm0 vmovapd g-32(%rax), %ymm7 vfmadd231pd b-32(%rax), %ymm5, %ymm3 vmovapd o-32(%rax), %ymm4 vmulpd m-32(%rax), %ymm4, %ymm1 vmovapd l-32(%rax), %ymm5 vfmadd231pd f-32(%rax), %ymm7, %ymm2 vfmadd231pd k-32(%rax), %ymm5, %ymm1 vaddpd %ymm3, %ymm0, %ymm0 vaddpd %ymm2, %ymm0, %ymm0 vaddpd %ymm1, %ymm0, %ymm0 vmovapd %ymm0, a-32(%rax) cmpq $8192, %rax jne .L4 vzeroupper ret with this patch applied GCC breaks the chain with width = 2 and generates 6 fma: vmovapd a(%rax), %ymm2 vmovapd c(%rax), %ymm0 addq $32, %rax vmovapd e-32(%rax), %ymm1 vmovapd p-32(%rax), %ymm5 vmovapd g-32(%rax), %ymm3 vmovapd j-32(%rax), %ymm6 vmovapd l-32(%rax), %ymm4 vmovapd o-32(%rax), %ymm7 vfmadd132pd b-32(%rax), %ymm2, %ymm0 vfmadd132pd d-32(%rax), %ymm5, %ymm1 vfmadd231pd f-32(%rax), %ymm3, %ymm0 vfmadd231pd h-32(%rax), %ymm6, %ymm1 vfmadd231pd k-32(%rax), %ymm4, %ymm0 vfmadd231pd m-32(%rax), %ymm7, %ymm1 vaddpd %ymm1, %ymm0, %ymm0 vmovapd %ymm0, a-32(%rax) cmpq $8192, %rax jne .L2 vzeroupper ret gcc/ChangeLog: PR tree-optimization/98350 * tree-ssa-reassoc.cc (rewrite_expr_tree_parallel): Rewrite this function. (rank_ops_for_fma): New. (reassociate_bb): Handle new function. gcc/testsuite/ChangeLog: PR tree-optimization/98350 * gcc.dg/pr98350-1.c: New test. * gcc.dg/pr98350-2.c: Ditto.
2023-05-30rtlanal: Change return type of predicate functions from int to boolUros Bizjak3-275/+275
gcc/ChangeLog: * rtl.h (rtx_addr_can_trap_p): Change return type from int to bool. (rtx_unstable_p): Ditto. (reg_mentioned_p): Ditto. (reg_referenced_p): Ditto. (reg_used_between_p): Ditto. (reg_set_between_p): Ditto. (modified_between_p): Ditto. (no_labels_between_p): Ditto. (modified_in_p): Ditto. (reg_set_p): Ditto. (multiple_sets): Ditto. (set_noop_p): Ditto. (noop_move_p): Ditto. (reg_overlap_mentioned_p): Ditto. (dead_or_set_p): Ditto. (dead_or_set_regno_p): Ditto. (find_reg_fusage): Ditto. (find_regno_fusage): Ditto. (side_effects_p): Ditto. (volatile_refs_p): Ditto. (volatile_insn_p): Ditto. (may_trap_p_1): Ditto. (may_trap_p): Ditto. (may_trap_or_fault_p): Ditto. (computed_jump_p): Ditto. (auto_inc_p): Ditto. (loc_mentioned_in_p): Ditto. * rtlanal.cc (computed_jump_p_1): Adjust forward declaration. (rtx_unstable_p): Change return type from int to bool and adjust function body accordingly. (rtx_addr_can_trap_p): Ditto. (reg_mentioned_p): Ditto. (no_labels_between_p): Ditto. (reg_used_between_p): Ditto. (reg_referenced_p): Ditto. (reg_set_between_p): Ditto. (reg_set_p): Ditto. (modified_between_p): Ditto. (modified_in_p): Ditto. (multiple_sets): Ditto. (set_noop_p): Ditto. (noop_move_p): Ditto. (reg_overlap_mentioned_p): Ditto. (dead_or_set_p): Ditto. (dead_or_set_regno_p): Ditto. (find_reg_fusage): Ditto. (find_regno_fusage): Ditto. (remove_node_from_insn_list): Ditto. (volatile_insn_p): Ditto. (volatile_refs_p): Ditto. (side_effects_p): Ditto. (may_trap_p_1): Ditto. (may_trap_p): Ditto. (may_trap_or_fault_p): Ditto. (computed_jump_p): Ditto. (auto_inc_p): Ditto. (loc_mentioned_in_p): Ditto. * combine.cc (can_combine_p): Update indirect function.
2023-05-30RISC-V: Add floating-point to integer conversion RVV auto-vectorization supportJuzhe-Zhong7-1/+110
Even though we can't support floating-point operations which are depending on FRM yet, (for example vfadd support is blocked) since the RVV intrinsic doc is not updated and we can't support mode switching for this. We can support floating-point to integer conversion now since it's not depending on FRM and we don't need mode switching support for this ('rtz' conversions independent FRM). Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai> gcc/ChangeLog: * config/riscv/autovec.md (<optab><mode><vconvert>2): New pattern. * config/riscv/iterators.md: New attribute. * config/riscv/vector-iterators.md: New attribute. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/conversions/vfcvt_rtz-run.c: New test. * gcc.target/riscv/rvv/autovec/conversions/vfcvt_rtz-rv32gcv.c: New test. * gcc.target/riscv/rvv/autovec/conversions/vfcvt_rtz-rv64gcv.c: New test. * gcc.target/riscv/rvv/autovec/conversions/vfcvt_rtz-template.h: New test.
2023-05-30RISC-V: Fix warning in riscv.mdFrom: Juzhe-Zhong1-2/+2
Notice there is warning: ../../../riscv-gcc/gcc/config/riscv/riscv.md:1356:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (INTVAL (operands[2]) == GET_MODE_MASK (HImode)) ../../../riscv-gcc/gcc/config/riscv/riscv.md:1358:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] else if (INTVAL (operands[2]) == GET_MODE_MASK (SImode)) ../../../riscv-gcc/gcc/config/riscv/riscv.md: In function ‘rtx_def* gen_anddi3(rtx, rtx, rtx)’: ../../../riscv-gcc/gcc/config/riscv/riscv.md:1356:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (INTVAL (operands[2]) == GET_MODE_MASK (HImode)) ../../../riscv-gcc/gcc/config/riscv/riscv.md:1358:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] else if (INTVAL (operands[2]) == GET_MODE_MASK (SImode)) Add unsigned conversion to fix this warning. Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai> gcc/ChangeLog: * config/riscv/riscv.md: Fix signed and unsigned comparison warning.
2023-05-30RISC-V: Add RVV FNMA auto-vectorization supportJuzhe-Zhong7-0/+432
Like FMA, Add FNMA (VNMSAC or VNMSUB) auto-vectorization support. Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai> gcc/ChangeLog: * config/riscv/autovec.md (fnma<mode>4): New pattern. (*fnma<mode>): Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/ternop/ternop-4.c: New test. * gcc.target/riscv/rvv/autovec/ternop/ternop-5.c: New test. * gcc.target/riscv/rvv/autovec/ternop/ternop-6.c: New test. * gcc.target/riscv/rvv/autovec/ternop/ternop_run-4.c: New test. * gcc.target/riscv/rvv/autovec/ternop/ternop_run-5.c: New test. * gcc.target/riscv/rvv/autovec/ternop/ternop_run-6.c: New test.
2023-05-30Daily bump.GCC Administrator3-1/+41
2023-05-29RISC-V: Optimize TARGET_XTHEADCONDMOVDie Li3-98/+42
This patch allows less instructions to be used when TARGET_XTHEADCONDMOV is enabled. Provide an example from the existing testcases. Testcase: int ConEmv_imm_imm_reg(int x, int y){ if (x == 1000) return 10; return y; } Cflags: -O2 -march=rv64gc_xtheadcondmov -mabi=lp64d before patch: ConEmv_imm_imm_reg: addi a5,a0,-1000 li a0,10 th.mvnez a0,zero,a5 th.mveqz a1,zero,a5 or a0,a0,a1 ret after patch: ConEmv_imm_imm_reg: addi a5,a0,-1000 li a0,10 th.mvnez a0,a1,a5 ret Signed-off-by: Die Li <lidie@eswincomputing.com> gcc/ChangeLog: * config/riscv/riscv.cc (riscv_expand_conditional_move_onesided): Delete. (riscv_expand_conditional_move): Reuse the TARGET_SFB_ALU expand process for TARGET_XTHEADCONDMOV gcc/testsuite/ChangeLog: * gcc.target/riscv/xtheadcondmov-indirect-rv32.c: Update the output. * gcc.target/riscv/xtheadcondmov-indirect-rv64.c: Likewise.
2023-05-29i386: Also require TARGET_AVX512BW to generate truncv16hiv16qi2 [PR110021]Uros Bizjak1-1/+1
gcc/ChangeLog: PR target/110021 * config/i386/i386-expand.cc (ix86_expand_vecop_qihi2): Also require TARGET_AVX512BW to generate truncv16hiv16qi2.
2023-05-29RISC-V: Use extension instructions instead of bitwise "and"Jivan Hakobyan4-1/+104
In the case where the target supports extension instructions, it is preferable to use that instead of doing the same in other ways. For the following case void foo (unsigned long a, unsigned long* ptr) { ptr[0] = a & 0xffffffffUL; ptr[1] &= 0xffffffffUL; } GCC generates foo: li a5,-1 srli a5,a5,32 and a0,a0,a5 sd a0,0(a1) ld a4,8(a1) and a5,a4,a5 sd a5,8(a1) ret but it will be profitable to generate this one foo: zext.w a0,a0 sd a0,0(a1) lwu a5,8(a1) sd a5,8(a1) ret This patch fixes mentioned issue. It supports HI -> DI, HI->SI and SI -> DI extensions. gcc/ChangeLog: * config/riscv/riscv.md (and<mode>3): New expander. (*and<mode>3) New pattern. * config/riscv/predicates.md (arith_operand_or_mode_mask): New predicate. gcc/testsuite/ChangeLog: * gcc.target/riscv/and-extend-1.c: New test * gcc.target/riscv/and-extend-2.c: New test
2023-05-29RISC-V: Refactor comments and naming of riscv-v.cc.Pan Li1-47/+49
This patch would like to remove unnecessary comments of some self explained parameters and try a better name to avoid misleading. Signed-off-by: Pan Li <pan2.li@intel.com> gcc/ChangeLog: * config/riscv/riscv-v.cc (emit_vlmax_insn): Remove unnecessary comments and rename local variables. (emit_nonvlmax_insn): Diito. (emit_vlmax_merge_insn): Ditto. (emit_vlmax_cmp_insn): Ditto. (emit_vlmax_cmp_mu_insn): Ditto. (emit_scalar_move_insn): Ditto. Signed-off-by: Pan Li <pan2.li@intel.com>
2023-05-29Daily bump.GCC Administrator4-1/+404
2023-05-29RISC-V: Eliminate the magic number in riscv-v.ccPan Li1-31/+46
This patch would like to remove the magic number in the riscv-v.cc, and align the same value to one macro. Signed-off-by: Pan Li <pan2.li@intel.com> gcc/ChangeLog: * config/riscv/riscv-v.cc (emit_vlmax_insn): Eliminate the magic number. (emit_nonvlmax_insn): Ditto. (emit_vlmax_merge_insn): Ditto. (emit_vlmax_cmp_insn): Ditto. (emit_vlmax_cmp_mu_insn): Ditto. (expand_vec_series): Ditto. Signed-off-by: Pan Li <pan2.li@intel.com>
2023-05-29RISC-V: Using merge approach to optimize repeating sequence in vec_initPan Li11-6/+457
This patch would like to optimize the VLS vector initialization like repeating sequence. From the vslide1down to the vmerge with a simple cost model, aka every instruction only has 1 cost. Given code with -march=rv64gcv_zvl256b --param riscv-autovec-preference=fixed-vlmax typedef int64_t vnx32di __attribute__ ((vector_size (256))); __attribute__ ((noipa)) void f_vnx32di (int64_t a, int64_t b, int64_t *out) { vnx32di v = { a, b, a, b, a, b, a, b, a, b, a, b, a, b, a, b, a, b, a, b, a, b, a, b, a, b, a, b, a, b, a, b, }; *(vnx32di *) out = v; } Before this patch: vslide1down.vx (x31 times) After this patch: li a5,-1431654400 addi a5,a5,-1365 li a3,-1431654400 addi a3,a3,-1366 slli a5,a5,32 add a5,a5,a3 vsetvli a4,zero,e64,m8,ta,ma vmv.v.x v8,a0 vmv.s.x v0,a5 vmerge.vxm v8,v8,a1,v0 vs8r.v v8,0(a2) Since we dont't have SEW = 128 in vec_duplicate, we can't combine ab into SEW = 128 element and then broadcast this big element. Signed-off-by: Pan Li <pan2.li@intel.com> Co-Authored by: Juzhe-Zhong <juzhe.zhong@rivai.ai> gcc/ChangeLog: * config/riscv/riscv-protos.h (enum insn_type): New type. * config/riscv/riscv-v.cc (RVV_INSN_OPERANDS_MAX): New macro. (rvv_builder::can_duplicate_repeating_sequence_p): Align the referenced class member. (rvv_builder::get_merged_repeating_sequence): Ditto. (rvv_builder::repeating_sequence_use_merge_profitable_p): New function to evaluate the optimization cost. (rvv_builder::get_merge_scalar_mask): New function to get the merge mask. (emit_scalar_move_insn): New function to emit vmv.s.x. (emit_vlmax_integer_move_insn): New function to emit vlmax vmv.v.x. (emit_nonvlmax_integer_move_insn): New function to emit nonvlmax vmv.v.x. (get_repeating_sequence_dup_machine_mode): New function to get the dup machine mode. (expand_vector_init_merge_repeating_sequence): New function to perform the optimization. (expand_vec_init): Add this vector init optimization. * config/riscv/riscv.h (BITS_PER_WORD): New macro. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-1.c: New test. * gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-2.c: New test. * gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-3.c: New test. * gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-4.c: New test. * gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-5.c: New test. * gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-run-1.c: New test. * gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-run-2.c: New test. * gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-run-3.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
2023-05-29Fix incorrect SLOC inherited by induction variable incrementEric Botcazou1-4/+4
This extends the condition to more cases involving debug instructions. gcc/ * tree-ssa-loop-manip.cc (create_iv): Try harder to find a SLOC to put onto the increment when it is inserted after the position.
2023-05-29Fix artificial overflow during GENERIC foldingEric Botcazou2-0/+27
The Ada compiler gives a bogus warning: storage_offset1.ads:16:52: warning: Constraint_Error will be raised at run time [enabled by default] Ironically enough, this occurs because of an intermediate conversion to an unsigned type which is supposed to hide overflows but is counter-productive for constants because TREE_OVERFLOW is always set for them, so it ends up setting a bogus TREE_OVERFLOW when converting back to the original type. The fix simply redirects INTEGER_CSTs to the other, direct path without the intermediate conversion to the unsigned type. gcc/ * match.pd ((T)P - (T)(P + A) -> -(T) A): Avoid artificial overflow on constants. gcc/testsuite/ * gnat.dg/specs/storage_offset1.ads: New test.
2023-05-29ada: Define sigset for systems that does not suport socketsCedric Landet1-5/+5
In s-oscons-tmplt.c, sigset is defined inside the HAVE_SOCKETS bloc. A platform could require sigset without supporting sockets. gcc/ada/ * s-oscons-tmplt.c: move the definition of sigset out of the HAVE_SOCKETS bloc.
2023-05-29ada: Set g-spogwa as a GNATRTL_SOCKETS_OBJSCedric Landet1-2/+1
g-spogwa.adb is the body of the procedure GNAT.Sockets.Poll.G_Wait. This is a socket specific procedure. It should only be built for systems that support sockets. gcc/ada/ * Makefile.rtl: Move g-spogwa$(objext) from GNATRTL_NONTASKING_OBJS to GNATRTL_SOCKETS_OBJS
2023-05-29ada: Fix spurious error on imported generic function with preconditionEric Botcazou1-7/+1
It occurs during the instantiation because the compiler forgets the context of the generic declaration. gcc/ada/ * freeze.adb (Wrap_Imported_Subprogram): Use Copy_Subprogram_Spec in both cases to copy the spec of the subprogram.
2023-05-29ada: Fix memory leak in expression function returning Big_IntegerEric Botcazou2-16/+28
We fail to establish a transient scope around the return statement because the function returns a controlled type, but this is no longer problematic because controlled types are no longer returned on the secondary stack. gcc/ada/ * exp_ch7.adb (Establish_Transient_Scope.Find_Transient_Context): Bail out for a simple return statement only if the transient scope and the function both require secondary stack management, or else if the function is a thunk. * sem_res.adb (Resolve_Call): Do not create a transient scope when the call is the expression of a simple return statement.
2023-05-29ada: Use Code_Address attribute to determine subprogram addressesPatrick Bernardi3-89/+48
The runtime used label addresses to determine the code address of subprograms because the subprogram's canonical address on some targets is a descriptor or a stub. Simplify the code by using the Code_Address attribute instead, which is designed to return the code address of a subprogram. This also works around a current GNAT-LLVM limitation where the address of a label is incorrectly calculated when using -O1. As a result, we can now build a-except.adb and g-debpoo.adb at -O1 again with GNAT-LLVM. gcc/ada/ * libgnat/a-excach.adb (Call_Chain): Replace Code_Address_For_AAA/ZZZ functions with AAA/ZZZ'Code_Address. * libgnat/a-except.adb (Code_Address_For_AAA/ZZZ): Delete. (AAA/ZZZ): New null procedures. * libgnat/g-debpoo.adb (Code_Address_For_Allocate_End): Delete. (Code_Address_For_Deallocate_End): Delete. (Code_Address_For_Dereference_End): Delete. (Allocate): Remove label and use Code_Address attribute to determine subprogram addresses. (Dellocate): Likewise. (Dereference): Likewise. (Allocate_End): Convert to null procedure. (Dellocate_End): Likewise. (Dereference_End): Likewise.
2023-05-29ada: Call idiomatic routine in Expand_Simple_Function_ReturnEric Botcazou1-1/+1
In the primary stack case, Insert_Actions is invoked when the expression is being rewritten, whereas Insert_List_Before_And_Analyze is invoked in the secondary stack case. The former is idiomatic, the latter is not. gcc/ada/ * exp_ch6.adb (Expand_Simple_Function_Return): Call Insert_Actions consistently when rewriting the expression.
2023-05-29ada: Fix wrong finalization for loop on indexed containerEric Botcazou1-3/+99
The problem is that a transient temporary created for the constant indexing of the container is finalized almost immediately after its creation. gcc/ada/ * exp_util.adb (Is_Finalizable_Transient.Is_Indexed_Container): New predicate to detect a temporary created to hold the result of a constant indexing on a container. (Is_Finalizable_Transient.Is_Iterated_Container): Adjust a couple of obsolete comments. (Is_Finalizable_Transient): Return False if Is_Indexed_Container returns True on the object.
2023-05-29ada: Fix bogus error on conditional expression with only user-defined literalsEric Botcazou1-29/+98
This implements the recursive resolution of conditional expressions whose dependent expressions are (all) user-defined literals the same way it is implemented for operators. gcc/ada/ * sem_res.adb (Has_Applicable_User_Defined_Literal): Make it clear that the predicate also checks the node itself. (Try_User_Defined_Literal): Move current implementation to... Deal only with literals, named numbers and conditional expressions whose dependent expressions are literals or named numbers. (Try_User_Defined_Literal_For_Operator): ...this. Remove multiple return False statements and put a single one at the end. (Resolve): Call Try_User_Defined_Literal instead of directly Has_Applicable_User_Defined_Literal for all nodes. Call Try_User_Defined_Literal_For_Operator for operator nodes.
2023-05-29ada: Fix crash on semi-recursive call in access-to-subprogram contractPiotr Trojanek1-2/+2
Calls to access-to-subprogram from its own pre/post aspects are rejected as illegal, e.g.: type F is access function (X : Natural) return Boolean with Pre => F.all (X); but they caused an assertion failure in detection of recursive calls. Now they are properly recognized as recursive, but the error is suppressed, because it has been already posted at the call node. gcc/ada/ * sem_res.adb (Invoked_With_Different_Arguments): Use Get_Called_Entity, which properly deals with calls via an access-to-subprogram; fix inconsistent use of a Call object declared in enclosing subprogram.
2023-05-29ada: Attach pre/post on access-to-subprogram to internal subprogram typePiotr Trojanek2-5/+13
Aspects Pre/Post that annotate access-to-subprogram type were attached to the source entity (whose kind is either E_Access_Subprogram_Type or E_Access_Protected_Subprogram_Type). However, it is more convenient to attach them to the internal entity (whose kind is E_Subprogram_Type), so that both Pre/Post aspects and First_Formal/Next_Formal chain are attached to the same entity, just like for ordinary subprograms. The drawback of having the Post aspect attached to an internal entity is that name in prefixes of attribute Result no longer match the name of entity where this Post aspect is attached. However, currently there is no code that relies on this matching and, in general, there are fewer routines that deal with attribute Result so they are easier to adapt than the code that queries the Pre/Post aspects. gcc/ada/ * contracts.adb (Add_Pre_Post_Condition): Attach pre/post aspects to E_Subprogram_Type entity. (Analyze_Entry_Or_Subprogram_Contract): Adapt to use full type declaration for a contract attached to E_Subprogram_Type entity. * sem_prag.adb (Analyze_Pre_Post_Condition): Add pre/post aspects to the designed type.
2023-05-29ada: Remove redundant protection against empty listsPiotr Trojanek1-3/+1
Calls to First on No_List intentionally return Empty, so explicit guards against No_List are unnecessary. Code cleanup; semantics is unaffected. gcc/ada/ * sem_util.adb (Check_Function_Writable_Actuals): Remove guard against a membership test with no alternatives; simplify with a membership test.
2023-05-29ada: Remove extra whitespace from FOR loopsPiotr Trojanek3-6/+6
Whitespace cleanup. gcc/ada/ * doc/gnat_ugn/gnat_and_program_execution.rst (Some Useful Memory Pools): Remove extra whitespace from examples. * sem_aggr.adb (Make_String_Into_Aggregate): Remove extra whitespace. * gnat_ugn.texi: Regenerate.
2023-05-29ada: Cleanup detection of type support subprogram entitiesPiotr Trojanek3-47/+35
Avoid repeated calls to Get_TSS_Name. Code cleanup related to handling of dispatching operations in GNATprove; semantics is unaffected. gcc/ada/ * exp_aggr.adb (Convert_Aggr_In_Allocator): Replace Get_TSS_Name with a high-level Is_TSS. * sem_ch6.adb (Check_Conformance): Replace DECLARE block and nested IF with a call to Get_TSS_Name and a membership test. (Has_Reliable_Extra_Formals): Refactor repeated calls to Get_TSS_Name. * sem_disp.adb (Check_Dispatching_Operation): Replace repeated calls to Get_TSS_Name with a membership test.
2023-05-29ada: Fix wrong finalization for case expression in expression functionEric Botcazou1-2/+6
This happens when the case expression contains a single alternative. gcc/ada/ * exp_ch5.adb (Expand_N_Case_Statement): Do not remove the statement if it is the node to be wrapped by a transient scope.
2023-05-29ada: Fix internal error with pragma Compile_Time_{Warning,Error}Eric Botcazou1-2/+7
This happens when the pragmas are deferred to the back-end from an external unit to the main unit that is generic, because the back-end does not compile a main unit that is generic. gcc/ada/ * sem_prag.adb (Process_Compile_Time_Warning_Or_Error): Do not defer anything to the back-end when the main unit is generic.
2023-05-29ada: Fix small fallout of previous changeEric Botcazou1-4/+6
It may lead to an infinite recursion if no interpretation exists. gcc/ada/ * sem_res.adb (Try_User_Defined_Literal): Restrict previous change to non-leaf nodes.
2023-05-29ada: Fix remaining failures in Roman Numbers testEric Botcazou1-2/+6
The test is inspired from the example of user-defined literals given in the Ada 2022 RM. Mixed Arabic numbers/Roman numbers computations are rejected because the second resolution pass would try to resolve Arabic numbers only as user-defined literals. gcc/ada/ * sem_res.adb (Try_User_Defined_Literal): For arithmetic operators, also accept operands whose type is covered by the resolution type.
2023-05-29ada: Fix memory leak in multi-dimensional array aggregate of VectorEric Botcazou1-1/+1
It comes from a superfluous adjustment for subarray components. gcc/ada/ * exp_aggr.adb (Initialize_Array_Component): Fix condition detecting the nested case that requires an adjustment.