[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 Andrew Pinski changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=112418, ||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=112324, ||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=64700 --- Comment #22 from Andrew Pinski --- (In reply to Jeffrey A. Law from comment #7) > The other thing to keep in mind, sinking of this nature ought to be > applicable to other unary ops and cases where we have multiple PHI args that > are SSA_NAMEs.It shouldn't be structurally limited to just conversions > where one arg is an SSA_NAME and the other a constant. Just an FYI on the above comment; other unary ops was implemented with r14-575-g6d6c17e45f62cf (and improved to some builtins with r15-2986-gcd2f394418be0c). Multiple phi args is recorded as PR 112418, I have a patch which needs improvement on the cost model side. Also we can handle binary ops too which is recorded as PR 112324 (and PR 64700), I have a patch there but has some regressions where other passes need improvement still (PR 64700 has those linked).
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #21 from Jorn Wolfgang Rennecke --- Author: amylaar Date: Mon Jul 1 21:48:55 2019 New Revision: 272911 URL: https://gcc.gnu.org/viewcvs?rev=272911&root=gcc&view=rev Log: PR middle-end/66726 * tree-ssa-phiopt.c (factor_out_conditional_conversion): Tune heuristic from PR71016 to allow MIN / MAX. * testsuite/gcc.dg/tree-ssa/pr66726-4.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/pr66726-4.c Modified: trunk/gcc/ChangeLog trunk/gcc/tree-ssa-phiopt.c
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 Jeffrey A. Law changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #20 from Jeffrey A. Law --- Fixed by Kugan's work.
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #19 from kugan at gcc dot gnu.org --- Author: kugan Date: Sun Jul 24 12:47:29 2016 New Revision: 238695 URL: https://gcc.gnu.org/viewcvs?rev=238695&root=gcc&view=rev Log: gcc/ChangeLog: 2016-07-24 Kugan Vivekanandarajah PR middle-end/66726 * tree-ssa-reassoc.c (optimize_vec_cond_expr): Handle tcc_compare stmt whose result is used in PHI. (final_range_test_p): Likewise. (maybe_optimize_range_tests): Likewise. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-ssa-reassoc.c
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 Eric Botcazou changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2016-05-25 CC||ebotcazou at gcc dot gnu.org Ever confirmed|0 |1
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #18 from kugan at gcc dot gnu.org --- Reverted r233362 as it caused PR69786 and PR69781. I will test for these and post a revised patch for next stage1.
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #17 from kugan at gcc dot gnu.org --- Author: kugan Date: Fri Feb 12 06:40:55 2016 New Revision: 233368 URL: https://gcc.gnu.org/viewcvs?rev=233368&root=gcc&view=rev Log: 2016-02-12 Kugan Vivekanandarajah revert: 2016-02-12 Kugan Vivekanandarajah PR middle-end/66726 * tree-ssa-reassoc.c (optimize_range_tests): Handle tcc_compare stmt whose result is used in PHI. (maybe_optimize_range_tests): Likewise. (final_range_test_p): Likweise. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-ssa-reassoc.c
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #16 from kugan at gcc dot gnu.org --- Author: kugan Date: Fri Feb 12 00:24:22 2016 New Revision: 233362 URL: https://gcc.gnu.org/viewcvs?rev=233362&root=gcc&view=rev Log: gcc/ChangeLog: 2016-02-12 Kugan Vivekanandarajah PR middle-end/66726 * tree-ssa-reassoc.c (optimize_range_tests): Handle tcc_compare stmt whose result is used in PHI. (maybe_optimize_range_tests): Likewise. (final_range_test_p): Likweise. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-ssa-reassoc.c
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #15 from Jakub Jelinek --- Author: jakub Date: Mon Dec 7 21:05:51 2015 New Revision: 231384 URL: https://gcc.gnu.org/viewcvs?rev=231384&root=gcc&view=rev Log: PR middle-end/66726 * g++.dg/tree-ssa/pr66726.c: Renamed to... * g++.dg/tree-ssa/pr66726.C: ... this. Added: trunk/gcc/testsuite/g++.dg/tree-ssa/pr66726.C - copied, changed from r231383, trunk/gcc/testsuite/g++.dg/tree-ssa/pr66726.c Removed: trunk/gcc/testsuite/g++.dg/tree-ssa/pr66726.c Modified: trunk/gcc/testsuite/ChangeLog
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #14 from kugan at gcc dot gnu.org --- Sorry I missed this. I posted patch which was OKed but in further testing I found an issue. I am testing a modified patch and will post for review soon.
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #13 from Andreas Schwab --- ../../gcc/tree-ssa-reassoc.c: In function 'void maybe_optimize_range_tests(gimple*)': ../../gcc/tree-ssa-reassoc.c:3193:8: error: 'operand_entry_t' was not declared in this scope operand_entry_t oe = operand_entry_pool.allocate (); ^ ../../gcc/tree-ssa-reassoc.c:3193:24: error: expected ';' before 'oe' operand_entry_t oe = operand_entry_pool.allocate (); ^ ../../gcc/tree-ssa-reassoc.c:3194:8: error: 'oe' was not declared in this scope oe->op = lhs; ^
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #12 from kugan at gcc dot gnu.org --- Created attachment 35976 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35976&action=edit patch for tree-ssa-reassoc Here is a prototype patch (to fix comment 9) that makes tree-ssa-reassoc understand after sinking the casts. Not fully tested yet.
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #11 from kugan at gcc dot gnu.org --- Thanks for reporting. This test case is valid for targets that has branch cost greater than 1. One way to handle this is by disabling this for convections involving bool that are part of branch (?) I think the real fix is to make tree-ssa-reassoc handle this? Looking into it.
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #10 from Jeffrey A. Law --- Sinking the cast changes the form of the range tests into one that tree-ssa-reassoc isn't prepared to handle. Sadly the form presented with the cast sunk is *simpler* than the original. I'm testing a bit of a hack to avoid the sinking of the cast in cases where doing so is less likely to be a win.
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #9 from Andreas Schwab --- On m68k: FAIL: gcc.dg/pr46309.c scan-tree-dump-times reassoc1 "Optimizing range tests a_[0-9]*.D. -.1, 1. and -.3, 3.[\n\r]* into" 1 FAIL: gcc.dg/pr46309.c scan-tree-dump-times reassoc1 "Optimizing range tests a_[0-9]*.D. -.1, 1. and -.2, 2.[\n\r]* into" 1 FAIL: gcc.dg/pr46309.c scan-tree-dump-times reassoc1 "Optimizing range tests a_[0-9]*.D. -.0, 31. and -.64, 95.[\n\r]* into" 2 $ gcc/xgcc -Bgcc/ ../gcc/testsuite/gcc.dg/pr46309.c -O2 -fdump-tree-reassoc-details -S -o pr46309.s $ grep -e "Optimizing range tests" -e into pr46309.c.*.reassoc1 Optimizing range tests a_2(D) -[1, 1] and -[2, 2] and -[3, 3] and -[4, 4] into (unsigned int) a_2(D) + 4294967295 > 3 Optimizing range tests a_2(D) -[1, 1] and -[2, 2] and -[3, 3] and -[4, 4] into (unsigned int) a_2(D) + 4294967295 > 3 Optimizing range tests a_2(D) -[0, 31] and -[64, 95] into (a_2(D) & 4294967231) > 31 Optimizing range tests a_2(D) -[128, 159] and -[192, 223] into (a_2(D) & 4294967231) + 4294967168 > 31
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #8 from kugan at gcc dot gnu.org --- Author: kugan Date: Sun Jul 12 11:22:42 2015 New Revision: 225722 URL: https://gcc.gnu.org/viewcvs?rev=225722&root=gcc&view=rev Log: gcc/testsuite/ChangeLog: 2015-07-12 Kugan Vivekanandarajah Jeff Law PR middle-end/66726 * g++.dg/tree-ssa/pr66726.c: New test. * gcc.dg/tree-ssa/pr66726-2.c: New test. * gcc.dg/tree-ssa/pr66726.c: New test. gcc/ChangeLog: 2015-07-12 Kugan Vivekanandarajah PR middle-end/66726 * tree-ssa-phiopt.c(factor_out_conditional_conversion): New function. tree_ssa_phiopt_worker): Call it. Added: trunk/gcc/testsuite/g++.dg/tree-ssa/pr66726.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr66726-2.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr66726.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-phiopt.c
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #7 from Jeffrey A. Law --- The other thing to keep in mind, sinking of this nature ought to be applicable to other unary ops and cases where we have multiple PHI args that are SSA_NAMEs.It shouldn't be structurally limited to just conversions where one arg is an SSA_NAME and the other a constant.
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #6 from Jeffrey A. Law --- WRT c#2. PRE will try to optimize away a runtime redundant expression. In the cases I'm looking at, there is only a single runtime evaluation. But that evaluation can be sunk from a set of predecessors into a single successor. It's more like tail merging than PRE.
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #5 from kugan at gcc dot gnu.org --- (In reply to Andrew Pinski from comment #4) > (In reply to kugan from comment #3) > > > really you should handle more > > > than two arguments to phis. > > I am not sure how we can handle phi stmt with more than two arguments here. > > Any hints please? > > Yes they are all interger constants but one of them. Also I think you do > have another bug where the conversion is an extension the original interger > has to fit in the new type. That is if you converting from char to int. Thanks for that. Yes, I fixed this and another during testing. I will post it after full regression testing.
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #4 from Andrew Pinski --- (In reply to kugan from comment #3) > > really you should handle more > > than two arguments to phis. > I am not sure how we can handle phi stmt with more than two arguments here. > Any hints please? Yes they are all interger constants but one of them. Also I think you do have another bug where the conversion is an extension the original interger has to fit in the new type. That is if you converting from char to int.
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #3 from kugan at gcc dot gnu.org --- > really you should handle more > than two arguments to phis. I am not sure how we can handle phi stmt with more than two arguments here. Any hints please?
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #2 from Andrew Pinski --- Comment on attachment 35888 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35888 untested prototype patch I thought pre does this already and that seems like a better place than phi-opt. Oh wait pre does the opposite and really you should handle more than two arguments to phis.
[Bug tree-optimization/66726] missed optimization, factor conversion out of COND_EXPR
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66726 --- Comment #1 from kugan at gcc dot gnu.org --- Created attachment 35888 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35888&action=edit untested prototype patch Hi Jeff, Here is a patch (without debug dumps and not tesetd fully). Is this along what you had in mind? Thanks, Kugan