public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/28794] New: missed optimization with non COND_EXPR and vrp and comparisions @ 2006-08-21 23:24 pinskia at gcc dot gnu dot org 2006-08-21 23:31 ` [Bug tree-optimization/28794] " pinskia at gcc dot gnu dot org ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: pinskia at gcc dot gnu dot org @ 2006-08-21 23:24 UTC (permalink / raw) To: gcc-bugs int f(int x, int y) { int t; for (t = 0; t < 50; t++) g(t>0); } void f1(int x, int y) { int t; for (t = 0; t < 50; t++) g(t!=0); } -------------- The above two functions should produce the same code with f1 being better than f. If we change it to: void f2(int x, int y) { int t; for (t = 0; t < 50; t++) { int tt; if (t>0) tt = 1; else tt = 0; g(tt); } } ----- We get f1 so we are only folding comparisions in a COND_EXPR which is wrong, we should also be doing them in MODIFY_EXPRs too. -- Summary: missed optimization with non COND_EXPR and vrp and comparisions Product: gcc Version: 4.2.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/28794] missed optimization with non COND_EXPR and vrp and comparisions 2006-08-21 23:24 [Bug tree-optimization/28794] New: missed optimization with non COND_EXPR and vrp and comparisions pinskia at gcc dot gnu dot org @ 2006-08-21 23:31 ` pinskia at gcc dot gnu dot org 2006-08-21 23:53 ` [Bug tree-optimization/28794] missed optimization with non-COND_EXPR " pinskia at gcc dot gnu dot org 2006-08-22 8:10 ` rguenth at gcc dot gnu dot org 2 siblings, 0 replies; 10+ messages in thread From: pinskia at gcc dot gnu dot org @ 2006-08-21 23:31 UTC (permalink / raw) To: gcc-bugs ------- Comment #1 from pinskia at gcc dot gnu dot org 2006-08-21 23:31 ------- I found this while trying to figure out how to get VRP to optimize: a_1 != 0 into a_1 if the range of a_1 is [0,1] (well with a NOP_EXPR). If I do it inside simplify_cond_using_ranges, I miss all the MODIFY_EXPRs. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/28794] missed optimization with non-COND_EXPR and vrp and comparisions 2006-08-21 23:24 [Bug tree-optimization/28794] New: missed optimization with non COND_EXPR and vrp and comparisions pinskia at gcc dot gnu dot org 2006-08-21 23:31 ` [Bug tree-optimization/28794] " pinskia at gcc dot gnu dot org @ 2006-08-21 23:53 ` pinskia at gcc dot gnu dot org 2006-08-22 8:10 ` rguenth at gcc dot gnu dot org 2 siblings, 0 replies; 10+ messages in thread From: pinskia at gcc dot gnu dot org @ 2006-08-21 23:53 UTC (permalink / raw) To: gcc-bugs ------- Comment #2 from pinskia at gcc dot gnu dot org 2006-08-21 23:52 ------- For x86, there is no difference in the code gen for f and f1/f2, but for PPC32, there is: for f1/f2: addic %r0,%r31,-1 subfe %r3,%r0,%r31 For f: srawi %r3,%r31,31 subf %r3,%r31,%r3 srwi %r3,%r3,31 -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|missed optimization with non|missed optimization with |COND_EXPR and vrp and |non-COND_EXPR and vrp and |comparisions |comparisions http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/28794] missed optimization with non-COND_EXPR and vrp and comparisions 2006-08-21 23:24 [Bug tree-optimization/28794] New: missed optimization with non COND_EXPR and vrp and comparisions pinskia at gcc dot gnu dot org 2006-08-21 23:31 ` [Bug tree-optimization/28794] " pinskia at gcc dot gnu dot org 2006-08-21 23:53 ` [Bug tree-optimization/28794] missed optimization with non-COND_EXPR " pinskia at gcc dot gnu dot org @ 2006-08-22 8:10 ` rguenth at gcc dot gnu dot org 2 siblings, 0 replies; 10+ messages in thread From: rguenth at gcc dot gnu dot org @ 2006-08-22 8:10 UTC (permalink / raw) To: gcc-bugs ------- Comment #3 from rguenth at gcc dot gnu dot org 2006-08-22 08:10 ------- Confirmed. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu dot | |org Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2006-08-22 08:10:03 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794 ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <bug-28794-4@http.gcc.gnu.org/bugzilla/>]
* [Bug tree-optimization/28794] missed optimization with non-COND_EXPR and vrp and comparisions [not found] <bug-28794-4@http.gcc.gnu.org/bugzilla/> @ 2021-06-08 7:50 ` pinskia at gcc dot gnu.org 2023-08-07 5:57 ` pinskia at gcc dot gnu.org ` (4 subsequent siblings) 5 siblings, 0 replies; 10+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-06-08 7:50 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2020-01-17 00:00:00 |2021-6-8 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note really the loops at -O3 should really be optimized to: void f3(int x, int y) { int t; g(0); for (t = 1; t < 50; t++) { g(1); } } That is peel off the first iteration. I don't know why -O3 -fno-ssa-phiopt -fno-tree-vrp does not do that either. I will file that as a different bug because this is about converting the comparison only in COND_EXPR gimple. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/28794] missed optimization with non-COND_EXPR and vrp and comparisions [not found] <bug-28794-4@http.gcc.gnu.org/bugzilla/> 2021-06-08 7:50 ` pinskia at gcc dot gnu.org @ 2023-08-07 5:57 ` pinskia at gcc dot gnu.org 2023-08-07 6:27 ` pinskia at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 10+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-08-07 5:57 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I am going to finally optimize this. My plan is to change simplify_cond_using_ranges_1 to take 3 reference arguments and return true if a change to them. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/28794] missed optimization with non-COND_EXPR and vrp and comparisions [not found] <bug-28794-4@http.gcc.gnu.org/bugzilla/> 2021-06-08 7:50 ` pinskia at gcc dot gnu.org 2023-08-07 5:57 ` pinskia at gcc dot gnu.org @ 2023-08-07 6:27 ` pinskia at gcc dot gnu.org 2023-08-07 6:44 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 5 siblings, 0 replies; 10+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-08-07 6:27 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED --- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I have a patch now. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/28794] missed optimization with non-COND_EXPR and vrp and comparisions [not found] <bug-28794-4@http.gcc.gnu.org/bugzilla/> ` (2 preceding siblings ...) 2023-08-07 6:27 ` pinskia at gcc dot gnu.org @ 2023-08-07 6:44 ` pinskia at gcc dot gnu.org 2023-08-08 15:42 ` cvs-commit at gcc dot gnu.org 2023-08-08 15:43 ` pinskia at gcc dot gnu.org 5 siblings, 0 replies; 10+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-08-07 6:44 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794 --- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Created attachment 55700 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55700&action=edit Patch, still needs testcase ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/28794] missed optimization with non-COND_EXPR and vrp and comparisions [not found] <bug-28794-4@http.gcc.gnu.org/bugzilla/> ` (3 preceding siblings ...) 2023-08-07 6:44 ` pinskia at gcc dot gnu.org @ 2023-08-08 15:42 ` cvs-commit at gcc dot gnu.org 2023-08-08 15:43 ` pinskia at gcc dot gnu.org 5 siblings, 0 replies; 10+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2023-08-08 15:42 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794 --- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>: https://gcc.gnu.org/g:aadc5c07feb0ab08729ab25d0d896b55860ad9e6 commit r14-3084-gaadc5c07feb0ab08729ab25d0d896b55860ad9e6 Author: Andrew Pinski <apinski@marvell.com> Date: Mon Aug 7 00:05:21 2023 -0700 VR-VALUES [PR28794]: optimize compare assignments also This patch fixes the oldish (2006) bug where VRP was not optimizing the comparison for assignments while handling them for GIMPLE_COND only. It just happens to also solves PR 103281 due to allowing to optimize `c < 1` to `c == 0` and then we get `(c == 0) == c` (which was handled by r14-2501-g285c9d04). OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/103281 PR tree-optimization/28794 gcc/ChangeLog: * vr-values.cc (simplify_using_ranges::simplify_cond_using_ranges_1): Split out majority to ... (simplify_using_ranges::simplify_compare_using_ranges_1): Here. (simplify_using_ranges::simplify_casted_cond): Rename to ... (simplify_using_ranges::simplify_casted_compare): This and change arguments to take op0 and op1. (simplify_using_ranges::simplify_compare_assign_using_ranges_1): New method. (simplify_using_ranges::simplify): For tcc_comparison assignments call simplify_compare_assign_using_ranges_1. * vr-values.h (simplify_using_ranges): Add new methods, simplify_compare_using_ranges_1 and simplify_compare_assign_using_ranges_1. Rename simplify_casted_cond and simplify_casted_compare and update argument types. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr103281-1.c: New test. * gcc.dg/tree-ssa/vrp-compare-1.c: New test. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/28794] missed optimization with non-COND_EXPR and vrp and comparisions [not found] <bug-28794-4@http.gcc.gnu.org/bugzilla/> ` (4 preceding siblings ...) 2023-08-08 15:42 ` cvs-commit at gcc dot gnu.org @ 2023-08-08 15:43 ` pinskia at gcc dot gnu.org 5 siblings, 0 replies; 10+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-08-08 15:43 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|ASSIGNED |RESOLVED Target Milestone|--- |14.0 --- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Fixed finally. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-08-08 15:43 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2006-08-21 23:24 [Bug tree-optimization/28794] New: missed optimization with non COND_EXPR and vrp and comparisions pinskia at gcc dot gnu dot org 2006-08-21 23:31 ` [Bug tree-optimization/28794] " pinskia at gcc dot gnu dot org 2006-08-21 23:53 ` [Bug tree-optimization/28794] missed optimization with non-COND_EXPR " pinskia at gcc dot gnu dot org 2006-08-22 8:10 ` rguenth at gcc dot gnu dot org [not found] <bug-28794-4@http.gcc.gnu.org/bugzilla/> 2021-06-08 7:50 ` pinskia at gcc dot gnu.org 2023-08-07 5:57 ` pinskia at gcc dot gnu.org 2023-08-07 6:27 ` pinskia at gcc dot gnu.org 2023-08-07 6:44 ` pinskia at gcc dot gnu.org 2023-08-08 15:42 ` cvs-commit at gcc dot gnu.org 2023-08-08 15:43 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).