aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-05-22ada: Remove outdated part of commentRonan Desplanques1-2/+1
The concept of extended nodes was retired with the introduction of variable-sized node types, but a reference to that concept was left over in a comment. This change removes that reference. gcc/ada/ * atree.ads: Remove outdated part of comment.
2023-05-22ada: Fix missing finalization in library-unit instance specEric Botcazou3-13/+34
This fixes the missing finalization of objects declared in the spec of package instances that are library units (and only them, i.e. not all library-level package instances) when the instances have a package body. The finalization is done when there is no package body, and supporting this case precisely broke the other case because of a thinko or a typo. This also requires a small adjustment to the routine writing ALI files. gcc/ada/ * exp_ch7.adb (Build_Finalizer): Reverse the test comparing the instantiation and declaration nodes of a package instance, and therefore bail out only when they are equal. Adjust comments. (Expand_N_Package_Declaration): Do not clear the Finalizer field. * lib-writ.adb: Add with and use clauses for Sem_Util. (Write_Unit_Information): Look at unit nodes to find finalizers. * sem_ch12.adb (Analyze_Package_Instantiation): Beef up the comment about the rewriting of the instantiation node into a declaration.
2023-05-22ada: Rename Is_Past_Self_Hiding_Point flag to be Is_Not_Self_HiddenBob Duff13-27/+27
...which seems clearer. Still work in progress. gcc/ada/ * cstand.adb (Is_Past_Self_Hiding_Point): Rename to be Is_Not_Self_Hidden. * einfo.ads: Likewise. * exp_aggr.adb: Likewise. * gen_il-fields.ads: Likewise. * gen_il-gen-gen_entities.adb: Likewise. * sem.adb: Likewise. * sem_aggr.adb: Likewise. * sem_ch11.adb: Likewise. * sem_ch12.adb: Likewise. * sem_ch5.adb: Likewise. * sem_ch6.adb: Likewise. * sem_ch7.adb: Likewise. * sem_prag.adb: Likewise.
2023-05-22ada: Fix spurious freezing error on nonabstract null extensionEric Botcazou1-3/+5
This prevents the wrapper function created for each nonoverridden inherited function with a controlling result of nonabstract null extensions of tagged types from causing premature freezing of types referenced in its profile. gcc/ada/ * exp_ch3.adb (Make_Controlling_Function_Wrappers): Create the body as the expanded body of an expression function.
2023-05-22ada: Further fixes to GNATprove and CodePeer expression pretty-printerPiotr Trojanek1-128/+198
The expression pretty-printer still crashes on several tests, but already gives much better outputs for many previously unsupported constructs. gcc/ada/ * pprint.adb (Expression_Image): Handle several previously unsupported constructs.
2023-05-22ada: Cleanup redundant condition in resolution of entity namesPiotr Trojanek1-6/+4
Code cleanup related to new contract for SPARK; semantics is unaffected. gcc/ada/ * sem_res.adb (Resolve_Entity_Name): Combine two IF statements that execute code only for references that come from source.
2023-05-22ada: Add Is_Past_Self_Hiding_Point flagBob Duff16-25/+89
This patch adds a flag Is_Past_Self_Hiding_Point. When False, this will replace E_Void as the indicator for a premature use of a declaration within itself -- for example, "X : T := X;". One might think this flag should be called something like Is_Hidden_From_All_Visibility, reversing the sense of Is_Past_Self_Hiding_Point. We don't do that because we want Is_Past_Self_Hiding_Point to be initially False by default (and we have no mechanism for defaulting to True), and because it doesn't exactly match the RM definition of "hidden from all visibility" (for example, for record components). This is work in progress; more changes are needed before we can remove all Mutate_Ekind(..., E_Void). gcc/ada/ * einfo.ads (Is_Past_Self_Hiding_Point): Document. * gen_il-fields.ads (Is_Past_Self_Hiding_Point): Add to list of fields. * gen_il-gen-gen_entities.adb (Is_Past_Self_Hiding_Point): Declare in all entities. * exp_aggr.adb: Set Is_Past_Self_Hiding_Point as appropriate. * sem.adb: Likewise. * sem_aggr.adb: Likewise. * sem_ch11.adb: Likewise. * sem_ch12.adb: Likewise. * sem_ch5.adb: Likewise. * sem_ch7.adb: Likewise. * sem_prag.adb: Likewise. * sem_ch6.adb: Likewise. (Set_Formal_Mode): Minor cleanup: Move from spec. * sem_ch6.ads: (Set_Formal_Mode): Minor cleanup: Move to body. * cstand.adb: Call Set_Is_Past_Self_Hiding_Point on all entities as soon as they are created. * comperr.adb (Compiler_Abort): Minor cleanup -- use 'in' instead of 'or else'. * debug.adb: Minor comment cleanups.
2023-05-22ada: Accept Assert pragmas in expression functionsSteve Baird1-1/+18
gcc/ada/ * sem_ch4.adb (Analyze_Expression_With_Actions.Check_Action_Ok): Accept an executable pragma occuring in a declare expression as per AI22-0045. This means Assert and Inspection_Point pragmas as well as any implementation-defined pragmas that the implementation chooses to categorize as executable. Currently Assume and Debug are the only such pragmas.
2023-05-22ada: Add warning on frontend inlining of Subprogram_VariantPiotr Trojanek1-3/+9
We already warned when contracts like pre/postcondition appear together with pragma Inline_Always and they are ignored by the frontend inlining. For consistency we now also warn for Subprogram_Variant, which is similarly ignored even though this contract is only meaningful for recursive subprograms and those can't be inlined anyway (but error about this might only be emitted when full compilation is done). gcc/ada/ * sem_prag.adb (Check_Postcondition_Use_In_Inlined_Subprogram): Mention Subprogram_Variant in the comment. (Analyze_Subprogram_Variant_In_Decl_Part): Warn when contract is ignored because of pragma Inline_Always and frontend inlining.
2023-05-22ada: Fix spurious warning on Inline_Always and contractsPiotr Trojanek1-1/+2
Warnings about pre/postconditions being ignored with Inline_Always were only true for the obsolete frontend inlining. With the current backend pre/postconditions work fine with Inline_Always. gcc/ada/ * sem_prag.adb (Check_Postcondition_Use_In_Inlined_Subprogram): Only emit warning when frontend inlining is enabled.
2023-05-22ada: Improve -gnatyx style checkArnaud Charlet6-23/+65
Check redundant parentheses in many more places, for now only under -gnatdQ, while pending violations are fixed. gcc/ada/ * par-ch3.adb, sem_ch4.adb (P_Discrete_Range, Analyze_Logical_Op, Analyze_Short_Circuit): Add calls to Check_Xtra_Parentheses. * par-ch5.adb (P_Condition): Move logic to Check_Xtra_Parentheses. * style.ads, styleg.adb, styleg.ads (Check_Xtra_Parens): Move logic related to expressions requiring parentheses here.
2023-05-22ada: Remove extra parenthesesArnaud Charlet63-187/+183
In preparation of enhancing -gnatyx to check for these automatically. gcc/ada/ * ali-util.adb, par-endh.adb, par-prag.adb, par-ch2.adb, checks.adb, fmap.adb, libgnat/a-nbnbig.ads, libgnat/g-dynhta.adb, libgnat/s-carun8.adb, libgnat/s-strcom.adb, libgnat/a-dhfina.adb, libgnat/a-direct.adb, libgnat/a-rbtgbo.adb, libgnat/a-strsea.adb, libgnat/a-ststio.adb, libgnat/a-suenco.adb, libgnat/a-costso.adb, libgnat/a-strmap.adb, libgnat/g-alleve.adb, libgnat/g-debpoo.adb, libgnat/g-sercom__linux.adb, libgnat/s-genbig.adb, libgnat/s-mmap.adb, libgnat/s-regpat.adb, par-ch5.adb, sem_case.adb, sem_ch12.adb, sem_ch13.adb, sem_ch8.adb, sem_eval.adb, sem_prag.adb, sem_type.adb, exp_ch11.adb, exp_ch2.adb, exp_ch3.adb, exp_ch4.adb, exp_ch5.adb, exp_ch6.adb, exp_ch9.adb, exp_put_image.adb, freeze.adb, live.adb, sem_aggr.adb, sem_cat.adb, sem_ch10.adb, sem_ch3.adb, sem_ch6.adb, sem_ch9.adb, sem_disp.adb, sem_elab.adb, sem_res.adb, sem_util.adb, sinput.adb, uintp.adb, bcheck.adb, binde.adb, binderr.adb, einfo-utils.adb, clean.adb, sem_ch4.adb, gnatls.adb, gprep.adb, sem_ch11.adb: Remove extra parentheses.
2023-05-22ada: Remove a remaining reference to ?Arnaud Charlet1-1/+1
We should no longer use ? anywhere when emitting warnings. gcc/ada/ * sem_aggr.adb (Get_Value): Use ?? instead of ?.
2023-05-22ada: Remove redundant protection against empty listsPiotr Trojanek4-22/+14
Calls to List_Length on No_List intentionally return 0 (and likewise call to First on No_List intentionally return Empty), so explicit guards against No_List are unnecessary. Code cleanup; semantics is unaffected. gcc/ada/ * exp_aggr.adb (Aggregate_Size): Remove redundant calls to Present. * exp_ch5.adb (Expand_N_If_Statement): Likewise. * sem_prag.adb (Analyze_Pragma): Likewise. * sem_warn.adb (Find_Var): Likewise.
2023-05-22ada: Support calls through dereferences in Find_ActualClaire Dross1-8/+38
Return the corresponding formal in the designated subprogram profile in that case. gcc/ada/ * sem_util.adb (Find_Actual): On calls through dereferences, return the corresponding formal in the designated subprogram profile.
2023-05-22ada: Remove unreferenced utility routine Is_Actual_Tagged_ParameterPiotr Trojanek2-16/+0
Routine Is_Actual_Tagged_Parameter was added to detect unsupported SPARK 2005 constructs, but this feature was deconstructed in favor of SPARK 2014 and its SPARK_Mode aspects. gcc/ada/ * sem_util.ads (Is_Actual_Tagged_Parameter): Remove spec. * sem_util.adb (Is_Actual_Tagged_Parameter): Remove body.
2023-05-22ada: Add contracts to Ada.Strings.Unbounded libraryJoffrey Huguet2-10/+22
This patch adds contracts to the conversions between Unbounded_String and String, the Element function and the equality between two Unbounded_String, or between Unbounded_String and String. This patch also disallows the use of a function in SPARK, because it returns an uninitialized Unbounded_String. gcc/ada/ * libgnat/a-strunb.ads, libgnat/a-strunb__shared.ads (To_Unbounded_String): Add postcondition. Add aspect SPARK_Mode Off on the version that takes a Natural as parameter. (To_String): Complete postcondition. (Set_Unbounded_String): Add postcondition. (Element): Likewise. ("="): Likewise.
2023-05-22ada: Fix crash on Ada.Containers with No_Dispatching_Calls restrictionEric Botcazou1-1/+5
This makes it so that the compiler does not crash and flags the underlying violation of the restriction instead. gcc/ada/ * exp_ch3.adb (Freeze_Type): Do not associate the Finalize_Address routine for a class-wide type if restriction No_Dispatching_Calls is in effect.
2023-05-22ada: Implement conversions from Big_Integer to large typesEric Botcazou3-20/+98
This implements the conversion from Big_Integer to Long_Long_Unsigned on 32-bit platforms and to Long_Long_Long_{Integer,Unsigned} on 64-bit ones. gcc/ada/ * libgnat/s-genbig.ads (From_Bignum): New overloaded declarations. * libgnat/s-genbig.adb (LLLI): New subtype. (LLLI_Is_128): New boolean constant. (From_Bignum): Change the return type of the signed implementation to Long_Long_Long_Integer and add support for the case where its size is 128 bits. Add a wrapper around it for Long_Long_Integer. Add an unsigned implementation returning Unsigned_128 and a wrapper around it for Unsigned_64. (To_Bignum): Test LLLI_Is_128 instead of its size. (To_String.Image): Add qualification to calls to From_Bignum. * libgnat/a-nbnbin.adb (To_Big_Integer): Likewise. (Signed_Conversions.From_Big_Integer): Likewise. (Unsigned_Conversions): Likewise.
2023-05-22ada: Fix error and crash on imported function with precondition and 'BaseEric Botcazou1-3/+4
This fixes a spurious error on an imported function with a precondition and a parameter declared with a 'Base formal type, and even a crash in the case where this function is declared in a generic package. gcc/ada/ * freeze.adb (Wrap_Imported_Subprogram): Use Copy_Subprogram_Spec to copy the spec from the subprogram to the generated subprogram body. (Freeze_Entity): Do not wrap imported subprograms inside generics.
2023-05-22ada: Reject illegal declarations in expression functionsSteve Baird1-0/+10
gcc/ada/ * sem_ch4.adb (Analyze_Expression_With_Actions.Check_Action_Ok): If Comes_From_Source (A) is False, then look at Original_Node (A) instead of A. In particular, if an (illegal) expression function is transformed into a "vanilla" function, we don't want to allow it just because Comes_From_Source is now False.
2023-05-22ada: Better error message if non-Ada2022 code declares No_Return functionSteve Baird1-4/+6
When a feature that is legal in Ada2022 but not in earlier Ada versions is used, we typically want to call Error_Msg_Ada_2022_Feature in order to generate an informative message in the error case. Specifying No_Return for a function (as opposed to a procedure) is no exception to this rule. gcc/ada/ * sem_prag.adb (Analyze_Pragma): In Check_No_Return, call Error_Msg_Ada_2022_Feature in the case of a function. Remove code outside of Check_No_Return that was querying Ada_Version.
2023-05-22ada: Fix double finalization in conditional exit statementEric Botcazou1-2/+5
The temporary is first finalized through its enclosing block. gcc/ada/ * exp_ch4.adb (Expand_N_Expression_With_Actions.Process_Action): Do not look into nested blocks.
2023-05-22ada: Fix handling of constrained array declarations in declare-expressionEric Botcazou1-2/+2
They need to go through Constrain_Array or else they do not really work. gcc/ada/ * sem_ch3.adb (Find_Type_Of_Object): In a spec expression, also set the Scope of the type, and call Constrain_Array for array subtypes.
2023-05-22ada: Fix traversal for the rightmost node of a pretty-printed expressionPiotr Trojanek1-46/+101
When getting the rightmost node of a pretty-printed expression we incorrectly traversed some composite nodes, which caused the expression image to be chopped. gcc/ada/ * pprint.adb (Expression_Image): Reduce scope of local variables; inline local uncommented constant From_Source; concatenate string with a single character, as it is likely to execute faster; add missing cases to traversal for the rightmost node and assertion to demonstrate that the ??? comment is no longer relevant.
2023-05-22ada: Restrict expression pretty-printer to subexpressionsPiotr Trojanek1-19/+23
When pretty-printing expressions with a CASE alternatives we can qualify the call to Nkind using N_Subexpr, so that we will get compile-time errors when new node kinds are added (e.g. Ada 2022 case expressions). gcc/ada/ * pprint.adb (Expr_Name): Qualify CASE expression with N_Subexpr; add missing alternative for N_Raise_Storage_Error; remove dead alternatives; explicitly list unsupported alternatives.
2023-05-22ada: Don't pretty-print DEL within expression imagesPiotr Trojanek1-1/+1
When printing expression images, e.g. for GNATprove counterexamples, it seems better to print DEL not directly but with its numeric code. gcc/ada/ * pprint.adb (Expr_Name): Exclude DEL from printable range.
2023-05-22ada: Update Controlling_Argument when copying treesPiotr Trojanek2-4/+70
When copying the AST we need to update fields that carry semantic meaning and not just copy them. We already updated some of them, e.g. the First/Next_Named_Association chain, but failed to update the Controlling_Argument. This fix doesn't appear to change anything for the compiler, but it is needed for GNATprove, where we no longer want to expand expression functions and instead we want to copy their preanalyzed expressions. gcc/ada/ * sem_util.ads (New_Copy_Tree): Update comment. * sem_util.adb (New_Copy_Tree): Update Controlling_Argument, very much like we update the First/Next_Named_Association.
2023-05-22ada: update Ada_Version_Type in fe.h to match opt.adsBob Duff2-12/+20
Remove Ada_With_Extensions, which is not used on the C side. Do not add Ada_With_Core_Extensions and Ada_With_All_Extensions, which are also not used on the C side, and on the Ada side are always used via functions All_Extensions_Allowed and Core_Extensions_Allowed. Explain this in comments. Move the functions closer to the type declaration, so the usage style is clearer. Cleanup only -- no change in compiler behavior. gcc/ada/ * fe.h: Remove Ada_With_Extensions and add commentary. * opt.ads: Rearrange code and add commentary.
2023-05-22ada: prevent infinite recursion in Collect_Types_In_HierarchyBob Duff2-0/+14
In (illegal) mutually-dependent type declarations, it is possible for Etype (Etype (Typ)) to point back to Typ. This patch stops the recursion in such cases. gcc/ada/ * sem_util.adb (Process_Type): Stop the recursion. * exp_aggr.adb (Build_Record_Aggr_Code): Add assertion.
2023-05-22VECT: Fix bug of multiple-rgroup for length is counting elementsJu-Zhe Zhong9-19/+950
Address comments from Richard that splits the patch of fixing multiple-rgroup handling of length counting elements. This patch is fixing issue of handling multiple-rgroup of length is counting elements Before this patch, multiple rgroup run fail: FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c execution test FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c execution test After this patch, These tests are all passed. gcc/ChangeLog: * tree-vect-loop.cc (vect_get_loop_len): Fix issue for multiple-rgroup of length. * tree-vect-stmts.cc (vectorizable_store): Ditto. (vectorizable_load): Ditto. * tree-vectorizer.h (vect_get_loop_len): Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-1.c: New test. * gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-1.h: New test. * gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-2.c: New test. * gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-2.h: New test. * gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-1.c: New test. * gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c: New test.
2023-05-22RISC-V: Reorganize the code of CONST_VECTOR handling in riscv.ccJuzhe-Zhong1-6/+6
Since satisfies_constraint_vi (x) belongs to RVV region. We make this condition inside riscv_v_ext_vector_mode_p to make codes more reasonable. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_const_insns): Reorganize the codes.
2023-05-21vect: Refactor code for index == count in vect_transform_slp_perm_load_1Kewen Lin1-45/+44
This patch is to refactor the handlings for the case (index == count) in a loop of vect_transform_slp_perm_load_1, in order to prepare a subsequent adjustment on *nperm. This patch doesn't have any functional changes. Basically this is to rewrite two if below: if (index == count && !noop_p) { // A ... // ++*n_perms; } if (index == count) { if (!analyze_only) { if (!noop_p) // B1 ... // B2 ... for ... { if (!noop_p) // B3 building VEC_PERM_EXPR else // B4 building nothing (no uses for B2 and its seq) } } // B5 } into one hunk 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 ... } gcc/ChangeLog: * tree-vect-slp.cc (vect_transform_slp_perm_load_1): Refactor the handling for the case index == count.
2023-05-22Daily bump.GCC Administrator4-1/+108
2023-05-21libgomp: Honor OpenMP's nteams-var ICV as upper limit on num teams [PR109875]Tobias Burnus6-2/+234
The nteams-var ICV exists per device and can be set either via the routine omp_set_num_teams or as environment variable (OMP_NUM_TEAMS with optional _ALL/_DEV/_DEV_<num> suffix); it is default-initialized to zero. The number of teams created is described under the num_teams clause. If the clause is absent, the number of teams is implementation defined but at least one team must exist and, if nteams-var is positive, at most nteams-var teams may exist. The latter condition was not honored in a target region before this commit, such that too many teams were created. Already before this commit, both the num_teams([lower:]upper) clause (on the host and in target regions) and, only on the host, the nteams-var ICV were honored. And as only one teams is created for host fallback, unless the clause specifies otherwise, the nteams-var ICV was and is effectively honored. libgomp/ChangeLog: PR libgomp/109875 * config/gcn/target.c (GOMP_teams4): Honor nteams-var ICV. * config/nvptx/target.c (GOMP_teams4): Likewise. * testsuite/libgomp.c-c++-common/teams-nteams-icv-1.c: New test. * testsuite/libgomp.c-c++-common/teams-nteams-icv-2.c: New test. * testsuite/libgomp.c-c++-common/teams-nteams-icv-3.c: New test. * testsuite/libgomp.c-c++-common/teams-nteams-icv-4.c: New test.
2023-05-21target/90622: __builtin_avr_insert bits: Use BLD/BST for one bit in place.Georg-Johann Lay1-3/+6
If just one bit is inserted in the same position like with: __builtin_avr_insert_bits (0xFFFFF2FF, src, dst); a BLD/BST sequence is better than XOR/AND/XOR. Thus, don't fold that case to the latter sequence. gcc/ PR target/90622 * config/avr/avr.cc (avr_fold_builtin) [AVR_BUILTIN_INSERT_BITS]: Don't fold to XOR / AND / XOR if just one bit is copied to the same position.
2023-05-21nvptx: Add suppport for __builtin_nvptx_brev instrinsic.Roger Sayle6-0/+311
This patch adds support for (a pair of) bit reversal intrinsics __builtin_nvptx_brev and __builtin_nvptx_brevll which perform 32-bit and 64-bit bit reversal (using nvptx's brev instruction) matching the __brev and __brevll instrinsics provided by NVidia's nvcc compiler. https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH__INTRINSIC__INT.html 2023-05-21 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/nvptx/nvptx.cc (nvptx_expand_brev): Expand target builtin for bit reversal using brev instruction. (enum nvptx_builtins): Add NVPTX_BUILTIN_BREV and NVPTX_BUILTIN_BREVLL. (nvptx_init_builtins): Define "brev" and "brevll". (nvptx_expand_builtin): Expand NVPTX_BUILTIN_BREV and NVPTX_BUILTIN_BREVLL via nvptx_expand_brev function. * doc/extend.texi (Nvidia PTX Builtin-in Functions): New section, document __builtin_nvptx_brev{,ll}. gcc/testsuite/ChangeLog * gcc.target/nvptx/brev-1.c: New 32-bit test case. * gcc.target/nvptx/brev-2.c: Likewise. * gcc.target/nvptx/brevll-1.c: New 64-bit test case. * gcc.target/nvptx/brevll-2.c: Likewise.
2023-05-21atch.pd: Ensure (op CONSTANT_CLASS_P CONSTANT_CLASS_P) is simplified [PR109505]Jakub Jelinek2-10/+22
On the following testcase we hang, because POLY_INT_CST is CONSTANT_CLASS_P, but BIT_AND_EXPR with it and INTEGER_CST doesn't simplify and the (x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2) simplification actually relies on the (CST1 & CST2) simplification, otherwise it is a deoptimization, trading 2 ops for 3 and furthermore running into /* Given a bit-wise operation CODE applied to ARG0 and ARG1, see if both operands are another bit-wise operation with a common input. If so, distribute the bit operations to save an operation and possibly two if constants are involved. For example, convert (A | B) & (A | C) into A | (B & C) Further simplification will occur if B and C are constants. */ simplification which simplifies that (x & CST2) | (CST1 & CST2) back to CST2 & (x | CST1). I went through all other places I could find where we have a simplification with 2 CONSTANT_CLASS_P operands and perform some operation on those two, while the other spots aren't that severe (just trade 2 operations for another 2 if the two constants don't simplify, rather than as in the above case trading 2 ops for 3), I still think all those spots really intend to optimize only if the 2 constants simplify. So, the following patch adds to those a ! modifier to ensure that, even at GENERIC that modifier means !EXPR_P which is exactly what we want IMHO. 2023-05-21 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/109505 * match.pd ((x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2), Combine successive equal operations with constants, (A +- CST1) +- CST2 -> A + CST3, (CST1 - A) +- CST2 -> CST3 - A, CST1 - (CST2 - A) -> CST3 + A): Use ! on ops with 2 CONSTANT_CLASS_P operands. * gcc.target/aarch64/sve/pr109505.c: New test.
2023-05-20Fix expand_single_bit_test for big-endianAndrew Pinski1-1/+8
I had thought extract_bit_field bitpos argument was the shifted position and not the bitposition like BIT_FIELD_REF so I had removed the code which would use the correct bitposition for BYTES_BIG_ENDIAN. Committed as obvious; I checked big-endian MIPS to make sure we are now producing the correct code. gcc/ChangeLog: * expr.cc (expand_single_bit_test): Correct bitpos for big-endian.
2023-05-21RISC-V: Support RVV VREINTERPRET from v{u}int*_t to vbool[2-64]_tPan Li6-6/+265
This patch support the RVV VREINTERPRET from the int to the vbool[2|4|8|16|32|64]_t. Aka: vbool[2|4|8|16|32|64]_t __riscv_vreinterpret_x_x(v{u}int[8|16|32|64]_t); These APIs help the users to convert vector LMUL=1 integer to vbool[2-64]_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. vbool64_t test_vreinterpret_v_u8m1_b64 (vuint8m1_t src) { return __riscv_vreinterpret_v_u8m1_b64 (src); } It will generate the assembly code similar as below: vsetvli a5,zero,e8,mf8,ta,ma vlm.v v1,0(a1) vsm.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 v{u}int*_t with lmul=1 will be coverred int another PATCH. Signed-off-by: Pan Li <pan2.li@intel.com> gcc/ChangeLog: * config/riscv/genrvv-type-indexer.cc (BOOL_SIZE_LIST): Add the rest bool size, aka 2, 4, 8, 16, 32, 64. * config/riscv/riscv-vector-builtins-functions.def (vreinterpret): Register vbool[2|4|8|16|32|64] interpret function. * config/riscv/riscv-vector-builtins-types.def (DEF_RVV_BOOL2_INTERPRET_OPS): New macro for vbool2_t. (DEF_RVV_BOOL4_INTERPRET_OPS): Likewise. (DEF_RVV_BOOL8_INTERPRET_OPS): Likewise. (DEF_RVV_BOOL16_INTERPRET_OPS): Likewise. (DEF_RVV_BOOL32_INTERPRET_OPS): Likewise. (DEF_RVV_BOOL64_INTERPRET_OPS): Likewise. (vint8m1_t): Add the type to bool[2|4|8|16|32|64]_interpret_ops. (vint16m1_t): Likewise. (vint32m1_t): Likewise. (vint64m1_t): Likewise. (vuint8m1_t): Likewise. (vuint16m1_t): Likewise. (vuint32m1_t): Likewise. (vuint64m1_t): Likewise. * config/riscv/riscv-vector-builtins.cc (DEF_RVV_BOOL2_INTERPRET_OPS): New macro for vbool2_t. (DEF_RVV_BOOL4_INTERPRET_OPS): Likewise. (DEF_RVV_BOOL8_INTERPRET_OPS): Likewise. (DEF_RVV_BOOL16_INTERPRET_OPS): Likewise. (DEF_RVV_BOOL32_INTERPRET_OPS): Likewise. (DEF_RVV_BOOL64_INTERPRET_OPS): Likewise. (required_extensions_p): Add vbool[2|4|8|16|32|64] interpret case. * config/riscv/riscv-vector-builtins.def (bool2_interpret): Add vbool2_t interprect to base type. (bool4_interpret): Likewise. (bool8_interpret): Likewise. (bool16_interpret): Likewise. (bool32_interpret): Likewise. (bool64_interpret): Likewise. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/misc_vreinterpret_vbool_vint.c: Add test cases for vbool[2|4|8|16|32|64]_t.
2023-05-21Fix PR 109919: ICE in emit_move_insn with some bit testsAndrew Pinski2-1/+10
The problem is I used expand_expr with the target but we don't want to use the target here as it is the wrong mode for the original expression. The testcase would ICE deap down while trying to do a move to use the target. Anyways just calling expand_expr with NULL_EXPR fixes the issue. Committed as obvious after a bootstrap/test on x86_64-linux-gnu. PR middle-end/109919 gcc/ChangeLog: * expr.cc (expand_single_bit_test): Don't use the target for expand_expr. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/pr109919-1.c: New test.
2023-05-21Daily bump.GCC Administrator3-1/+99
2023-05-21install.texi: Remove alpha*-*-* sectionGerald Pfeifer1-11/+0
gcc/ChangeLog: * doc/install.texi (Specific): Remove de facto empty alpha*-*-* section.
2023-05-20Mode-Switching: Fix local array maybe uninitialized warningPan Li1-2/+2
There are 2 local array in function optimize_mode_switching. It will be initialized conditionally at the beginning but then always consumed in another loop. It may trigger the warning maybe-uninitialized, and may result in build failure when enable werror, aka warning as error. This patch will initialize the local array to zero explictly when declaration. Signed-off-by: Pan Li <pan2.li@intel.com> gcc/ChangeLog: * mode-switching.cc (entity_map): Initialize the array to zero. (bb_info): Ditto.
2023-05-20target/105753: Fix ICE in add_clobbers due to extra PARALLEL in insn.Triffid Hunter2-62/+77
This patch removes the superfluous parallel in [u]divmod patterns in the AVR backend. Effect of extra parallel is that add_clobbers reaches gcc_unreachable() because the clobbers for [u]divmod are missing. If an insn has multiple parts like clobbers, the parallel around the parts of the insn pattern is implicit. gcc/ PR target/105753 * config/avr/avr.md (divmodpsi, udivmodpsi, divmodsi, udivmodsi): Remove superfluous "parallel" in insn pattern. ([u]divmod<mode>4): Tidy code. Use gcc_unreachable() instead of printing error text to assembly. gcc/testsuite/ PR target/105753 * gcc.target/avr/torture/pr105753.c: New test.
2023-05-20Expand directly for single bit testAndrew Pinski1-35/+28
Instead of using creating trees to the expansion, just expand directly which makes the code a little simplier but also reduces how much GC memory will be used during the expansion. gcc/ChangeLog: * expr.cc (fold_single_bit_test): Rename to ... (expand_single_bit_test): This and expand directly. (do_store_flag): Update for the rename function.
2023-05-20Use BIT_FIELD_REF inside fold_single_bit_testAndrew Pinski1-11/+10
Instead of depending on combine to do the extraction, Let's create a tree which will expand directly into the extraction. This improves code generation on some targets. gcc/ChangeLog: * expr.cc (fold_single_bit_test): Use BIT_FIELD_REF instead of shift/and.
2023-05-20Simplify fold_single_bit_test with respect to codeAndrew Pinski1-55/+53
Since we know that fold_single_bit_test is now only passed NE_EXPR or EQ_EXPR, we can simplify it and just use a gcc_assert to assert that is the code that is being passed. gcc/ChangeLog: * expr.cc (fold_single_bit_test): Add an assert and simplify based on code being NE_EXPR or EQ_EXPR.
2023-05-20Simplify fold_single_bit_test slightlyAndrew Pinski1-12/+10
Now the only use of fold_single_bit_test is in do_store_flag, we can change it such that to pass the inner arg and bitnum instead of building a tree. There is no code generation changes due to this change, only a decrease in GC memory that is produced during expansion. gcc/ChangeLog: * expr.cc (fold_single_bit_test): Take inner and bitnum instead of arg0 and arg1. Update the code. (do_store_flag): Don't create a tree when calling fold_single_bit_test instead just call it with the bitnum and the inner tree.
2023-05-20Use get_def_for_expr in fold_single_bit_testAndrew Pinski1-5/+6
The code in fold_single_bit_test, checks if the inner was a right shift and improve the bitnum based on that. But since the inner will always be a SSA_NAME at this point, the code is dead. Move it over to use the helper function get_def_for_expr instead. gcc/ChangeLog: * expr.cc (fold_single_bit_test): Use get_def_for_expr instead of checking the inner's code.