[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 anlauf at gcc dot gnu.org changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #15 from anlauf at gcc dot gnu.org --- Fixed on mainline for gcc-12, and on 11- and 10-branch. Closing. Thanks for the report!
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 --- Comment #14 from CVS Commits --- The releases/gcc-10 branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:1f49f2ad78360ea6634deca9a8cc35f9c4f1051d commit r10-10334-g1f49f2ad78360ea6634deca9a8cc35f9c4f1051d Author: Harald Anlauf Date: Sat Nov 27 21:43:52 2021 +0100 Fortran: improve expansion of constant array expressions within constructors gcc/fortran/ChangeLog: PR fortran/102787 * array.c (expand_constructor): When encountering a constant array expression or array section within a constructor, simplify it to enable better expansion. gcc/testsuite/ChangeLog: * gfortran.dg/array_constructor_54.f90: New test. (cherry picked from commit 6b8ecbc6d6652d061d7c72c64352d51eca2df6ca)
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 --- Comment #13 from CVS Commits --- The releases/gcc-11 branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:217d8bf22b148ebe52456a4bccfe9d725e7c68e9 commit r11-9359-g217d8bf22b148ebe52456a4bccfe9d725e7c68e9 Author: Harald Anlauf Date: Sat Nov 27 21:43:52 2021 +0100 Fortran: improve expansion of constant array expressions within constructors gcc/fortran/ChangeLog: PR fortran/102787 * array.c (expand_constructor): When encountering a constant array expression or array section within a constructor, simplify it to enable better expansion. gcc/testsuite/ChangeLog: * gfortran.dg/array_constructor_54.f90: New test. (cherry picked from commit 6b8ecbc6d6652d061d7c72c64352d51eca2df6ca)
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 --- Comment #12 from anlauf at gcc dot gnu.org --- *** Bug 103263 has been marked as a duplicate of this bug. ***
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 anlauf at gcc dot gnu.org changed: What|Removed |Added CC||gs...@t-online.de --- Comment #11 from anlauf at gcc dot gnu.org --- *** Bug 103261 has been marked as a duplicate of this bug. ***
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 --- Comment #10 from CVS Commits --- The master branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:6b8ecbc6d6652d061d7c72c64352d51eca2df6ca commit r12-5639-g6b8ecbc6d6652d061d7c72c64352d51eca2df6ca Author: Harald Anlauf Date: Sat Nov 27 21:43:52 2021 +0100 Fortran: improve expansion of constant array expressions within constructors gcc/fortran/ChangeLog: PR fortran/102787 * array.c (expand_constructor): When encountering a constant array expression or array section within a constructor, simplify it to enable better expansion. gcc/testsuite/ChangeLog: * gfortran.dg/array_constructor_54.f90: New test.
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 --- Comment #9 from anlauf at gcc dot gnu.org --- (In reply to anlauf from comment #8) > Simpler and better patch which handles array sections as well as vector > subscripts: @Bill: does this patch or the submitted one in https://gcc.gnu.org/pipermail/fortran/2021-November/057066.html fix the regression for you?
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 --- Comment #8 from anlauf at gcc dot gnu.org --- Simpler and better patch which handles array sections as well as vector subscripts: diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 6552eaf3b0c..f870c225195 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -1804,6 +1804,12 @@ expand_constructor (gfc_constructor_base base) if (empty_constructor) empty_ts = e->ts; + /* Expand constant array within array constructor. */ + if (e->expr_type == EXPR_VARIABLE && e->rank > 0 && e->ref + && e->symtree && e->symtree->n.sym + && e->symtree->n.sym->attr.flavor == FL_PARAMETER) + gfc_simplify_expr (e, 0); + if (e->expr_type == EXPR_ARRAY) { if (!expand_constructor (e->value.constructor))
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 --- Comment #7 from anlauf at gcc dot gnu.org --- Slightly improved version of the patch of comment#6: diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 6552eaf3b0c..a63a6631f59 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -1812,6 +1812,29 @@ expand_constructor (gfc_constructor_base base) continue; } + /* Expand constant array within array constructor. */ + if (e->expr_type == EXPR_VARIABLE && e->rank && e->ref + && e->symtree && e->symtree->n.sym + && e->symtree->n.sym->attr.flavor == FL_PARAMETER + && e->symtree->n.sym->value + && e->symtree->n.sym->value->value.constructor) + { + gfc_array_ref *ar; + ar = gfc_find_array_ref (e); + if (ar && ar->as && ar->as->type == AS_EXPLICIT) + { + if (ar->type == AR_FULL) + { + gfc_expr *value = e->symtree->n.sym->value; + if (!expand_constructor (value->value.constructor)) + return false; + + continue; + } + /* TODO: handle ar->type == AR_SECTION. */ + } + } + empty_constructor = false; e = gfc_copy_expr (e); if (!gfc_simplify_expr (e, 1)) Still does not handle array sections.
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 --- Comment #6 from anlauf at gcc dot gnu.org --- WIP patch that fixes comment#5 as like comment#0 and regtests cleanly: diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 6552eaf3b0c..e1ab2e06fdb 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -1812,6 +1812,29 @@ expand_constructor (gfc_constructor_base base) continue; } + /* Expand constant array within array constructor. */ + if (e->expr_type == EXPR_VARIABLE && e->rank && e->ref + && e->symtree && e->symtree->n.sym + && e->symtree->n.sym->attr.flavor == FL_PARAMETER + && e->symtree->n.sym->value + && e->symtree->n.sym->value->value.constructor) + { + gfc_ref *ref; + for (ref = e->ref; ref; ref = ref->next) + if (ref->type == REF_ARRAY) + break; + + if (ref && ref->u.ar.as && ref->u.ar.as->type == AS_EXPLICIT + && ref->u.ar.type == AR_FULL) + { + gfc_expr *value = e->symtree->n.sym->value; + if (!expand_constructor (value->value.constructor)) + return false; + + continue; + } + } + empty_constructor = false; e = gfc_copy_expr (e); if (!gfc_simplify_expr (e, 1)) It only lacks goodies such as array sections in the constructor.
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 --- Comment #5 from anlauf at gcc dot gnu.org --- Looks like an issue with simplification of array within array constructor: print *, - a print *, - [a] print *, - [[a]] end -fdump-fortran-original produces: code: WRITE UNIT=6 FMT=-1 TRANSFER (/ -2 /) DT_END WRITE UNIT=6 FMT=-1 TRANSFER (/ (/ -2 /) /) DT_END WRITE UNIT=6 FMT=-1 TRANSFER (/ -2 /) DT_END -fdump-tree-original confirms this.
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 Dominique d'Humieres changed: What|Removed |Added Status|ASSIGNED|NEW
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 Dominique d'Humieres changed: What|Removed |Added Ever confirmed|0 |1 Last reconfirmed||2021-10-16 Status|UNCONFIRMED |ASSIGNED --- Comment #4 from Dominique d'Humieres --- Confirmed on Darwin too.
[Bug fortran/102787] ICE in new test case gfortran.dg/reshape_shape_2.f90
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102787 Andrew Pinski changed: What|Removed |Added Summary|[12 regression] ICE in new |ICE in new test case |test case |gfortran.dg/reshape_shape_2 |gfortran.dg/reshape_shape_2 |.f90 |.f90| --- Comment #3 from Andrew Pinski --- Note I don't think this is a regression as the testcase was ICEing before.