[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] git commit correction erreur gimplify
https://gcc.gnu.org/g:0f4d403799290b81652e9649229aba1ece495c94 commit 0f4d403799290b81652e9649229aba1ece495c94 Author: Mikael Morin Date: Wed Feb 12 09:52:09 2025 +0100 git commit correction erreur gimplify Diff: --- gcc/gimplify.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index e81a1dc5522e..73f558eb634e 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -6840,7 +6840,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, if (TREE_CODE (*to_p) == NON_LVALUE_EXPR) { - error ("non-lvalue %qE used as lhs", *to_p); + error ("non-lvalue used as lhs in %qD", *expr_p); return GS_ERROR; }
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Ajout surcharge gfc_conv_descriptor_type_set
https://gcc.gnu.org/g:18adfe80069d2541a5f3550eef2b51881ec15cde commit 18adfe80069d2541a5f3550eef2b51881ec15cde Author: Mikael Morin Date: Wed Feb 12 10:22:42 2025 +0100 Ajout surcharge gfc_conv_descriptor_type_set Diff: --- gcc/fortran/trans-array.cc | 41 + 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 19c6768cc66e..051ccafe9807 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -261,6 +261,15 @@ get_field (tree desc, unsigned field_idx) return field; } +tree +get_dtype_subfield (tree desc, unsigned subfield) +{ + tree dtype = get_field (desc, DTYPE_FIELD); + tree field = gfc_advance_chain (TYPE_FIELDS (TREE_TYPE (dtype)), subfield); + gcc_assert (field != NULL_TREE); + return field; +} + tree get_component (tree desc, unsigned field_idx) { @@ -518,6 +527,14 @@ conv_type_set (stmtblock_t *block, tree desc, tree value) fold_convert_loc (loc, TREE_TYPE (t), value)); } +void +conv_type_set (stmtblock_t *block, tree desc, int value) +{ + tree field = get_dtype_subfield (desc, GFC_DTYPE_TYPE); + tree val = build_int_cst (TREE_TYPE (field), value); + conv_type_set (block, desc, val); +} + tree get_dimensions (tree desc) { @@ -870,6 +887,12 @@ gfc_conv_descriptor_type_set (stmtblock_t *block, tree desc, tree value) gfc_descriptor::conv_type_set (block, desc, value); } +void +gfc_conv_descriptor_type_set (stmtblock_t *block, tree desc, int value) +{ + gfc_descriptor::conv_type_set (block, desc, value); +} + tree gfc_conv_descriptor_token_get (tree desc) { @@ -2536,7 +2559,6 @@ gfc_set_gfc_from_cfi (stmtblock_t *unconditional_block, ctype = fold_build2_loc (input_location, BIT_AND_EXPR, TREE_TYPE (ctype), ctype, build_int_cst (TREE_TYPE (ctype), CFI_type_mask)); - tree type = gfc_conv_descriptor_type_get (gfc); /* if (CFI_type_cptr) BT_VOID else BT_UNKNOWN */ /* Note: BT_VOID is could also be CFI_type_funcptr, but assume c_ptr. */ @@ -2545,13 +2567,11 @@ gfc_set_gfc_from_cfi (stmtblock_t *unconditional_block, stmtblock_t set_void; gfc_init_block (&set_void); - tree void_value = build_int_cst (TREE_TYPE (type), BT_VOID); - gfc_conv_descriptor_type_set (&set_void, gfc, void_value); + gfc_conv_descriptor_type_set (&set_void, gfc, BT_VOID); stmtblock_t set_unknown; gfc_init_block (&set_unknown); - tree unknown_value = build_int_cst (TREE_TYPE (type), BT_UNKNOWN); - gfc_conv_descriptor_type_set (&set_unknown, gfc, unknown_value); + gfc_conv_descriptor_type_set (&set_unknown, gfc, BT_UNKNOWN); tree tmp2 = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, gfc_finish_block (&set_void), @@ -2563,8 +2583,7 @@ gfc_set_gfc_from_cfi (stmtblock_t *unconditional_block, CFI_type_struct)); stmtblock_t set_derived; gfc_init_block (&set_derived); - tree derived_value = build_int_cst (TREE_TYPE (type), BT_DERIVED); - gfc_conv_descriptor_type_set (&set_derived, gfc, derived_value); + gfc_conv_descriptor_type_set (&set_derived, gfc, BT_DERIVED); tmp2 = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, gfc_finish_block (&set_derived), tmp2); @@ -2576,8 +2595,7 @@ gfc_set_gfc_from_cfi (stmtblock_t *unconditional_block, CFI_type_Character)); stmtblock_t set_character; gfc_init_block (&set_character); - tree character_value = build_int_cst (TREE_TYPE (type), BT_CHARACTER); - gfc_conv_descriptor_type_set (&set_character, gfc, character_value); + gfc_conv_descriptor_type_set (&set_character, gfc, BT_CHARACTER); tmp2 = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, gfc_finish_block (&set_character), tmp2); @@ -2591,7 +2609,7 @@ gfc_set_gfc_from_cfi (stmtblock_t *unconditional_block, build_int_cst (TREE_TYPE (tmp), CFI_type_ucs4_char)); gfc_init_block (&set_character); - gfc_conv_descriptor_type_set (&set_character, gfc, character_value); + gfc_conv_descriptor_type_set (&set_character, gfc, BT_CHARACTER); tmp2 = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, gfc_finish_block (&set_character), tmp2); @@ -2601,8 +2619,7 @@ gfc_set_gfc_from_cfi (stmtblock_t *unconditional_block, CFI_type_Complex)); stmtblock_t set_complex; gfc_init_block (&set_complex); - tree complex_value = build_int_cst (TREE_TYPE (type), BT_COMPLEX); - gfc_conv_descriptor_type_set (&set_complex,
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction erreurs non-lvalue lhs pr113363.f90
https://gcc.gnu.org/g:e10f6194f7c040a6254a1712999fafda5b7394b0 commit e10f6194f7c040a6254a1712999fafda5b7394b0 Author: Mikael Morin Date: Wed Feb 12 10:47:31 2025 +0100 Correction erreurs non-lvalue lhs pr113363.f90 Diff: --- gcc/fortran/trans-decl.cc | 21 + gcc/fortran/trans.cc | 4 ++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index 450a30871577..b3ebc056e4cf 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -5113,10 +5113,23 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) if (!sym->attr.dummy || sym->attr.intent == INTENT_OUT) { /* Nullify when entering the scope. */ - tmp = fold_build2_loc (input_location, MODIFY_EXPR, -TREE_TYPE (se.expr), se.expr, -fold_convert (TREE_TYPE (se.expr), - null_pointer_node)); + if (sym->ts.type == BT_CLASS + && (CLASS_DATA (sym)->attr.dimension + || CLASS_DATA (sym)->attr.codimension)) + { + stmtblock_t nullify; + gfc_init_block (&nullify); + gfc_conv_descriptor_data_set (&nullify, descriptor, + null_pointer_node); + tmp = gfc_finish_block (&nullify); + } + else + { + tmp = fold_build2_loc (input_location, MODIFY_EXPR, +TREE_TYPE (se.expr), se.expr, +fold_convert (TREE_TYPE (se.expr), + null_pointer_node)); + } if (sym->attr.optional) { tree present = gfc_conv_expr_present (sym); diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index e7cccb6b0bca..f0ad42c92ead 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1737,7 +1737,7 @@ gfc_finalize_tree_expr (gfc_se *se, gfc_symbol *derived, gfc_call_free (data_ptr), build_empty_stmt (input_location)); gfc_add_expr_to_block (&se->loop->post, tmp); - gfc_add_modify (&se->loop->post, data_ptr, data_null); + gfc_conv_descriptor_data_set (&se->loop->post, desc, data_null); } else { @@ -1751,7 +1751,7 @@ gfc_finalize_tree_expr (gfc_se *se, gfc_symbol *derived, gfc_call_free (data_ptr), build_empty_stmt (input_location)); gfc_add_expr_to_block (&se->finalblock, tmp); - gfc_add_modify (&se->finalblock, data_ptr, data_null); + gfc_conv_descriptor_data_set (&se->finalblock, desc, data_null); } } }
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction non_lvalue PR97046.f90
https://gcc.gnu.org/g:053373044075a110eb210a6d2c57ec492647d49a commit 053373044075a110eb210a6d2c57ec492647d49a Author: Mikael Morin Date: Wed Feb 12 10:07:40 2025 +0100 Correction non_lvalue PR97046.f90 Diff: --- gcc/fortran/trans-array.cc | 42 +++--- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 7072927a30be..19c6768cc66e 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -2556,24 +2556,31 @@ gfc_set_gfc_from_cfi (stmtblock_t *unconditional_block, tree tmp2 = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, gfc_finish_block (&set_void), gfc_finish_block (&set_unknown)); + /* if (CFI_type_struct) BT_DERIVED else < tmp2 > */ cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, ctype, build_int_cst (TREE_TYPE (ctype), CFI_type_struct)); - tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node, type, -build_int_cst (TREE_TYPE (type), BT_DERIVED)); + stmtblock_t set_derived; + gfc_init_block (&set_derived); + tree derived_value = build_int_cst (TREE_TYPE (type), BT_DERIVED); + gfc_conv_descriptor_type_set (&set_derived, gfc, derived_value); tmp2 = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, - tmp, tmp2); + gfc_finish_block (&set_derived), tmp2); + /* if (CFI_type_Character) BT_CHARACTER else < tmp2 > */ /* Note: this is kind=1, CFI_type_ucs4_char is handled in the 'else if' before (see below, as generated bottom up). */ cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, ctype, build_int_cst (TREE_TYPE (ctype), CFI_type_Character)); - tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node, type, -build_int_cst (TREE_TYPE (type), BT_CHARACTER)); + stmtblock_t set_character; + gfc_init_block (&set_character); + tree character_value = build_int_cst (TREE_TYPE (type), BT_CHARACTER); + gfc_conv_descriptor_type_set (&set_character, gfc, character_value); tmp2 = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, - tmp, tmp2); + gfc_finish_block (&set_character), tmp2); + /* if (CFI_type_ucs4_char) BT_CHARACTER else < tmp2 > */ /* Note: gfc->elem_len = cfi->elem_len/4. */ /* However, assuming that CFI_type_ucs4_char cannot be recovered, leave @@ -2583,18 +2590,22 @@ gfc_set_gfc_from_cfi (stmtblock_t *unconditional_block, cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, tmp, build_int_cst (TREE_TYPE (tmp), CFI_type_ucs4_char)); - tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node, type, -build_int_cst (TREE_TYPE (type), BT_CHARACTER)); + gfc_init_block (&set_character); + gfc_conv_descriptor_type_set (&set_character, gfc, character_value); tmp2 = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, - tmp, tmp2); + gfc_finish_block (&set_character), tmp2); + /* if (CFI_type_Complex) BT_COMPLEX + cfi->elem_len/2 else < tmp2 > */ cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, ctype, build_int_cst (TREE_TYPE (ctype), CFI_type_Complex)); - tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node, type, -build_int_cst (TREE_TYPE (type), BT_COMPLEX)); + stmtblock_t set_complex; + gfc_init_block (&set_complex); + tree complex_value = build_int_cst (TREE_TYPE (type), BT_COMPLEX); + gfc_conv_descriptor_type_set (&set_complex, gfc, complex_value); tmp2 = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, - tmp, tmp2); + gfc_finish_block (&set_complex), tmp2); + /* if (CFI_type_Integer || CFI_type_Logical || CFI_type_Real) ctype else*/ cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, ctype, @@ -2610,10 +2621,11 @@ gfc_set_gfc_from_cfi (stmtblock_t *unconditional_block, CFI_type_Real)); cond = fold_build2_loc (input_location, TRUTH_OR_EXPR, boolean_type_node, cond, tmp); - tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node, -
[gcc r13-9373] AArch64: Fix GCC 13 backport of big.Little CPU detection [PR118800]
https://gcc.gnu.org/g:fa5aedd841105329b2f65cb0ff418cb4427f255e commit r13-9373-gfa5aedd841105329b2f65cb0ff418cb4427f255e Author: Tamar Christina Date: Wed Feb 12 10:38:21 2025 + AArch64: Fix GCC 13 backport of big.Little CPU detection [PR118800] On the GCC-13 branch the backport caused a failure due to the branch not having generic-armv8-a and also it still treating the generic cpu special. This made it return NULL when trying to find the default CPU. In GCC 13 we still had multiple structures with the same information and in this case aarch64_cpu_data was missing the generic CPU which is in all_cores. This corrects it by using "generc" instead and also adding it to aarch64_cpu_data. gcc/ChangeLog: PR target/118800 * config/aarch64/driver-aarch64.cc (DEFAULT_CPU): Use generic instead of generic-armv8-a. (aarch64_cpu_data): Add generic. gcc/testsuite/ChangeLog: PR target/118800 * gcc.target/aarch64/cpunative/native_cpu_34.c: Update order. Diff: --- gcc/config/aarch64/driver-aarch64.cc | 3 ++- gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_34.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/aarch64/driver-aarch64.cc b/gcc/config/aarch64/driver-aarch64.cc index ff4660f469cd..acc44536629e 100644 --- a/gcc/config/aarch64/driver-aarch64.cc +++ b/gcc/config/aarch64/driver-aarch64.cc @@ -60,7 +60,7 @@ struct aarch64_core_data #define ALL_VARIANTS ((unsigned)-1) /* Default architecture to use if -mcpu=native did not detect a known CPU. */ #define DEFAULT_ARCH "8A" -#define DEFAULT_CPU "generic-armv8-a" +#define DEFAULT_CPU "generic" #define AARCH64_CORE(CORE_NAME, CORE_IDENT, SCHED, ARCH, FLAGS, COSTS, IMP, PART, VARIANT) \ { CORE_NAME, #ARCH, IMP, PART, VARIANT, feature_deps::cpu_##CORE_IDENT }, @@ -68,6 +68,7 @@ struct aarch64_core_data static CONSTEXPR const aarch64_core_data aarch64_cpu_data[] = { #include "aarch64-cores.def" + { "generic", "armv8-a", 0, 0, ALL_VARIANTS, 0}, { NULL, NULL, INVALID_IMP, INVALID_CORE, ALL_VARIANTS, 0 } }; diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_34.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_34.c index 168140002a0f..d2ff8156d8fc 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_34.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_34.c @@ -7,6 +7,6 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\+sve2\n} } } */ +/* { dg-final { scan-assembler {\.arch armv8-a\+crc\+dotprod\+crypto\+sve2\n} } } */ /* Test a normal looking procinfo. */
[gcc r15-7491] vect: Set counts of early break exit blocks correctly [PR117790]
https://gcc.gnu.org/g:cfdb961588ba318a78e995d2e2cde43130acd993 commit r15-7491-gcfdb961588ba318a78e995d2e2cde43130acd993 Author: Alex Coplan Date: Tue Nov 26 17:48:14 2024 + vect: Set counts of early break exit blocks correctly [PR117790] This adds missing code to correctly set the counts of the exit blocks we create when building the CFG for a vectorized early break loop. gcc/ChangeLog: PR tree-optimization/117790 * tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg): Set profile counts for {main,alt}_loop_exit_block. Diff: --- gcc/tree-vect-loop-manip.cc | 10 ++ 1 file changed, 10 insertions(+) diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index 06ca99eaab95..56a4e9a8b63f 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -1686,6 +1686,16 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop, edge loop_exit, set_immediate_dominator (CDI_DOMINATORS, new_preheader, loop->header); + + /* Fix up the profile counts of the new exit blocks. +main_loop_exit_block was created by duplicating the +preheader, so needs its count scaling according to the main +exit edge's probability. The remaining count from the +preheader goes to the alt_loop_exit_block, since all +alternative exits have been redirected there. */ + main_loop_exit_block->count = loop_exit->count (); + alt_loop_exit_block->count + = preheader->count - main_loop_exit_block->count; } /* Adjust the epilog loop PHI entry values to continue iteration.
[gcc/aoliva/heads/testme] [testsuite] adjust expectations of x86 vect-simd-clone test
The branch 'aoliva/heads/testme' was updated to point to: dec20ebfffeb... [testsuite] adjust expectations of x86 vect-simd-clone test It previously pointed to: 89bc8c7a9b8e... [testsuite] adjust expectations of x86 vect-simd-clone test Diff: !!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST): --- 89bc8c7... [testsuite] adjust expectations of x86 vect-simd-clone test Summary of changes (added commits): --- dec20eb... [testsuite] adjust expectations of x86 vect-simd-clone test
[gcc(refs/users/aoliva/heads/testme)] [testsuite] adjust expectations of x86 vect-simd-clone tests
https://gcc.gnu.org/g:dec20ebfffeba351ea9dd58979f4640fc2406083 commit dec20ebfffeba351ea9dd58979f4640fc2406083 Author: Alexandre Oliva Date: Tue Feb 11 00:13:43 2025 -0300 [testsuite] adjust expectations of x86 vect-simd-clone tests Some vect-simd-clone tests fail when targeting ancient x86 variants, because the expected transformations only take place with -msse4 or higher. So arrange for these tests to take an -msse4 option on x86, so that the expected vectorization takes place, but decay to a compile test if vect.exp would enable execution but the target doesn't have an sse4 runtime. This requires the new dg-do-if to override the action on a target while retaining the default action on others, instead of disabling the test. We can count on avx512f compile-time support for these tests, because vect_simd_clones requires that on x86, and that implies sse4 support, so we need not complicate the scan conditionals with tests for sse4, except on the last test. for gcc/ChangeLog * doc/sourcebuild.texi (dg-do-if): Document. for gcc/testsuite/ChangeLog * lib/target-supports-dg.exp (dg-do-if): New. * gcc.dg/vect/vect-simd-clone-16f.c: Use -msse4 on x86, and skip in case execution is enabled but the runtime isn't. * gcc.dg/vect/vect-simd-clone-17f.c: Likewise. * gcc.dg/vect/vect-simd-clone-18f.c: Likewise. * gcc.dg/vect/vect-simd-clone-20.c: Likewise, but only skip the scan test. Diff: --- gcc/doc/sourcebuild.texi| 5 + gcc/testsuite/gcc.dg/vect/vect-simd-clone-16f.c | 2 ++ gcc/testsuite/gcc.dg/vect/vect-simd-clone-17f.c | 2 ++ gcc/testsuite/gcc.dg/vect/vect-simd-clone-18f.c | 2 ++ gcc/testsuite/gcc.dg/vect/vect-simd-clone-20.c | 6 +++-- gcc/testsuite/lib/target-supports-dg.exp| 29 + 6 files changed, 44 insertions(+), 2 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 98ede70f23c0..255d1a451e44 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -1128,6 +1128,11 @@ by the specified floating-point factor. @subsubsection Skip a test for some targets @table @code +@item @{ dg-do-if @var{action} @{ @var{selector} @} @} +Same as dg-do if the selector matches and the test hasn't already been +marked as unsupported. Use it to override an action on a target while +leaving the default action alone for other targets. + @item @{ dg-skip-if @var{comment} @{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]] @} Arguments @var{include-opts} and @var{exclude-opts} are lists in which each element is a string of zero or more GCC options. diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-16f.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-16f.c index 7cd29e894d05..bb3b081b0e3d 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-16f.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-16f.c @@ -1,5 +1,7 @@ +/* { dg-do-if compile { target { sse2_runtime && { ! sse4_runtime } } } } */ /* { dg-require-effective-target vect_simd_clones } */ /* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-msse4" { target sse4 } } */ /* { dg-additional-options "-mavx" { target avx_runtime } } */ /* { dg-additional-options "-mno-avx512f" { target { { i?86*-*-* x86_64-*-* } && { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-17f.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-17f.c index 177521dc4453..504465614c98 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-17f.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-17f.c @@ -1,5 +1,7 @@ +/* { dg-do-if compile { target { sse2_runtime && { ! sse4_runtime } } } } */ /* { dg-require-effective-target vect_simd_clones } */ /* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-msse4" { target sse4 } } */ /* { dg-additional-options "-mavx" { target avx_runtime } } */ /* { dg-additional-options "-mno-avx512f" { target { { i?86*-*-* x86_64-*-* } && { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-18f.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-18f.c index 4dd51381d73c..0c418d432482 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-18f.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-18f.c @@ -1,5 +1,7 @@ +/* { dg-do-if compile { target { sse2_runtime && { ! sse4_runtime } } } } */ /* { dg-require-effective-target vect_simd_clones } */ /* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-msse4" { target sse4 } } */ /* { dg-additional-options "-mavx" { target avx_runtime } } */ /* { dg-additional-options "-mno-avx512f" { target { { i?86*-*-* x86_64-*-* } && { ! lp64 } } } } */ diff --git a/gcc/tests
[gcc(refs/users/aoliva/heads/testme)] [testsuite] add x86 effective target
https://gcc.gnu.org/g:b9e7c101eafcefb4c5a3b70e18f25ac92a01f0ae commit b9e7c101eafcefb4c5a3b70e18f25ac92a01f0ae Author: Alexandre Oliva Date: Tue Feb 11 00:13:43 2025 -0300 [testsuite] add x86 effective target I got tired of repeating the conditional that recognizes ia32 or x86_64, and introduced 'x86' as a shorthand for that, adjusting all occurrences in target-supports.exp, to set an example. I found some patterns that recognized i?86* and x86_64*, but I took those as likely cut&pastos instead of trying to preserve those weirdnesses. for gcc/ChangeLog * doc/sourcebuild.texi: Add x86 effective target. for gcc/testsuite/ChangeLog * lib/target-supports.exp (check_effective_target_x86): New. Replace all uses of i?86-*-* and x86_64-*-* in this file. Diff: --- gcc/doc/sourcebuild.texi | 3 + gcc/testsuite/lib/target-supports.exp | 188 +- 2 files changed, 99 insertions(+), 92 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 255d1a451e44..d4e2a13dd77a 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2801,6 +2801,9 @@ Target supports the execution of @code{user_msr} instructions. @item vect_cmdline_needed Target requires a command line argument to enable a SIMD instruction set. +@item x86 +Target is ia32 or x86_64. + @item xorsign Target supports the xorsign optab expansion. diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 60e24129bd58..035f82eb86c9 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -740,7 +740,7 @@ proc check_profiling_available { test_what } { } if { $test_what == "-fauto-profile" } { - if { !([istarget i?86-*-linux*] || [istarget x86_64-*-linux*]) } { + if { !([check_effective_target_x86] && [istarget *-*-linux*]) } { verbose "autofdo only supported on linux" return 0 } @@ -2616,17 +2616,23 @@ proc remove_options_for_riscv_zvbb { flags } { return [add_options_for_riscv_z_ext zvbb $flags] } +# Return 1 if the target is ia32 or x86_64. + +proc check_effective_target_x86 { } { +if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } { + return 1 +} else { +return 0 +} +} + # Return 1 if the target OS supports running SSE executables, 0 # otherwise. Cache the result. proc check_sse_os_support_available { } { return [check_cached_effective_target sse_os_support_available { # If this is not the right target then we can skip the test. - if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } { - expr 0 - } else { - expr 1 - } + expr [check_effective_target_x86] }] } @@ -2636,7 +2642,7 @@ proc check_sse_os_support_available { } { proc check_avx_os_support_available { } { return [check_cached_effective_target avx_os_support_available { # If this is not the right target then we can skip the test. - if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } { + if { !([check_effective_target_x86]) } { expr 0 } else { # Check that OS has AVX and SSE saving enabled. @@ -2659,7 +2665,7 @@ proc check_avx_os_support_available { } { proc check_avx512_os_support_available { } { return [check_cached_effective_target avx512_os_support_available { # If this is not the right target then we can skip the test. - if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } { + if { !([check_effective_target_x86]) } { expr 0 } else { # Check that OS has AVX512, AVX and SSE saving enabled. @@ -2682,7 +2688,7 @@ proc check_avx512_os_support_available { } { proc check_sse_hw_available { } { return [check_cached_effective_target sse_hw_available { # If this is not the right target then we can skip the test. - if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } { + if { !([check_effective_target_x86]) } { expr 0 } else { check_runtime_nocache sse_hw_available { @@ -2706,7 +2712,7 @@ proc check_sse_hw_available { } { proc check_sse2_hw_available { } { return [check_cached_effective_target sse2_hw_available { # If this is not the right target then we can skip the test. - if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } { + if { !([check_effective_target_x86]) } { expr 0 } else { check_runtime_nocache sse2_hw_available { @@ -2730,7 +2736,7 @@ proc check_sse2_hw_available { } { proc check_sse4_hw_available { } { return [check_cached_effective_target sse4_hw_available { # If this is not the right target then we can skip the test. - if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } { + if { !([check_effe
[gcc r15-7498] tree-optimization/118817 - fix ICE with VN CTOR simplification
https://gcc.gnu.org/g:77d01927bd7c989d431035251a5c196fe39bcec9 commit r15-7498-g77d01927bd7c989d431035251a5c196fe39bcec9 Author: Richard Biener Date: Wed Feb 12 15:01:53 2025 +0100 tree-optimization/118817 - fix ICE with VN CTOR simplification The representation of CONSTRUCTOR nodes in VN NARY and gimple_match_op do not agree so do not attempt to marshal between them. PR tree-optimization/118817 * tree-ssa-sccvn.cc (vn_nary_simplify): Do not process CONSTRUCTOR NARY or update from CONSTRUCTOR simplified gimple_match_op. * gcc.dg/pr118817.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/pr118817.c | 14 ++ gcc/tree-ssa-sccvn.cc | 9 +++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/pr118817.c b/gcc/testsuite/gcc.dg/pr118817.c new file mode 100644 index ..6cfb424dbf4f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr118817.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef int v4si __attribute__((vector_size (sizeof(int) * 4))); + +v4si x; + +void foo (int flag) +{ + v4si tem = (v4si) { 0, 0, 0, 0 }; + if (flag) +tem = (v4si) { flag }; + x = __builtin_shufflevector (tem, tem, 0, 0, 0, 0); +} diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 06f6b0ccd724..8bb45780a981 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -2604,13 +2604,18 @@ vn_nary_build_or_lookup (gimple_match_op *res_op) tree vn_nary_simplify (vn_nary_op_t nary) { - if (nary->length > gimple_match_op::MAX_NUM_OPS) + if (nary->length > gimple_match_op::MAX_NUM_OPS + /* For CONSTRUCTOR the vn_nary_op_t and gimple_match_op representation +does not match. */ + || nary->opcode == CONSTRUCTOR) return NULL_TREE; gimple_match_op op (gimple_match_cond::UNCOND, nary->opcode, nary->type, nary->length); memcpy (op.ops, nary->op, sizeof (tree) * nary->length); tree res = vn_nary_build_or_lookup_1 (&op, false, true); - if (op.code.is_tree_code () && op.num_ops <= nary->length) + if (op.code.is_tree_code () + && op.num_ops <= nary->length + && (tree_code) op.code != CONSTRUCTOR) { nary->opcode = (tree_code) op.code; nary->length = op.num_ops;
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Factorisation set temporary descriptor
https://gcc.gnu.org/g:bcdea6ab6a4b8a0e200d143c5ec4c39ada487a41 commit bcdea6ab6a4b8a0e200d143c5ec4c39ada487a41 Author: Mikael Morin Date: Wed Feb 12 18:17:41 2025 +0100 Factorisation set temporary descriptor Diff: --- gcc/fortran/trans-array.cc | 104 + 1 file changed, 77 insertions(+), 27 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 051ccafe9807..fd6f9f56dcb1 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -3294,13 +3294,14 @@ gfc_set_loop_bounds_from_array_spec (gfc_interface_mapping * mapping, DYNAMIC is true if the caller may want to extend the array later using realloc. This prevents us from putting the array on the stack. */ -static void +static tree gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post, gfc_array_info * info, tree size, tree nelem, tree initial, bool dynamic, bool dealloc) { tree tmp; tree desc; + tree ptr = NULL_TREE; bool onstack; desc = info->descriptor; @@ -3308,7 +3309,7 @@ gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post, if (size == NULL_TREE || (dynamic && integer_zerop (size))) { /* A callee allocated array. */ - gfc_conv_descriptor_data_set (pre, desc, null_pointer_node); + ptr = null_pointer_node; onstack = false; } else @@ -3336,8 +3337,7 @@ gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post, fold_build1_loc (input_location, DECL_EXPR, TREE_TYPE (tmp), tmp)); - tmp = gfc_build_addr_expr (NULL_TREE, tmp); - gfc_conv_descriptor_data_set (pre, desc, tmp); + ptr = gfc_build_addr_expr (NULL_TREE, tmp); } else { @@ -3345,7 +3345,7 @@ gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post, if (initial == NULL_TREE) { tmp = gfc_call_malloc (pre, NULL, size); - tmp = gfc_evaluate_now (tmp, pre); + ptr = gfc_evaluate_now (tmp, pre); } else { @@ -3388,18 +3388,12 @@ gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post, build_empty_stmt (input_location)); gfc_add_expr_to_block (pre, tmp); - tmp = fold_convert (pvoid_type_node, packed); + ptr = fold_convert (pvoid_type_node, packed); } - - gfc_conv_descriptor_data_set (pre, desc, tmp); } } info->data = gfc_conv_descriptor_data_get (desc); - /* The offset is zero because we create temporaries with a zero - lower bound. */ - gfc_conv_descriptor_offset_set (pre, desc, gfc_index_zero_node); - if (dealloc && !onstack) { /* Free the temporary. */ @@ -3407,6 +3401,8 @@ gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post, tmp = gfc_call_free (tmp); gfc_add_expr_to_block (post, tmp); } + + return ptr; } @@ -3618,6 +3614,63 @@ get_class_info_from_ss (stmtblock_t * pre, gfc_ss *ss, tree *eltype, } +static void +set_temporary_descriptor (stmtblock_t *block, tree desc, tree class_src, + tree elemsize, tree data_ptr, + tree ubound[GFC_MAX_DIMENSIONS], + tree stride[GFC_MAX_DIMENSIONS], int rank, + bool callee_allocated, bool rank_changer) +{ + tree class_expr = NULL_TREE; + int n; + + if (!class_expr) +{ + /* Fill in the array dtype. */ + gfc_conv_descriptor_dtype_set (block, desc, +gfc_get_dtype (TREE_TYPE (desc))); +} + else if (rank_changer) +{ + /* For classes, we copy the whole original class descriptor to the + temporary one, so we don't need to set the individual dtype fields. +Except for the case of rank altering intrinsics for which we +generate descriptors of different rank. */ + + /* Take the dtype from the class expression. */ + tree src_data = gfc_class_data_get (class_src); + tree dtype = gfc_conv_descriptor_dtype_get (src_data); + gfc_conv_descriptor_dtype_set (block, desc, dtype); + + /* These transformational functions change the rank. */ + gfc_conv_descriptor_rank_set (block, desc, rank); +} + + /* Set the span. */ + gfc_conv_descriptor_span_set (block, desc, elemsize); + + if (!callee_allocated) +{ + for (n = 0; n < rank; n++) + { + /* Store the stride and bound components in the descriptor. */ + gfc_conv_descriptor_stride_set (block, desc, gfc_rank_cst[n], + stride[n]); + + gfc_conv_descriptor_lbound_set (bl
[gcc r15-7494] avr.opt.urls += -mcall-main
https://gcc.gnu.org/g:30dfcecddc6260970924841f222402aebfbec57d commit r15-7494-g30dfcecddc6260970924841f222402aebfbec57d Author: Georg-Johann Lay Date: Wed Feb 12 22:16:23 2025 +0100 avr.opt.urls += -mcall-main gcc/ * config/avr/avr.opt.urls: Add -mcall-main. Diff: --- gcc/config/avr/avr.opt.urls | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/config/avr/avr.opt.urls b/gcc/config/avr/avr.opt.urls index 5470fe72591c..64cf0600a36b 100644 --- a/gcc/config/avr/avr.opt.urls +++ b/gcc/config/avr/avr.opt.urls @@ -17,6 +17,9 @@ UrlSuffix(gcc/AVR-Options.html#index-mgas-isr-prologues) mn-flash= UrlSuffix(gcc/AVR-Options.html#index-mn-flash) +mcall-main +UrlSuffix(gcc/AVR-Options.html#index-mcall-main) + mskip-bug UrlSuffix(gcc/AVR-Options.html#index-mskip-bug)
[gcc(refs/users/meissner/heads/work193-bugs)] Revert changes
https://gcc.gnu.org/g:929044cf459560200db55922d9d1d66d1de77f85 commit 929044cf459560200db55922d9d1d66d1de77f85 Author: Michael Meissner Date: Wed Feb 12 15:02:28 2025 -0500 Revert changes Diff: --- gcc/config/rs6000/predicates.md | 10 +- gcc/config/rs6000/rs6000-protos.h | 17 +--- gcc/config/rs6000/rs6000.cc | 23 +- gcc/config/rs6000/rs6000.h| 10 ++ gcc/config/rs6000/rs6000.md | 24 +-- gcc/testsuite/gcc.target/powerpc/pr118541-1.c | 28 --- gcc/testsuite/gcc.target/powerpc/pr118541-2.c | 26 - gcc/testsuite/gcc.target/powerpc/pr118541-3.c | 26 - gcc/testsuite/gcc.target/powerpc/pr118541-4.c | 26 - 9 files changed, 18 insertions(+), 172 deletions(-) diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index ba8df6a7979d..647e89afb6a7 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -1466,16 +1466,8 @@ ;; Return 1 if OP is a comparison operator suitable for vector/scalar ;; comparisons that generate a 0/-1 mask (i.e. the inverse of ;; fpmask_comparison_operator). -;; -;; invert_fpmask_comparison_operator is used to form floating point conditional -;; moves on power9. The instructions that would be generated (xscmpeqdp, -;; xscmpgtdp, or xscmpgedp) will raise an error if one of the arguments is a -;; signalling NaN. Don't allow the test to be inverted if NaNs are supported -;; and the comparison is an ordered comparison. (define_predicate "invert_fpmask_comparison_operator" - (ior (match_code "ne") - (and (match_code "unlt,unle") - (match_test "flag_finite_math_only" + (match_code "ne,unlt,unle")) ;; Return 1 if OP is a comparison operation suitable for integer vector/scalar ;; comparisons that generate a -1/0 mask. diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h index ea9f267bb8e3..4619142d197b 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -114,23 +114,8 @@ extern const char *rs6000_sibcall_template (rtx *, unsigned int); extern const char *rs6000_indirect_call_template (rtx *, unsigned int); extern const char *rs6000_indirect_sibcall_template (rtx *, unsigned int); extern const char *rs6000_pltseq_template (rtx *, int); - -/* Whether we can reverse the sense of an ordered (UNLT, UNLE, UNGT, UNGE, - UNEQ, or LTGT) comairson. If we are doing floating point conditional moves - on power9 and above, we cannot convert an ordered comparison to unordered, - since the instructions (XSCMP{EQ,GT,GE}DP) that are used for conditional - moves can trap if an argument is a signalling NaN. However for normal jumps - we can reverse a comparison since we only use unordered compare instructions - which do not trap on signalling NaNs. */ - -enum reverse_cond_t { - REVERSE_COND_ORDERED_OK, - REVERSE_COND_NO_ORDERED -}; - extern enum rtx_code rs6000_reverse_condition (machine_mode, - enum rtx_code, - enum reverse_cond_t); + enum rtx_code); extern rtx rs6000_emit_eqne (machine_mode, rtx, rtx, rtx); extern rtx rs6000_emit_fp_cror (rtx_code, machine_mode, rtx); extern void rs6000_emit_sCOND (machine_mode, rtx[]); diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 563fac8eddd2..f9f9a0b931db 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -15360,25 +15360,15 @@ rs6000_print_patchable_function_entry (FILE *file, } enum rtx_code -rs6000_reverse_condition (machine_mode mode, - enum rtx_code code, - enum reverse_cond_t ordered_cmp_ok) +rs6000_reverse_condition (machine_mode mode, enum rtx_code code) { /* Reversal of FP compares takes care -- an ordered compare - becomes an unordered compare and vice versa. - - However, this is not safe for ordered comparisons (i.e. for isgreater, - etc.) starting with the power9 because ifcvt.cc will want to create a fp - cmove, and the x{s,v}cmp{eq,gt,ge}{dp,qp} instructions will trap if one of - the arguments is a signalling NaN. */ - + becomes an unordered compare and vice versa. */ if (mode == CCFPmode && (!flag_finite_math_only || code == UNLT || code == UNLE || code == UNGT || code == UNGE || code == UNEQ || code == LTGT)) -return (ordered_cmp_ok == REVERSE_COND_NO_ORDERED && !flag_finite_math_only - ? UNKNOWN - : reverse_condition_maybe_unordered (code)); +return reverse_condition_maybe_unordered (code); else return reverse_condition (code); } @@ -15990,14 +15980,11 @@ rs6000_emit_sCOND (machine_mode mode,
[gcc r15-7492] c++: add fixed test [PR101740]
https://gcc.gnu.org/g:b0cf0429bd711c2121a7d4a920d875157f19 commit r15-7492-gb0cf0429bd711c2121a7d4a920d875157f19 Author: Marek Polacek Date: Wed Feb 12 15:48:22 2025 -0500 c++: add fixed test [PR101740] Fixed by r12-3643. PR c++/101740 gcc/testsuite/ChangeLog: * g++.dg/template/dtor12.C: New test. Diff: --- gcc/testsuite/g++.dg/template/dtor12.C | 19 +++ 1 file changed, 19 insertions(+) diff --git a/gcc/testsuite/g++.dg/template/dtor12.C b/gcc/testsuite/g++.dg/template/dtor12.C new file mode 100644 index ..2c75ee03d8e5 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/dtor12.C @@ -0,0 +1,19 @@ +// PR c++/101740 + +template class T, class U> +struct Test{ +void fun(){ +T d; +d.~GG(); // #1 +} +}; + +template +struct GG {}; + +int +main () +{ + Test b; + b.fun(); +}
[gcc r15-7493] AVR: target/118806 - Add -mno-call-main to tweak running main().
https://gcc.gnu.org/g:0fa06d7fd7820e0d60fd8da381ec45175a675c80 commit r15-7493-g0fa06d7fd7820e0d60fd8da381ec45175a675c80 Author: Georg-Johann Lay Date: Sun Feb 9 10:55:20 2025 +0100 AVR: target/118806 - Add -mno-call-main to tweak running main(). On devices with very limited resources, it may be desirable to run main in a more efficient way than provided by the startup code XCALL main XJMP exit from section .init9. In AVR-LibC v2.3, that code has been moved to libmcu.a, hence symbol __call_main can be satisfied so that the respective code is no more pulled in from that library. Instead, main can be run by putting it in section .init9. The patch adds attributes noreturn and section(".init9"), and sets __call_main=0 when it encounters main(). gcc/ PR target/118806 * config/avr/avr.opt (-mcall-main): New option and... (avropt_call_main): ...variable. * config/avr/avr.cc (avr_no_call_main_p): New variable. (avr_insert_attributes) [-mno-call-main, main]: Add attributes noreturn and section(".init9") to main. Set avr_no_call_main_p. (avr_file_end) [avr_no_call_main_p]: Define symbol __call_main. * doc/invoke.texi (AVR Options) <-mno-call-main>: Document. <-mnodevicelib>: Extend explanation. Diff: --- gcc/config/avr/avr.cc | 51 ++ gcc/config/avr/avr.opt | 4 gcc/doc/invoke.texi| 34 +++-- 3 files changed, 87 insertions(+), 2 deletions(-) diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index 9bfb3785ddbd..bb00e3347206 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -230,6 +230,9 @@ bool avr_need_clear_bss_p = false; bool avr_need_copy_data_p = false; bool avr_has_rodata_p = false; +/* To track if we satisfy __call_main from AVR-LibC. */ +bool avr_no_call_main_p = false; + /* Counts how often pass avr-fuse-add has been executed. Is is kept in sync with cfun->machine->n_avr_fuse_add_executed and serves as an insn condition for shift insn splitters. */ @@ -11712,6 +11715,45 @@ avr_insert_attributes (tree node, tree *attributes) NULL, *attributes); } +#if defined WITH_AVRLIBC + if (avropt_call_main == 0 + && TREE_CODE (node) == FUNCTION_DECL + && MAIN_NAME_P (DECL_NAME (node))) +{ + const char *s_section_name = nullptr; + + if (tree a_sec = lookup_attribute ("section", *attributes)) + if (TREE_VALUE (a_sec)) + if (tree t_section_name = TREE_VALUE (TREE_VALUE (a_sec))) + if (TREE_CODE (t_section_name) == STRING_CST) + s_section_name = TREE_STRING_POINTER (t_section_name); + + bool in_init9_p = s_section_name && !strcmp (s_section_name, ".init9"); + + if (s_section_name && !in_init9_p) + { + warning (OPT_Wattributes, "% attribute on main" + " function inhibits %<-mno-call-main%>", s_section_name); + } + else + { + if (!lookup_attribute ("noreturn", *attributes)) + *attributes = tree_cons (get_identifier ("noreturn"), +NULL_TREE, *attributes); + // Put main into section .init9 so that it is executed even + // though it's not called. + if (!in_init9_p) + { + tree init9 = build_string (1 + strlen (".init9"), ".init9"); + tree arg = build_tree_list (NULL_TREE, init9); + *attributes = tree_cons (get_identifier ("section"), + arg, *attributes); + } + avr_no_call_main_p = true; + } +} // -mno-call-main +#endif // AVR-LibC + avr_handle_isr_attribute (node, attributes, "signal"); avr_handle_isr_attribute (node, attributes, "interrupt"); @@ -12311,6 +12353,15 @@ avr_file_end (void) if (avr_need_clear_bss_p) fputs (".global __do_clear_bss\n", asm_out_file); + + /* Don't let __call_main call main() and exit(). + Defining this symbol will keep the code from being pulled + in from lib.a as requested by AVR-LibC's gcrt1.S. + We invoke main() by other means: putting it in .init9. */ + + if (avr_no_call_main_p) +fputs (".global __call_main\n" + "__call_main = 0\n", asm_out_file); } diff --git a/gcc/config/avr/avr.opt b/gcc/config/avr/avr.opt index 0184b40f4e50..d22a118ad9e5 100644 --- a/gcc/config/avr/avr.opt +++ b/gcc/config/avr/avr.opt @@ -42,6 +42,10 @@ mn-flash= Target RejectNegative Joined Var(avropt_n_flash) UInteger Init(-1) This option is used internally. Set the number of 64 KiB flash segments. +mcall-main +Target Var(avropt_call_main) UInteger Init(1) +Call main and exit (default). + mskip-bug Target Mask(SKIP_BUG) This option is used internally. Indicate presence of a processor erratum. Do not skip 32-b
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Suppression code redondant initialisation descriptor temporaire
https://gcc.gnu.org/g:61b45d514d49f1e075b2cab97ffd6038c41d0c3d commit 61b45d514d49f1e075b2cab97ffd6038c41d0c3d Author: Mikael Morin Date: Wed Feb 12 18:30:17 2025 +0100 Suppression code redondant initialisation descriptor temporaire Diff: --- gcc/fortran/trans-array.cc | 21 + 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index fd6f9f56dcb1..6765034f9bd6 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -3839,7 +3839,6 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss, || (fcn_ss && fcn_ss->info && fcn_ss->info->class_container)) { tree class_data; - tree dtype; gfc_expr *expr1 = fcn_ss ? fcn_ss->info->expr : NULL; /* Pick out these transformational functions because they change the rank @@ -3894,15 +3893,7 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss, class_data = gfc_class_data_get (tmp); if (rank_changer) - { - /* Take the dtype from the class expression. */ - dtype = gfc_conv_descriptor_dtype_get (gfc_class_data_get (class_expr)); - gfc_conv_descriptor_dtype_set (pre, desc, dtype); - - /* These transformational functions change the rank. */ - gfc_conv_descriptor_rank_set (pre, desc, ss->loop->dimen); - fcn_ss->info->class_container = NULL_TREE; - } + fcn_ss->info->class_container = NULL_TREE; /* Assign the new descriptor to the _data field. This allows the vptr _copy to be used for scalarized assignment since the class @@ -3914,12 +3905,6 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss, /* Point desc to the class _data field. */ desc = class_data; } - else -{ - /* Fill in the array dtype. */ - gfc_conv_descriptor_dtype_set (pre, desc, -gfc_get_dtype (TREE_TYPE (desc))); -} info->descriptor = desc; size = gfc_index_one_node; @@ -4007,10 +3992,6 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss, size = NULL_TREE; } - /* Set the span. */ - tmp = fold_convert (gfc_array_index_type, elemsize); - gfc_conv_descriptor_span_set (pre, desc, tmp); - tree data_ptr = gfc_trans_allocate_array_storage (pre, post, info, size, nelem, initial, dynamic, dealloc);
[gcc(refs/users/meissner/heads/work193-bugs)] Fix PR 118541, do not generate unordered fp cmoves for IEEE compares.
https://gcc.gnu.org/g:c7c8ed0d63efced5991690ee2d48568561617825 commit c7c8ed0d63efced5991690ee2d48568561617825 Author: Michael Meissner Date: Wed Feb 12 15:20:32 2025 -0500 Fix PR 118541, do not generate unordered fp cmoves for IEEE compares. This is version 3 of the patch. In version 3, I made the following changes: 1: The new argument to rs6000_reverse_condition that says whether we should allow ordered floating point compares to be reversed is now an enumeration instead of a boolean. 2: I tried to make the code in rs6000_reverse_condition clearer. 3: I added checks in invert_fpmask_comparison_operator to prevent ordered floating point compares from being reversed unless -ffast-math. 4: I split the test cases into 4 separate tests (ordered vs. unordered compare and -O2 vs. -Ofast). In bug PR target/118541 on power9, power10, and power11 systems, for the function: extern double __ieee754_acos (double); double __acospi (double x) { double ret = __ieee754_acos (x) / 3.14; return __builtin_isgreater (ret, 1.0) ? 1.0 : ret; } GCC currently generates the following code: Power9 Power10 and Power11 == === bl __ieee754_acos bl __ieee754_acos@notoc nop plfd 0,.LC0@pcrel addis 9,2,.LC2@toc@ha xxspltidp 12,1065353216 addi 1,1,32 addi 1,1,32 lfd 0,.LC2@toc@l(9) ld 0,16(1) addis 9,2,.LC0@toc@ha fdiv 0,1,0 ld 0,16(1) mtlr 0 lfd 12,.LC0@toc@l(9)xscmpgtdp 1,0,12 fdiv 0,1,0 xxsel 1,0,12,1 mtlr 0 blr xscmpgtdp 1,0,12 xxsel 1,0,12,1 blr This is because ifcvt.c optimizes the conditional floating point move to use the XSCMPGTDP instruction. However, the XSCMPGTDP instruction will generate an interrupt if one of the arguments is a signalling NaN and signalling NaNs can generate an interrupt. The IEEE comparison functions (isgreater, etc.) require that the comparison not raise an interrupt. The following patch changes the PowerPC back end so that ifcvt.c will not change the if/then test and move into a conditional move if the comparison is one of the comparisons that do not raise an error with signalling NaNs and -Ofast is not used. If a normal comparison is used or -Ofast is used, GCC will continue to generate XSCMPGTDP and XXSEL. For the following code: double ordered_compare (double a, double b, double c, double d) { return __builtin_isgreater (a, b) ? c : d; } /* Verify normal > does generate xscmpgtdp. */ double normal_compare (double a, double b, double c, double d) { return a > b ? c : d; } with the following patch, GCC generates the following for power9, power10, and power11: ordered_compare: fcmpu 0,1,2 fmr 1,4 bnglr 0 fmr 1,3 blr normal_compare: xscmpgtdp 1,1,2 xxsel 1,4,3,1 blr I have built bootstrap compilers on big endian power9 systems and little endian power9/power10 systems and there were no regressions. Can I check this patch into the GCC trunk, and after a waiting period, can I check this into the active older branches? 2025-02-12 Michael Meissner gcc/ PR target/118541 * config/rs6000/predicates.md (invert_fpmask_comparison_operator): Do not allow UNLT and UNLE unless -ffast-math. * config/rs6000/rs6000-protos.h (enum reverse_cond_t): New enumeration. (rs6000_reverse_condition): Add argument. * config/rs6000/rs6000.cc (rs6000_reverse_condition): Do not allow ordered comparisons to be reversed for floating point conditional moves, but allow ordered comparisons to be reversed on jumps. (rs6000_emit_sCOND): Adjust rs6000_reverse_condition call. * config/rs6000/rs6000.h (REVERSE_CONDITION): Likewise. * config/rs6000/rs6000.md (reverse_branch_comparison): Name insn. Adjust rs6000_reverse_condition calls. gcc/testsuite/ PR target/118541 * gcc.target/powerpc/pr118541-1.c: New test.
[gcc(refs/users/meissner/heads/work193-bugs)] Update ChangeLog.*
https://gcc.gnu.org/g:0ef072cfea54663d85a77c45bf1eda6984f17aad commit 0ef072cfea54663d85a77c45bf1eda6984f17aad Author: Michael Meissner Date: Wed Feb 12 15:22:14 2025 -0500 Update ChangeLog.* Diff: --- gcc/ChangeLog.bugs | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog.bugs b/gcc/ChangeLog.bugs index 329d928c50d6..89e1b7ac40e4 100644 --- a/gcc/ChangeLog.bugs +++ b/gcc/ChangeLog.bugs @@ -1,9 +1,23 @@ - Branch work193-bugs, patch #211 + Branch work193-bugs, patch #212 Fix PR 118541, do not generate unordered fp cmoves for IEEE compares. This is version 3 of the patch. +In version 3, I made the following changes: + +1: The new argument to rs6000_reverse_condition that says whether we should + allow ordered floating point compares to be reversed is now an + enumeration instead of a boolean. + +2: I tried to make the code in rs6000_reverse_condition clearer. + +3: I added checks in invert_fpmask_comparison_operator to prevent ordered + floating point compares from being reversed unless -ffast-math. + +4: I split the test cases into 4 separate tests (ordered vs. unordered + compare and -O2 vs. -Ofast). + In bug PR target/118541 on power9, power10, and power11 systems, for the function: @@ -84,7 +98,7 @@ power9/power10 systems and there were no regressions. Can I check this patch into the GCC trunk, and after a waiting period, can I check this into the active older branches? -2025-02-11 Michael Meissner +2025-02-12 Michael Meissner gcc/ @@ -109,6 +123,7 @@ gcc/testsuite/ * gcc.target/powerpc/pr118541-3.c: Likewise. * gcc.target/powerpc/pr118541-4.c: Likewise. + Branch work193-bugs, patch #211 was reverted Branch work193-bugs, patch #210 was reverted Branch work193-bugs, patch #202
[gcc r15-7496] loop-invariant: Treat inline-asm conditional trapping [PR102150]
https://gcc.gnu.org/g:8598a84bf5ca91ddd26f3bf6f944b0235cfa06b4 commit r15-7496-g8598a84bf5ca91ddd26f3bf6f944b0235cfa06b4 Author: Andrew Pinski Date: Tue Feb 11 21:00:06 2025 -0800 loop-invariant: Treat inline-asm conditional trapping [PR102150] So inline-asm is known not to trap BUT it can have undefined behavior if made executed speculatively. This fixes the loop invariant pass to treat it similarly as trapping cases. If the inline-asm could be executed always, then it will be pulled out of the loop; otherwise it will be kept inside the loop. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: PR rtl-optimization/102150 * loop-invariant.cc (find_invariant_insn): Treat inline-asm similar to trapping instruction and only move them if always executed. Signed-off-by: Andrew Pinski Diff: --- gcc/loop-invariant.cc | 5 + 1 file changed, 5 insertions(+) diff --git a/gcc/loop-invariant.cc b/gcc/loop-invariant.cc index bcb52bb9c76e..236d5ee70eee 100644 --- a/gcc/loop-invariant.cc +++ b/gcc/loop-invariant.cc @@ -1123,6 +1123,11 @@ find_invariant_insn (rtx_insn *insn, bool always_reached, bool always_executed) if (may_trap_or_fault_p (PATTERN (insn)) && !always_reached) return; + /* inline-asm that is not always executed cannot be moved + as it might conditionally trap. */ + if (!always_reached && asm_noperands (PATTERN (insn)) >= 0) +return; + depends_on = BITMAP_ALLOC (NULL); if (!check_dependencies (insn, depends_on)) {
[gcc r15-7495] ifcvt: Don't speculation move inline-asm [PR102150]
https://gcc.gnu.org/g:aa972d027437784686dfc66180dc1b640e7dbb39 commit r15-7495-gaa972d027437784686dfc66180dc1b640e7dbb39 Author: Andrew Pinski Date: Tue Feb 11 15:13:07 2025 -0800 ifcvt: Don't speculation move inline-asm [PR102150] So unlike loop invariant motion, moving an inline-asm out of an if is not always profitable and the cost estimate for the instruction inside inline-asm is unknown. This is a regression from GCC 4.6 which didn't speculatively move inline-asm as far as I can tell. Bootstrapped and tested on x86_64-linux-gnu. PR rtl-optimization/102150 gcc/ChangeLog: * ifcvt.cc (cheap_bb_rtx_cost_p): Return false if the insn has an inline-asm in it. Signed-off-by: Andrew Pinski Diff: --- gcc/ifcvt.cc | 7 +++ 1 file changed, 7 insertions(+) diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc index cb5597bc171d..6d67bef41c88 100644 --- a/gcc/ifcvt.cc +++ b/gcc/ifcvt.cc @@ -166,6 +166,13 @@ cheap_bb_rtx_cost_p (const_basic_block bb, { if (NONJUMP_INSN_P (insn)) { + /* Inline-asm's cost is not very estimatable. +It could be a costly instruction but the +estimate would be the same as a non costly +instruction. */ + if (asm_noperands (PATTERN (insn)) >= 0) + return false; + int cost = insn_cost (insn, speed) * REG_BR_PROB_BASE; if (cost == 0) return false;
[gcc r14-11303] [PATCH] PR modula2/118703 Abort compiling m2pim_NumberIO_BinToStr
https://gcc.gnu.org/g:209de720fb8ad491568633780c8e8c5cca8b4c33 commit r14-11303-g209de720fb8ad491568633780c8e8c5cca8b4c33 Author: Gaius Mulley Date: Wed Feb 12 21:26:04 2025 + [PATCH] PR modula2/118703 Abort compiling m2pim_NumberIO_BinToStr This patch builds access to the gcc builtins clz, clzl, clzll, ctz, ctzl and ctzll within m2builtins.cc. The patch provides modula2 api access to clz, clzll, ctz and ctzll though the Builtins definition module. This PR was raised because of PR118689. gcc/m2/ChangeLog: PR modula2/118703 * gm2-gcc/m2builtins.cc (define_builtin_gcc): New function. (m2builtins_init): Call define_builtin_gcc. * gm2-libs/Builtins.def (clz): New procedure function. (clzll): Ditto. (ctz): Ditto. (ctzll): Ditto. * gm2-libs/Builtins.mod (clz): New procedure function. (clzll): Ditto. (ctz): Ditto. (ctzll): Ditto. * gm2-libs/cbuiltin.def (clz): New procedure function. (clzll): Ditto. (ctz): Ditto. (ctzll): Ditto. gcc/testsuite/ChangeLog: PR modula2/118703 * gm2/builtins/run/pass/testbitfns.mod: New test. (cherry picked from commit e2d32c81a993a27f3e9b5408f5d20580fe58feca) Signed-off-by: Gaius Mulley Diff: --- gcc/m2/gm2-gcc/m2builtins.cc | 36 + gcc/m2/gm2-libs/Builtins.def | 5 ++ gcc/m2/gm2-libs/Builtins.mod | 20 + gcc/m2/gm2-libs/cbuiltin.def | 11 ++- gcc/testsuite/gm2/builtins/run/pass/testbitfns.mod | 90 ++ 5 files changed, 161 insertions(+), 1 deletion(-) diff --git a/gcc/m2/gm2-gcc/m2builtins.cc b/gcc/m2/gm2-gcc/m2builtins.cc index 44f48fc01ba8..9f87871f48f7 100644 --- a/gcc/m2/gm2-gcc/m2builtins.cc +++ b/gcc/m2/gm2-gcc/m2builtins.cc @@ -375,6 +375,7 @@ static struct GTY(()) builtin_function_entry list_of_builtins[] = { BUILT_IN_NORMAL, "strchr", NULL, NULL, bf_default_lib }, { "__builtin_strrchr", BT_FN_STRING_CONST_STRING_INT, BUILT_IN_STRCHR, BUILT_IN_NORMAL, "strrchr", NULL, NULL, bf_default_lib }, + { "__builtin_frame_address", BT_FN_PTR_UNSIGNED, BUILT_IN_FRAME_ADDRESS, BUILT_IN_NORMAL, "frame_address", NULL, NULL, bf_gcc }, { "__builtin_return_address", BT_FN_PTR_UNSIGNED, BUILT_IN_RETURN_ADDRESS, @@ -426,6 +427,9 @@ static GTY (()) tree long_doubleptr_type_node; static GTY (()) tree doubleptr_type_node; static GTY (()) tree floatptr_type_node; static GTY (()) tree builtin_ftype_int_var; +static GTY (()) tree builtin_ftype_int_uint; +static GTY (()) tree builtin_ftype_int_ulong; +static GTY (()) tree builtin_ftype_int_ulonglong; static GTY (()) vec *builtin_macros; /* Prototypes for locally defined functions. */ @@ -1480,6 +1484,27 @@ define_builtin_math (enum built_in_function val, const char *name, tree type, versions as well? */ } +/* Define gcc specific builtins. */ + +static +void +define_builtin_gcc (void) +{ + /* Bit count functions. */ + define_builtin (BUILT_IN_CLZ, "clz", builtin_ftype_int_uint, + "__builtin_clz", ECF_CONST | ECF_NOTHROW | ECF_LEAF); + define_builtin (BUILT_IN_CLZL, "clzl", builtin_ftype_int_ulong, + "__builtin_clzl", ECF_CONST | ECF_NOTHROW | ECF_LEAF); + define_builtin (BUILT_IN_CLZLL, "clzll", builtin_ftype_int_ulonglong, + "__builtin_clzll", ECF_CONST | ECF_NOTHROW | ECF_LEAF); + define_builtin (BUILT_IN_CTZ, "ctz", builtin_ftype_int_uint, + "__builtin_ctz", ECF_CONST | ECF_NOTHROW | ECF_LEAF); + define_builtin (BUILT_IN_CTZL, "ctzl", builtin_ftype_int_ulong, + "__builtin_ctzl", ECF_CONST | ECF_NOTHROW | ECF_LEAF); + define_builtin (BUILT_IN_CTZLL, "ctzll", builtin_ftype_int_ulonglong, + "__builtin_ctzll", ECF_CONST | ECF_NOTHROW | ECF_LEAF); +} + void m2builtins_init (location_t location) { @@ -1516,6 +1541,15 @@ m2builtins_init (location_t location) builtin_ftype_int_var = build_function_type ( integer_type_node, tree_cons (NULL_TREE, double_type_node, endlink)); + builtin_ftype_int_uint = build_function_type ( + integer_type_node, tree_cons (NULL_TREE, unsigned_type_node, endlink)); + + builtin_ftype_int_ulong = build_function_type ( + integer_type_node, tree_cons (NULL_TREE, long_unsigned_type_node, endlink)); + + builtin_ftype_int_ulonglong = build_function_type ( + integer_type_node, tree_cons (NULL_TREE, long_long_unsigned_type_node, endlink)); + for (i = 0; list_of_builtins[i].name != NULL; i++) create_function_prototype (location, &list_of_builtins[i]); @@ -1541,6 +1575,8 @@ m2builtins_init (location_t location) define_builtin_math (BUILT_IN_ISINF_SIGN, "isinf_sign", builtin_ftype_int_var, "__builtin_isinf_sign", ECF_