[gcc r14-9505] d: Merge upstream dmd, druntime 855353a1d9
https://gcc.gnu.org/g:2d454f982914c481a268f1c63e431b2682cc3be0 commit r14-9505-g2d454f982914c481a268f1c63e431b2682cc3be0 Author: Iain Buclaw Date: Sun Mar 17 12:00:57 2024 +0100 d: Merge upstream dmd, druntime 855353a1d9 D front-end changes: - Import dmd v2.108.0-rc.1. - Add support for Named Arguments for functions. - Hex strings now convert to integer arrays. D runtime changes: - Import druntime v2.108.0-rc.1. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 855353a1d9. * dmd/VERSION: libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 855353a1d9. Diff: --- gcc/d/dmd/MERGE| 2 +- gcc/d/dmd/VERSION | 2 +- gcc/d/dmd/cxxfrontend.d| 10 +++ gcc/d/dmd/dcast.d | 31 +--- gcc/d/dmd/dinterpret.d | 2 +- gcc/d/dmd/dsymbolsem.d | 7 +- gcc/d/dmd/dtemplate.d | 48 +--- gcc/d/dmd/enum.h | 6 ++ gcc/d/dmd/expression.h | 15 gcc/d/dmd/expressionsem.d | 9 ++- gcc/d/dmd/hdrgen.d | 3 +- gcc/d/dmd/lexer.d | 1 - gcc/d/dmd/mtype.d | 17 +++-- gcc/d/dmd/mtype.h | 5 +- gcc/d/dmd/root/filename.d | 2 +- gcc/d/dmd/root/filename.h | 2 +- gcc/d/dmd/template.h | 16 +--- gcc/d/dmd/templatesem.d| 85 ++ gcc/d/dmd/typesem.d| 16 +++- .../gdc.test/compilable/named_arguments_auto_ref.d | 39 ++ .../gdc.test/compilable/named_arguments_ifti.d | 27 +++ .../gdc.test/fail_compilation/hexstring.d | 5 +- .../fail_compilation/named_arguments_error.d | 11 ++- .../fail_compilation/named_arguments_ifti_error.d | 20 + gcc/testsuite/gdc.test/runnable/literal.d | 10 ++- libphobos/libdruntime/MERGE| 2 +- .../core/internal/gc/impl/conservative/gc.d| 4 +- .../libdruntime/core/internal/gc/impl/manual/gc.d | 2 +- .../libdruntime/core/internal/gc/impl/proto/gc.d | 2 +- 29 files changed, 294 insertions(+), 107 deletions(-) diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 4c0a0bc2aac..a00872ef864 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -f8bae0455851a1dfc8113d69323415f6de549e39 +855353a1d9e16d43e85b6cf2b03aef388619bd16 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/VERSION b/gcc/d/dmd/VERSION index 416807683f5..8ca452f8912 100644 --- a/gcc/d/dmd/VERSION +++ b/gcc/d/dmd/VERSION @@ -1 +1 @@ -v2.108.0-beta.1 +v2.108.0-rc.1 diff --git a/gcc/d/dmd/cxxfrontend.d b/gcc/d/dmd/cxxfrontend.d index 8c046343468..a0432d2e1b4 100644 --- a/gcc/d/dmd/cxxfrontend.d +++ b/gcc/d/dmd/cxxfrontend.d @@ -14,6 +14,7 @@ import dmd.aggregate : AggregateDeclaration; import dmd.arraytypes; import dmd.astenums; import dmd.common.outbuffer : OutBuffer; +import dmd.denum : EnumDeclaration; import dmd.dmodule /*: Module*/; import dmd.dscope : Scope; import dmd.dstruct /*: StructDeclaration*/; @@ -213,6 +214,15 @@ void genCppHdrFiles(ref Modules ms) return dmd.dtoh.genCppHdrFiles(ms); } +/*** + * enumsem.d + */ +Expression getDefaultValue(EnumDeclaration ed, const ref Loc loc) +{ +import dmd.enumsem; +return dmd.enumsem.getDefaultValue(ed, loc); +} + /*** * expression.d */ diff --git a/gcc/d/dmd/dcast.d b/gcc/d/dmd/dcast.d index a49bd575f4b..8a713f424d6 100644 --- a/gcc/d/dmd/dcast.d +++ b/gcc/d/dmd/dcast.d @@ -629,7 +629,7 @@ MATCH implicitConvTo(Expression e, Type t) TY tyn = e.type.nextOf().ty; -if (!tyn.isSomeChar) +if (!tyn.isSomeChar && !e.hexString) return visit(e); switch (t.ty) @@ -703,6 +703,11 @@ MATCH implicitConvTo(Expression e, Type t) return MATCH.nomatch; m = MATCH.constant; } +if (e.hexString && tn.isintegral && (tn.size == e.sz || (!e.committed && (e.len % tn.size) == 0))) +{ +m = MATCH.convert; +return m; +} if (!e.committed) { switch (tn.ty) @@ -719,9 +724,6 @@ MATCH implicitConvTo(Expression e, Type t) if (e.postfix != 'd') m = MATCH.convert; return m; -
[gcc r14-9506] PR modula2/114296 ICE when attempting to create a constant set with a variable element
https://gcc.gnu.org/g:f065c582d9c8e0a4fee7ee563c584ee3b1975bea commit r14-9506-gf065c582d9c8e0a4fee7ee563c584ee3b1975bea Author: Gaius Mulley Date: Sun Mar 17 14:49:23 2024 + PR modula2/114296 ICE when attempting to create a constant set with a variable element This patch corrects the virtual token creation for the aggregate constant and also corrects tokens for constructor components. gcc/m2/ChangeLog: PR modula2/114296 * gm2-compiler/M2ALU.mod (ElementsSolved): Add tokenno parameter. Add constant checks and generate error messages. (EvalSetValues): Pass tokenno parameter to ElementsSolved. * gm2-compiler/M2LexBuf.mod (stop): New procedure. (MakeVirtualTok): Call stop if caret = BadTokenNo. * gm2-compiler/M2Quads.def (BuildNulExpression): Add tokpos parameter. (BuildSetStart): Ditto. (BuildEmptySet): Ditto. (BuildConstructorEnd): Add startpos parameter. (BuildTypeForConstructor): Add tokpos parameter. * gm2-compiler/M2Quads.mod (BuildNulExpression): Add tokpos parameter and push tokpos to the quad stack. (BuildSetStart): Add tokpos parameter and push tokpos. (BuildSetEnd): Rewrite. (BuildEmptySet): Add tokpos parameter and push tokpos with the set type. (BuildConstructorStart): Pop typepos. (BuildConstructorEnd): Add startpos parameter. Create valtok from startpos and cbratokpos. (BuildTypeForConstructor): Add tokpos parameter. * gm2-compiler/M2Range.def (InitAssignmentRangeCheck): Rename d to des and e to expr. Add destok and exprtok parameters. * gm2-compiler/M2Range.mod (InitAssignmentRangeCheck): Rename d to des and e to expr. Add destok and exprtok parameters. Save destok and exprtok into range record. (FoldAssignment): Pass exprtok to TryDeclareConstant. * gm2-compiler/P3Build.bnf (ComponentValue): Rewrite. (Constructor): Rewrite. (ConstSetOrQualidentOrFunction): Rewrite. (SetOrQualidentOrFunction): Rewrite. * gm2-compiler/PCBuild.bnf (ConstSetOrQualidentOrFunction): Rewrite. (SetOrQualidentOrFunction): Rewrite. * gm2-compiler/PHBuild.bnf (Constructor): Rewrite. (ConstSetOrQualidentOrFunction): Rewrite. gcc/testsuite/ChangeLog: PR modula2/114296 * gm2/pim/fail/badtype2.mod: New test. Signed-off-by: Gaius Mulley Diff: --- gcc/m2/gm2-compiler/M2ALU.mod | 14 +++- gcc/m2/gm2-compiler/M2LexBuf.mod| 13 +++- gcc/m2/gm2-compiler/M2Quads.def | 15 ++-- gcc/m2/gm2-compiler/M2Quads.mod | 124 ++-- gcc/m2/gm2-compiler/M2Range.def | 4 +- gcc/m2/gm2-compiler/M2Range.mod | 14 ++-- gcc/m2/gm2-compiler/P3Build.bnf | 48 - gcc/m2/gm2-compiler/PCBuild.bnf | 11 +-- gcc/m2/gm2-compiler/PHBuild.bnf | 16 +++-- gcc/testsuite/gm2/pim/fail/badtype2.mod | 9 +++ 10 files changed, 173 insertions(+), 95 deletions(-) diff --git a/gcc/m2/gm2-compiler/M2ALU.mod b/gcc/m2/gm2-compiler/M2ALU.mod index 58d4b5c24ed..cfa372671cd 100644 --- a/gcc/m2/gm2-compiler/M2ALU.mod +++ b/gcc/m2/gm2-compiler/M2ALU.mod @@ -2922,10 +2922,20 @@ END AddField ; ElementsSolved - returns TRUE if all ranges in the set have been solved. *) -PROCEDURE ElementsSolved (r: listOfRange) : BOOLEAN ; +PROCEDURE ElementsSolved (tokenno: CARDINAL; r: listOfRange) : BOOLEAN ; BEGIN WHILE r#NIL DO WITH r^ DO + IF NOT IsConst (low) + THEN +MetaErrorT1 (tokenno, 'a constant set can only contain constant set elements, {%1Ead} is not a constant', + low) + END ; + IF (high # low) AND (NOT IsConst (high)) + THEN +MetaErrorT1 (tokenno, 'a constant set can only contain constant set elements, {%1Ead} is not a constant', + high) + END ; IF NOT (IsSolvedGCC(low) AND IsSolvedGCC(high)) THEN RETURN( FALSE ) @@ -3088,7 +3098,7 @@ END CombineElements ; PROCEDURE EvalSetValues (tokenno: CARDINAL; r: listOfRange) : BOOLEAN ; BEGIN - IF ElementsSolved(r) + IF ElementsSolved (tokenno, r) THEN SortElements(tokenno, r) ; CombineElements(tokenno, r) ; diff --git a/gcc/m2/gm2-compiler/M2LexBuf.mod b/gcc/m2/gm2-compiler/M2LexBuf.mod index 8d9b5a5a6e3..df073630bc1 100644 --- a/gcc/m2/gm2-compiler/M2LexBuf.mod +++ b/gcc/m2/gm2-compiler/M2LexBuf.mod @@ -48,6 +48,7 @@ CONST Tracing= FALSE ; Debugging = FALSE ; DebugRecover = FALSE ; + BadTokenNo = 32579 ; InitialSourceToken = 2 ;
[gcc r14-9507] libstdc++: Implement N3644 on _Safe_iterator<> [PR114316]
https://gcc.gnu.org/g:07fad7a7fc245369989e9ca746728ea78b924715 commit r14-9507-g07fad7a7fc245369989e9ca746728ea78b924715 Author: François Dumont Date: Thu Mar 14 22:13:57 2024 +0100 libstdc++: Implement N3644 on _Safe_iterator<> [PR114316] Consider range of value-initialized iterators as valid and empty. libstdc++-v3/ChangeLog: PR libstdc++/114316 * include/debug/safe_iterator.tcc (_Safe_iterator<>::_M_valid_range): First check if both iterators are value-initialized before checking if singular. * testsuite/23_containers/set/debug/114316.cc: New test case. * testsuite/23_containers/vector/debug/114316.cc: New test case. Diff: --- libstdc++-v3/include/debug/safe_iterator.tcc | 12 libstdc++-v3/testsuite/23_containers/set/debug/114316.cc | 16 .../testsuite/23_containers/vector/debug/114316.cc | 16 3 files changed, 44 insertions(+) diff --git a/libstdc++-v3/include/debug/safe_iterator.tcc b/libstdc++-v3/include/debug/safe_iterator.tcc index a8b24233e85..4b2baf2980e 100644 --- a/libstdc++-v3/include/debug/safe_iterator.tcc +++ b/libstdc++-v3/include/debug/safe_iterator.tcc @@ -194,6 +194,12 @@ namespace __gnu_debug std::pair& __dist, bool __check_dereferenceable) const { + if (_M_value_initialized() && __rhs._M_value_initialized()) + { + __dist = std::make_pair(0, __dp_exact); + return true; + } + if (_M_singular() || __rhs._M_singular() || !_M_can_compare(__rhs)) return false; @@ -218,6 +224,12 @@ namespace __gnu_debug std::pair& __dist) const { + if (this->_M_value_initialized() && __rhs._M_value_initialized()) + { + __dist = std::make_pair(0, __dp_exact); + return true; + } + if (this->_M_singular() || __rhs._M_singular() || !this->_M_can_compare(__rhs)) return false; diff --git a/libstdc++-v3/testsuite/23_containers/set/debug/114316.cc b/libstdc++-v3/testsuite/23_containers/set/debug/114316.cc new file mode 100644 index 000..126ec89b5e0 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/debug/114316.cc @@ -0,0 +1,16 @@ +// { dg-do run { target c++11 } } +// { dg-require-debug-mode "" } + +// PR libstdc++/114316 + +#include +#include + +#include + +int main() +{ + std::set::iterator it{}; + VERIFY( std::find(it, it, 0) == it ); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/114316.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/114316.cc new file mode 100644 index 000..f211cf67b4c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/114316.cc @@ -0,0 +1,16 @@ +// { dg-do run { target c++11 } } +// { dg-require-debug-mode "" } + +// PR libstdc++/114316 + +#include +#include + +#include + +int main() +{ + std::vector::iterator it{}; + VERIFY( std::find(it, it, 0) == it ); + return 0; +}
[gcc r13-8460] libstdc++: Implement N3644 on _Safe_iterator<> [PR114316]
https://gcc.gnu.org/g:c1f57ff40738bbce9902ea25865ed6d729b10127 commit r13-8460-gc1f57ff40738bbce9902ea25865ed6d729b10127 Author: François Dumont Date: Thu Mar 14 22:13:57 2024 +0100 libstdc++: Implement N3644 on _Safe_iterator<> [PR114316] Consider range of value-initialized iterators as valid and empty. libstdc++-v3/ChangeLog: PR libstdc++/114316 * include/debug/safe_iterator.tcc (_Safe_iterator<>::_M_valid_range): First check if both iterators are value-initialized before checking if singular. * testsuite/23_containers/set/debug/114316.cc: New test case. * testsuite/23_containers/vector/debug/114316.cc: New test case. (cherry picked from commit 07fad7a7fc245369989e9ca746728ea78b924715) Diff: --- libstdc++-v3/include/debug/safe_iterator.tcc | 12 libstdc++-v3/testsuite/23_containers/set/debug/114316.cc | 16 .../testsuite/23_containers/vector/debug/114316.cc | 16 3 files changed, 44 insertions(+) diff --git a/libstdc++-v3/include/debug/safe_iterator.tcc b/libstdc++-v3/include/debug/safe_iterator.tcc index 170229ad2f1..2640fc8a473 100644 --- a/libstdc++-v3/include/debug/safe_iterator.tcc +++ b/libstdc++-v3/include/debug/safe_iterator.tcc @@ -194,6 +194,12 @@ namespace __gnu_debug std::pair& __dist, bool __check_dereferenceable) const { + if (_M_value_initialized() && __rhs._M_value_initialized()) + { + __dist = std::make_pair(0, __dp_exact); + return true; + } + if (_M_singular() || __rhs._M_singular() || !_M_can_compare(__rhs)) return false; @@ -218,6 +224,12 @@ namespace __gnu_debug std::pair& __dist) const { + if (this->_M_value_initialized() && __rhs._M_value_initialized()) + { + __dist = std::make_pair(0, __dp_exact); + return true; + } + if (this->_M_singular() || __rhs._M_singular() || !this->_M_can_compare(__rhs)) return false; diff --git a/libstdc++-v3/testsuite/23_containers/set/debug/114316.cc b/libstdc++-v3/testsuite/23_containers/set/debug/114316.cc new file mode 100644 index 000..126ec89b5e0 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/debug/114316.cc @@ -0,0 +1,16 @@ +// { dg-do run { target c++11 } } +// { dg-require-debug-mode "" } + +// PR libstdc++/114316 + +#include +#include + +#include + +int main() +{ + std::set::iterator it{}; + VERIFY( std::find(it, it, 0) == it ); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/114316.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/114316.cc new file mode 100644 index 000..f211cf67b4c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/114316.cc @@ -0,0 +1,16 @@ +// { dg-do run { target c++11 } } +// { dg-require-debug-mode "" } + +// PR libstdc++/114316 + +#include +#include + +#include + +int main() +{ + std::vector::iterator it{}; + VERIFY( std::find(it, it, 0) == it ); + return 0; +}
[gcc r14-9508] hppa: Fix complaint about non-delegitimized UNSPEC UNSPEC_TP
https://gcc.gnu.org/g:8064107535328717aeb78418edf778559cd5c3ac commit r14-9508-g8064107535328717aeb78418edf778559cd5c3ac Author: John David Anglin Date: Sun Mar 17 16:38:48 2024 + hppa: Fix complaint about non-delegitimized UNSPEC UNSPEC_TP 2024-03-17 John David Anglin gcc/ChangeLog: * config/pa/pa.cc (pa_delegitimize_address): Delegitimize UNSPEC_TP. Diff: --- gcc/config/pa/pa.cc | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc index 129289f8e62..5ab9eff4b5e 100644 --- a/gcc/config/pa/pa.cc +++ b/gcc/config/pa/pa.cc @@ -10707,7 +10707,13 @@ pa_trampoline_adjust_address (rtx addr) static rtx pa_delegitimize_address (rtx orig_x) { - rtx x = delegitimize_mem_from_attrs (orig_x); + rtx x; + + if (GET_CODE (orig_x) == UNSPEC + && XINT (orig_x, 1) == UNSPEC_TP) +orig_x = XVECEXP (orig_x, 0, 0); + + x = delegitimize_mem_from_attrs (orig_x); if (GET_CODE (x) == LO_SUM && GET_CODE (XEXP (x, 1)) == UNSPEC
[gcc r14-9509] Fortran: fix for absent array argument passed to optional dummy [PR101135]
https://gcc.gnu.org/g:3f3f0b7ee8022776d69ecaed1375e1559716f226 commit r14-9509-g3f3f0b7ee8022776d69ecaed1375e1559716f226 Author: Harald Anlauf Date: Fri Mar 15 20:14:07 2024 +0100 Fortran: fix for absent array argument passed to optional dummy [PR101135] gcc/fortran/ChangeLog: PR fortran/101135 * trans-array.cc (gfc_get_dataptr_offset): Check for optional arguments being present before dereferencing data pointer. gcc/testsuite/ChangeLog: PR fortran/101135 * gfortran.dg/missing_optional_dummy_6a.f90: Adjust diagnostic pattern. * gfortran.dg/ubsan/missing_optional_dummy_8.f90: New test. Diff: --- gcc/fortran/trans-array.cc | 11 +++ .../gfortran.dg/missing_optional_dummy_6a.f90 | 2 +- .../gfortran.dg/ubsan/missing_optional_dummy_8.f90 | 108 + 3 files changed, 120 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 3673fa40720..a7717a8107e 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -7526,6 +7526,17 @@ gfc_get_dataptr_offset (stmtblock_t *block, tree parm, tree desc, tree offset, /* Set the target data pointer. */ offset = gfc_build_addr_expr (gfc_array_dataptr_type (desc), tmp); + + /* Check for optional dummy argument being present. Arguments of BIND(C) + procedures are excepted here since they are handled differently. */ + if (expr->expr_type == EXPR_VARIABLE + && expr->symtree->n.sym->attr.dummy + && expr->symtree->n.sym->attr.optional + && !is_CFI_desc (NULL, expr)) +offset = build3_loc (input_location, COND_EXPR, TREE_TYPE (offset), +gfc_conv_expr_present (expr->symtree->n.sym), offset, +fold_convert (TREE_TYPE (offset), gfc_index_zero_node)); + gfc_conv_descriptor_data_set (block, parm, offset); } diff --git a/gcc/testsuite/gfortran.dg/missing_optional_dummy_6a.f90 b/gcc/testsuite/gfortran.dg/missing_optional_dummy_6a.f90 index c6a79059a91..b5e1726d74d 100644 --- a/gcc/testsuite/gfortran.dg/missing_optional_dummy_6a.f90 +++ b/gcc/testsuite/gfortran.dg/missing_optional_dummy_6a.f90 @@ -49,7 +49,7 @@ end program test ! { dg-final { scan-tree-dump-times "scalar2 \\(.* slr1" 1 "original" } } -! { dg-final { scan-tree-dump-times "= es1 != 0B" 1 "original" } } +! { dg-final { scan-tree-dump-times "= es1 != 0B" 2 "original" } } ! { dg-final { scan-tree-dump-times "assumed_shape2 \\(es1" 0 "original" } } ! { dg-final { scan-tree-dump-times "explicit_shape2 \\(es1" 1 "original" } } diff --git a/gcc/testsuite/gfortran.dg/ubsan/missing_optional_dummy_8.f90 b/gcc/testsuite/gfortran.dg/ubsan/missing_optional_dummy_8.f90 new file mode 100644 index 000..fd3914934aa --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ubsan/missing_optional_dummy_8.f90 @@ -0,0 +1,108 @@ +! { dg-do run } +! { dg-additional-options "-fdump-tree-original -fsanitize=undefined" } +! +! PR fortran/101135 - Load of null pointer when passing absent +! assumed-shape array argument for an optional dummy argument +! +! Based on testcase by Marcel Jacobse + +program main + implicit none + character(len=3) :: a(6) = ['abc', 'def', 'ghi', 'jlm', 'nop', 'qrs'] + call as () + call as (a(::2)) + call as_c () + call as_c (a(2::2)) + call test_wrapper + call test_wrapper_c + call test_ar_wrapper + call test_ar_wrapper_c +contains + subroutine as (xx) +character(len=*), optional, intent(in) :: xx(*) +if (.not. present (xx)) return +print *, xx(1:3) + end subroutine as + + subroutine as_c (zz) bind(c) +character(len=*), optional, intent(in) :: zz(*) +if (.not. present (zz)) return +print *, zz(1:3) + end subroutine as_c + + subroutine test_wrapper (x) +real, dimension(1), intent(out), optional :: x +call test (x) +call test1 (x) +call test_c (x) +call test1_c (x) + end subroutine test_wrapper + + subroutine test_wrapper_c (w) bind(c) +real, dimension(1), intent(out), optional :: w +call test (w) +call test1 (w) +call test_c (w) +call test1_c (w) + end subroutine test_wrapper_c + + subroutine test (y) +real, dimension(:), intent(out), optional :: y +if (present (y)) y=0. + end subroutine test + + subroutine test_c (y) bind(c) +real, dimension(:), intent(out), optional :: y +if (present (y)) y=0. + end subroutine test_c + + subroutine test1 (y) +real, dimension(1), intent(out), optional :: y +if (present (y)) y=0. + end subroutine test1 + + subroutine test1_c (y) bind(c) +real, dimension(1), intent(out), optional :: y +if (present (y)) y=0. + end subroutine test1_c + + subroutine test_ar_wrapper (p, q, r) +real, intent(out), optional :: p +real, dimension(1), intent(out), optional :: q +real, dimension(:), intent(out), optional :: r +call test_ar (p) +cal
[gcc r14-9511] hppa: Improve handling of REG+D addresses when generating PA 2.0 code
https://gcc.gnu.org/g:f0fda1aff0b752e4182c009c5526b9306bd35f7c commit r14-9511-gf0fda1aff0b752e4182c009c5526b9306bd35f7c Author: John David Anglin Date: Mon Mar 18 00:19:36 2024 + hppa: Improve handling of REG+D addresses when generating PA 2.0 code In looking at PR 112415, it became clear that improvements could be made in the handling of loads and stores using REG+D addresses. A change in 2002 conflated two issues: 1) We can't generate insns with 14-bit displacements before reload completes when generating PA 1.x code since floating-point loads and stores only support 5-bit offsets in PA 1.x. 2) The GNU ELF 32-bit linker lacks relocation support for PA 2.0 floating point instructions with 14-bit displacements. These relocations affect instructions with symbolic references. The result of the change was to block creation of PA 2.0 instructions with 14-bit REG_D displacements for SImode, DImode, SFmode and DFmode on the GNU linux target before reload. This was unnecessary as these instructions don't need relocation. This change revises the INT14_OK_STRICT define to allow creation of instructions with 14-bit REG+D addresses before reload when generating PA 2.0 code. 2024-03-17 John David Anglin gcc/ChangeLog: PR rtl-optimization/112415 * config/pa/pa.cc (pa_emit_move_sequence): Revise condition for symbolic memory operands. (pa_legitimate_address_p): Revise LO_SUM condition. * config/pa/pa.h (INT14_OK_STRICT): Revise define. Move comment about GNU linker to predicates.md. * config/pa/predicates.md (floating_point_store_memory_operand): Revise condition for symbolic memory operands. Update comment. Diff: --- gcc/config/pa/pa.cc | 18 -- gcc/config/pa/pa.h | 15 ++- gcc/config/pa/predicates.md | 17 +++-- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc index 5ab9eff4b5e..d7666103de8 100644 --- a/gcc/config/pa/pa.cc +++ b/gcc/config/pa/pa.cc @@ -2039,7 +2039,8 @@ pa_emit_move_sequence (rtx *operands, machine_mode mode, rtx scratch_reg) op1 = replace_equiv_address (op1, scratch_reg); } } - else if ((!INT14_OK_STRICT && symbolic_memory_operand (op1, VOIDmode)) + else if (((TARGET_ELF32 || !TARGET_PA_20) + && symbolic_memory_operand (op1, VOIDmode)) || IS_LO_SUM_DLT_ADDR_P (XEXP (op1, 0)) || IS_INDEX_ADDR_P (XEXP (op1, 0))) { @@ -2088,7 +2089,8 @@ pa_emit_move_sequence (rtx *operands, machine_mode mode, rtx scratch_reg) op0 = replace_equiv_address (op0, scratch_reg); } } - else if ((!INT14_OK_STRICT && symbolic_memory_operand (op0, VOIDmode)) + else if (((TARGET_ELF32 || !TARGET_PA_20) + && symbolic_memory_operand (op0, VOIDmode)) || IS_LO_SUM_DLT_ADDR_P (XEXP (op0, 0)) || IS_INDEX_ADDR_P (XEXP (op0, 0))) { @@ -11038,18 +11040,22 @@ pa_legitimate_address_p (machine_mode mode, rtx x, bool strict, code_helper) && (strict ? STRICT_REG_OK_FOR_BASE_P (y) : REG_OK_FOR_BASE_P (y))) { + y = XEXP (x, 1); + /* Needed for -fPIC */ if (mode == Pmode - && GET_CODE (XEXP (x, 1)) == UNSPEC) + && GET_CODE (y) == UNSPEC) return true; - if (!INT14_OK_STRICT - && (strict || !(reload_in_progress || reload_completed)) + /* Before reload, we need support for 14-bit floating +point loads and stores, and associated relocations. */ + if ((TARGET_ELF32 || !INT14_OK_STRICT) + && !reload_completed && mode != QImode && mode != HImode) return false; - if (CONSTANT_P (XEXP (x, 1))) + if (CONSTANT_P (y)) return true; } return false; diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 7abaeae269e..403f16c5cb5 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -828,19 +828,8 @@ extern int may_call_alloca; /* Nonzero if 14-bit offsets can be used for all loads and stores. This is not possible when generating PA 1.x code as floating point - accesses only support 5-bit offsets. Note that we do not forbid - the use of 14-bit offsets prior to reload. Instead, we use secondary - reloads to fix REG+D memory addresses for floating-point accesses. - - FIXME: the GNU ELF linker clobbers the LSB of the FP register number - in PA 2.0 floating-point insns with long displacements. This is - because R_PARISC_DPREL14WR and other relocations like it are not - yet supported by GNU ld. For now, we reject long displacements - on this t
[gcc r14-9512] Add missing hf/bf patterns.
https://gcc.gnu.org/g:942d470a5a4fb1baeff943127a81b441dffaa543 commit r14-9512-g942d470a5a4fb1baeff943127a81b441dffaa543 Author: liuhongt Date: Fri Mar 15 10:59:10 2024 +0800 Add missing hf/bf patterns. It will be used by copysignm3/xorsignm3/lroundmn2 expanders. gcc/ChangeLog: PR target/114334 * config/i386/i386.md (mode): Add new number V8BF,V16BF,V32BF. (MODEF248): New mode iterator. (ssevecmodesuffix): Hanlde BF and HF. * config/i386/sse.md (andnot3): Extend to HF/BF. (3): Ditto. gcc/testsuite/ChangeLog: * gcc.target/i386/pr114334.c: New test. Diff: --- gcc/config/i386/i386.md | 13 + gcc/config/i386/sse.md | 22 +++--- gcc/testsuite/gcc.target/i386/pr114334.c | 8 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index df97a2d6270..11fdc6af3fa 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -543,8 +543,9 @@ ;; Main data type used by the insn (define_attr "mode" - "unknown,none,QI,HI,SI,DI,TI,OI,XI,HF,BF,SF,DF,XF,TF,V32HF,V16HF,V8HF, - V16SF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF,V8DF,V4HF,V4BF,V2HF,V2BF" + "unknown,none,QI,HI,SI,DI,TI,OI,XI,HF,BF,SF,DF,XF,TF, + V32HF,V16HF,V8HF,V4HF,V2HF,V32BF,V16BF,V8BF,V4BF,V2BF, + V16SF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF,V8DF" (const_string "unknown")) ;; The CPU unit operations uses. @@ -1323,6 +1324,8 @@ ;; SSE and x87 SFmode and DFmode floating point modes (define_mode_iterator MODEF [SF DF]) +(define_mode_iterator MODEF248 [BF HF SF (DF "TARGET_SSE2")]) + ;; SSE floating point modes (define_mode_iterator MODEFH [(HF "TARGET_AVX512FP16") SF DF]) @@ -1347,7 +1350,8 @@ (V64QI "b") (V32HI "w") (V16SI "d") (V8DI "q")]) ;; SSE vector suffix for floating point modes -(define_mode_attr ssevecmodesuffix [(SF "ps") (DF "pd")]) +;; BF HF use same suffix as SF for logic operations. +(define_mode_attr ssevecmodesuffix [(BF "ps") (HF "ps") (SF "ps") (DF "pd")]) ;; SSE vector mode corresponding to a scalar mode (define_mode_attr ssevecmode @@ -1357,7 +1361,8 @@ ;; AVX512F vector mode corresponding to a scalar mode (define_mode_attr avx512fvecmode - [(QI "V64QI") (HI "V32HI") (SI "V16SI") (DI "V8DI") (SF "V16SF") (DF "V8DF")]) + [(QI "V64QI") (HI "V32HI") (SI "V16SI") (DI "V8DI") + (HF "V32HF") (BF "V32BF") (SF "V16SF") (DF "V8DF")]) ;; Instruction suffix for REX 64bit operators. (define_mode_attr rex64suffix [(SI "{l}") (DI "{q}")]) diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 1bc614ab702..3286d3a4fac 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -5125,12 +5125,12 @@ ;; because the native instructions read the full 128-bits. (define_insn "*andnot3" - [(set (match_operand:MODEF 0 "register_operand" "=x,x,v,v") - (and:MODEF - (not:MODEF - (match_operand:MODEF 1 "register_operand" "0,x,v,v")) - (match_operand:MODEF 2 "register_operand" "x,x,v,v")))] - "SSE_FLOAT_MODE_P (mode)" + [(set (match_operand:MODEF248 0 "register_operand" "=x,x,v,v") + (and:MODEF248 + (not:MODEF248 + (match_operand:MODEF248 1 "register_operand" "0,x,v,v")) + (match_operand:MODEF248 2 "register_operand" "x,x,v,v")))] + "TARGET_SSE" { char buf[128]; const char *ops; @@ -5257,11 +5257,11 @@ (const_string "TI")))]) (define_insn "3" - [(set (match_operand:MODEF 0 "register_operand" "=x,x,v,v") - (any_logic:MODEF - (match_operand:MODEF 1 "register_operand" "%0,x,v,v") - (match_operand:MODEF 2 "register_operand" "x,x,v,v")))] - "SSE_FLOAT_MODE_P (mode)" + [(set (match_operand:MODEF248 0 "register_operand" "=x,x,v,v") + (any_logic:MODEF248 + (match_operand:MODEF248 1 "register_operand" "%0,x,v,v") + (match_operand:MODEF248 2 "register_operand" "x,x,v,v")))] + "TARGET_SSE" { char buf[128]; const char *ops; diff --git a/gcc/testsuite/gcc.target/i386/pr114334.c b/gcc/testsuite/gcc.target/i386/pr114334.c new file mode 100644 index 000..8e38e24cd16 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr114334.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -mavx512fp16" } */ + +long +foo(_Float16 f) +{ + return __builtin_lroundf16(f); +}