[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #22 from Aldy Hernandez --- Author: aldyh Date: Wed Sep 13 17:36:05 2017 New Revision: 252605 URL: https://gcc.gnu.org/viewcvs?rev=252605=gcc=rev Log: [gcc] 2017-08-29 Bill SchmidtJakub Jelinek Richard Biener PR tree-optimization/81503 * gimple-ssa-strength-reduction.c (replace_mult_candidate): Ensure folded constant fits in the target type; reorder tests for clarity. [gcc/testsuite] 2017-08-29 Bill Schmidt PR tree-optimization/81503 * gcc.c-torture/execute/pr81503.c: New file. Added: branches/range-gen2/gcc/testsuite/gcc.c-torture/execute/pr81503.c Modified: branches/range-gen2/gcc/ChangeLog branches/range-gen2/gcc/gimple-ssa-strength-reduction.c branches/range-gen2/gcc/testsuite/ChangeLog
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 Bill Schmidt changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #21 from Bill Schmidt --- Fixed everywhere now.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #20 from Bill Schmidt --- Author: wschmidt Date: Tue Sep 5 21:52:01 2017 New Revision: 251745 URL: https://gcc.gnu.org/viewcvs?rev=251745=gcc=rev Log: [gcc] 2017-09-05 Bill SchmidtBackport from mainline 2017-08-29 Bill Schmidt Jakub Jelinek Richard Biener PR tree-optimization/81503 * gimple-ssa-strength-reduction.c (replace_mult_candidate): Ensure folded constant fits in the target type; reorder tests for clarity. [gcc/testsuite] 2017-09-05 Bill Schmidt Backport from mainline 2017-08-29 Bill Schmidt Jakub Jelinek Richard Biener PR tree-optimization/81503 * gcc.c-torture/execute/pr81503.c: New file. Added: branches/gcc-5-branch/gcc/testsuite/gcc.c-torture/execute/pr81503.c Modified: branches/gcc-5-branch/gcc/ChangeLog branches/gcc-5-branch/gcc/gimple-ssa-strength-reduction.c branches/gcc-5-branch/gcc/testsuite/ChangeLog
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #19 from Bill Schmidt --- Author: wschmidt Date: Tue Sep 5 21:50:38 2017 New Revision: 251744 URL: https://gcc.gnu.org/viewcvs?rev=251744=gcc=rev Log: [gcc] 2017-09-05 Bill SchmidtBackport from mainline 2017-08-29 Bill Schmidt Jakub Jelinek Richard Biener PR tree-optimization/81503 * gimple-ssa-strength-reduction.c (replace_mult_candidate): Ensure folded constant fits in the target type; reorder tests for clarity. [gcc/testsuite] 2017-09-05 Bill Schmidt Backport from mainline 2017-08-29 Bill Schmidt Jakub Jelinek Richard Biener PR tree-optimization/81503 * gcc.c-torture/execute/pr81503.c: New file. Added: branches/gcc-6-branch/gcc/testsuite/gcc.c-torture/execute/pr81503.c Modified: branches/gcc-6-branch/gcc/ChangeLog branches/gcc-6-branch/gcc/gimple-ssa-strength-reduction.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #18 from Bill Schmidt --- Author: wschmidt Date: Tue Sep 5 21:49:01 2017 New Revision: 251743 URL: https://gcc.gnu.org/viewcvs?rev=251743=gcc=rev Log: [gcc] 2017-09-05 Bill SchmidtBackport from mainline 2017-08-29 Bill Schmidt Jakub Jelinek Richard Biener PR tree-optimization/81503 * gimple-ssa-strength-reduction.c (replace_mult_candidate): Ensure folded constant fits in the target type; reorder tests for clarity. [gcc/testsuite] 2017-09-05 Bill Schmidt Backport from mainline 2017-08-29 Bill Schmidt Jakub Jelinek Richard Biener PR tree-optimization/81503 * gcc.c-torture/execute/pr81503.c: New file. Added: branches/gcc-7-branch/gcc/testsuite/gcc.c-torture/execute/pr81503.c Modified: branches/gcc-7-branch/gcc/ChangeLog branches/gcc-7-branch/gcc/gimple-ssa-strength-reduction.c branches/gcc-7-branch/gcc/testsuite/ChangeLog
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #17 from Bill Schmidt --- Fixed in trunk so far. Although this test case succeeds on GCC 7, the bug is latent there, so I'll keep this open and backport the fix to other releases in a week or so.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #16 from Bill Schmidt --- Author: wschmidt Date: Tue Aug 29 14:41:53 2017 New Revision: 251414 URL: https://gcc.gnu.org/viewcvs?rev=251414=gcc=rev Log: [gcc] 2017-08-29 Bill SchmidtJakub Jelinek Richard Biener PR tree-optimization/81503 * gimple-ssa-strength-reduction.c (replace_mult_candidate): Ensure folded constant fits in the target type; reorder tests for clarity. [gcc/testsuite] 2017-08-29 Bill Schmidt PR tree-optimization/81503 * gcc.c-torture/execute/pr81503.c: New file. Added: trunk/gcc/testsuite/gcc.c-torture/execute/pr81503.c Modified: trunk/gcc/ChangeLog trunk/gcc/gimple-ssa-strength-reduction.c trunk/gcc/testsuite/ChangeLog
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #15 from Bill Schmidt --- Proposed patch awaiting approval: https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00347.html
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #14 from Bill Schmidt --- Created attachment 41899 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41899=edit Patch under test This is the patch I'm currently looking at. I am unhappy at having to use a tree to get maxval, but I cannot find a way to convert a wide_int into a widest_int so that I can add them together (see the desired code that is commented out). Do you have a suggestion how I can do this within the wide_int framework?
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #13 from Bill Schmidt --- (In reply to Jakub Jelinek from comment #12) > I had in mind something like > wi::eq_p (wi::ext (w, TYPE_PRECISION (type), TYPE_SIGN (type)), w) > or so. Ah, good, thank you.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #12 from Jakub Jelinek --- I had in mind something like wi::eq_p (wi::ext (w, TYPE_PRECISION (type), TYPE_SIGN (type)), w) or so.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #11 from Bill Schmidt --- (In reply to Jakub Jelinek from comment #10) > The TREE_INT_CST_LOW part looks suspicious. Also, wide-int.h should provide > enough infrastructure so that you should be able to do everything on > wide-int, not have to create trees. I just saw this comment now. I think that the TREE_INT_CST_LOW is ok given that we've already constrained bump to fit in a HOST_WIDE_INT, right? But anyway, your second point is well taken -- it looks like I can make use of wi::to_uhwi and wi::to_shwi with a specified precision from the target type, so use of trees should indeed be unnecessary. I have a working patch that uses the trees, but I will rework that in favor of a pure wide-int solution. Thanks for the suggestion! Bill
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #10 from Jakub Jelinek --- The TREE_INT_CST_LOW part looks suspicious. Also, wide-int.h should provide enough infrastructure so that you should be able to do everything on wide-int, not have to create trees.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #9 from Bill Schmidt --- This is overkill, it has some test case fallout. Will have to look a bit deeper.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #8 from Bill Schmidt --- Patch under test that fixes this case: Index: gcc/gimple-ssa-strength-reduction.c === --- gcc/gimple-ssa-strength-reduction.c (revision 250791) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -2082,6 +2082,11 @@ replace_mult_candidate (slsr_cand_t c, tree basis_ types but allows for safe negation without twisted logic. */ if (wi::fits_shwi_p (bump) && bump.to_shwi () != HOST_WIDE_INT_MIN + /* It is more likely that the bump doesn't fit in the target +type, so check whether constraining it to that type changes +the value. */ + && wi::eq_p (TREE_INT_CST_LOW (wide_int_to_tree (target_type, bump)), + bump) /* It is not useful to replace casts, copies, negates, or adds of an SSA name and a constant. */ && cand_code != SSA_NAME
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #7 from Bill Schmidt --- Try -fno-slsr.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #6 from Dmitry Babokin --- How can I switch off optimization phases to workaround the bug? I have another instances of wrong code bugs, so I'd like to make sure that I don't create duplicate reports for the same problem.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 Bill Schmidt changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |wschmidt at gcc dot gnu.org --- Comment #5 from Bill Schmidt --- Mine, but my queue is getting pretty deep, so it will be a bit before I look at it.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 --- Comment #4 from Marc Glisse --- if (a + b * -2) c = (b-1073741824)*-2; might let you find an earlier culprit.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 Martin Liška changed: What|Removed |Added CC||marxin at gcc dot gnu.org --- Comment #3 from Martin Liška --- Started with r249447: gcc/ * match.pd (nop_convert): New predicate. ((A +- CST1) +- CST2): Allow some NOP conversions. gcc/testsuite/ * gcc.dg/tree-ssa/addadd.c: Un-XFAIL. * gcc.dg/tree-ssa/addadd-2.c: New file.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2017-07-21 CC||wschmidt at gcc dot gnu.org Known to work||7.1.1 Target Milestone|--- |8.0 Summary|Wrong code at -O2 |[8 Regression] Wrong code ||at -O2 Ever confirmed|0 |1 --- Comment #2 from Richard Biener --- Seems to work with GCC 7.