[Bug tree-optimization/80293] [6/7 Regression] unnecessary code at -O2 (-O1 is fine)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80293 Jakub Jelinek changed: What|Removed |Added CC||tvrtko.ursulin at linux dot intel. ||com --- Comment #10 from Jakub Jelinek --- *** Bug 78869 has been marked as a duplicate of this bug. ***
[Bug tree-optimization/80293] [6/7 Regression] unnecessary code at -O2 (-O1 is fine)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80293 Martin Jambor changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #9 from Martin Jambor --- Fixed on trunk and backported to 7.2.
[Bug tree-optimization/80293] [6/7 Regression] unnecessary code at -O2 (-O1 is fine)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80293 --- Comment #8 from Martin Jambor --- Author: jamborm Date: Wed May 31 08:45:23 2017 New Revision: 248724 URL: https://gcc.gnu.org/viewcvs?rev=248724&root=gcc&view=rev Log: [PR 80293] Dont totally-scalarize char arrays 2017-05-31 Martin Jambor Backport from mainline 2017-04-24 Martin Jambor PR tree-optimization/80293 * tree-sra.c (scalarizable_type_p): New parameter const_decl, make char arrays not totally scalarizable if it is false. (analyze_all_variable_accesses): Pass correct value in the new parameter. Add a statistics counter. testsuite/ * g++.dg/tree-ssa/pr80293.C: New test. Added: branches/gcc-7-branch/gcc/testsuite/g++.dg/tree-ssa/pr80293.C Modified: branches/gcc-7-branch/gcc/ChangeLog branches/gcc-7-branch/gcc/testsuite/ChangeLog branches/gcc-7-branch/gcc/tree-sra.c
[Bug tree-optimization/80293] [6/7 Regression] unnecessary code at -O2 (-O1 is fine)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80293 Richard Biener changed: What|Removed |Added Known to work||7.1.1 Target Milestone|6.4 |7.2 Known to fail||6.3.1, 7.1.0
[Bug tree-optimization/80293] [6/7 Regression] unnecessary code at -O2 (-O1 is fine)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80293 Jakub Jelinek changed: What|Removed |Added CC||peter at cordes dot ca --- Comment #11 from Jakub Jelinek --- *** Bug 80837 has been marked as a duplicate of this bug. ***
[Bug tree-optimization/80293] [6/7 Regression] unnecessary code at -O2 (-O1 is fine)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80293 Richard Biener changed: What|Removed |Added Keywords||missed-optimization Priority|P3 |P2 Component|c++ |tree-optimization --- Comment #2 from Richard Biener --- (In reply to Jakub Jelinek from comment #1) > Started with r227901, the complete scalarization is not really helpful here, > and unfortunately gimple-ssa-store-merging.c only merges now adjacent > constant stores, not adjacent loads followed by adjacent stores of the > loaded values to undo the damage. > Not sure what would be easier here, if some heuristics during SRA whether > the scalarization is helpful or not, or improving gimple-ssa-store-merging.c. We have another bugreport that complains about SRA and Martin said he had patches but intended to wait for GCC 8. Improving sotre-merging is of course good anyway (the user may have written the code in the "bad" way). Note that I believe that store-merging, SRA (and bswap) are all passes that should be merged given they perform similar analyses and transforms.
[Bug tree-optimization/80293] [6/7 Regression] unnecessary code at -O2 (-O1 is fine)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80293 --- Comment #3 from Martin Jambor --- (In reply to Richard Biener from comment #2) > We have another bugreport that complains about SRA and Martin said he had > patches but intended to wait for GCC 8. My patch for PR 78687 unfortunately won't help here, that one is aimed at making the original aggregates disappear when in fact we want to leave the intermediate aggregate in a chain of assignments intact, quite the opposite of a normal mode of operation. > Note that I believe that store-merging, SRA (and bswap) are all passes that > should be merged given they perform similar analyses and transforms. Yeah, and I am (slowly) starting to look in that direction. However, with the totally flow-insensitive SRA we have meanwhile, the only remedy for this that I can think of is to throttle down total scalarization here to never produce more than, say, DECL_SIZE (candidate) / BITS_PER_WORD scalar replacements. What do you think?
[Bug tree-optimization/80293] [6/7 Regression] unnecessary code at -O2 (-O1 is fine)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80293 --- Comment #4 from Richard Biener --- (In reply to Martin Jambor from comment #3) > (In reply to Richard Biener from comment #2) > > We have another bugreport that complains about SRA and Martin said he had > > patches but intended to wait for GCC 8. > > My patch for PR 78687 unfortunately won't help here, that one is aimed > at making the original aggregates disappear when in fact we want to > leave the intermediate aggregate in a chain of assignments intact, > quite the opposite of a normal mode of operation. > > > Note that I believe that store-merging, SRA (and bswap) are all passes that > > should be merged given they perform similar analyses and transforms. > > Yeah, and I am (slowly) starting to look in that direction. > > However, with the totally flow-insensitive SRA we have meanwhile, the > only remedy for this that I can think of is to throttle down total > scalarization here to never produce more than, say, > DECL_SIZE (candidate) / BITS_PER_WORD scalar replacements. > > What do you think? Yeah, but that's not sth for GCC 7 either. Note that we did get better both in FRE and DSE so we may no longer need SRA to perform some of the optimizations [in the early pipeline]. That said, the array cases we've seen are somewhat disturbing... maybe we can disable total scalarization for those?
[Bug tree-optimization/80293] [6/7 Regression] unnecessary code at -O2 (-O1 is fine)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80293 --- Comment #5 from Martin Jambor --- (In reply to Richard Biener from comment #4) > That said, the array cases we've seen are somewhat disturbing... Cases? Can you point me to the other ones, please? What type do they have? > maybe we can disable total scalarization for those? The support for total scalarization of arrays was added by Alan Lawrence as a part of constant pool SRA and I suppose that for a good reason (the added testcases have them at least). However, thinking about this particular testcase a bit more, I think the most reasonable thing to do is to disable total scalarization of char (or generally byte-sized-element) arrays. Those are likely just some anonymous storage anyway: diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 02453d3ed9a..cbe9e862a2f 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -981,7 +981,7 @@ scalarizable_type_p (tree type) if (TYPE_DOMAIN (type) == NULL_TREE || !tree_fits_shwi_p (TYPE_SIZE (type)) || !tree_fits_shwi_p (TYPE_SIZE (TREE_TYPE (type))) - || (tree_to_shwi (TYPE_SIZE (TREE_TYPE (type))) <= 0) + || (tree_to_shwi (TYPE_SIZE (TREE_TYPE (type))) <= BITS_PER_UNIT) || !tree_fits_shwi_p (TYPE_MIN_VALUE (TYPE_DOMAIN (type return false; if (tree_to_shwi (TYPE_SIZE (type)) == 0
[Bug tree-optimization/80293] [6/7 Regression] unnecessary code at -O2 (-O1 is fine)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80293 Martin Jambor changed: What|Removed |Added URL||https://gcc.gnu.org/ml/gcc- ||patches/2017-04/msg00639.ht ||ml Summary|[6/7/8 Regression] |[6/7 Regression] |unnecessary code at -O2 |unnecessary code at -O2 |(-O1 is fine) |(-O1 is fine) --- Comment #7 from Martin Jambor --- Fixed on trunk so far. Also ACKed to back-port to the gcc-7-branch after 7.1 is released. Not sure about the 6 branch.