public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19832] New: Missed optimisation
@ 2005-02-09  7:41 christophe dot jaillet at wanadoo dot fr
  2005-02-09  7:46 ` [Bug tree-optimization/19832] don't remove an if when we know the value is the same as with the if (subtraction) pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 14+ messages in thread
From: christophe dot jaillet at wanadoo dot fr @ 2005-02-09  7:41 UTC (permalink / raw)
  To: gcc-bugs

According to Andrew Pinski , the following patch is useless because gcc should 
be able to find the optimisation by itself.



Description : function preferable in cse.c can be simplified if we notice
that, at the end of the function :
   if (regcost_a != regcost_b)
     return regcost_a - regcost_b;
   return 0;

So, if regcost_a == regcost_b, we return 0, but in this case (regcost_a -
regcost_b) is also = 0.
There is no need for the test, and (return regcost_a - regcost_b;) wins in
all cases.



This patch remove 3 572 566 useless tests (if regcost_a != regcost_b) when
doing a full bootstrap.



Bootstrap on a cygwin machine based on snapshot from 20050130.


2005-02-08  Christophe Jaillet <christophe.jaillet@wanadoo.fr>

    * cse.c (preferable): simplify last test to speed up



*** gcc-4.0-20050130/gcc/cse.c Tue Feb  8 23:39:30 2005
--- my_patch/cse.c Tue Feb  8 23:55:02 2005
*************** preferable (int cost_a, int regcost_a, i
*** 836,845 ****
    /* Normal operation costs take precedence.  */
    if (cost_a != cost_b)
      return cost_a - cost_b;
    /* Only if these are identical consider effects on register pressure.
*/
!   if (regcost_a != regcost_b)
!     return regcost_a - regcost_b;
!   return 0;
  }

  /* Internal function, to compute cost when X is not a register; called
--- 836,844 ----
    /* Normal operation costs take precedence.  */
    if (cost_a != cost_b)
      return cost_a - cost_b;
+
    /* Only if these are identical consider effects on register pressure.
*/
!   return regcost_a - regcost_b;
  }

  /* Internal function, to compute cost when X is not a register; called

-- 
           Summary: Missed optimisation
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: christophe dot jaillet at wanadoo dot fr
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19832


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-12-25  4:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-19832-4@http.gcc.gnu.org/bugzilla/>
2011-08-13  1:39 ` [Bug tree-optimization/19832] don't remove an if when we know the value is the same as with the if (subtraction) jimis at gmx dot net
2011-08-13  2:21 ` jimis at gmx dot net
2012-08-06 11:41 ` rguenth at gcc dot gnu.org
2023-05-06 21:15 ` pinskia at gcc dot gnu.org
2023-05-06 23:12 ` pinskia at gcc dot gnu.org
2023-05-06 23:13 ` pinskia at gcc dot gnu.org
2023-08-31  1:03 ` pinskia at gcc dot gnu.org
2023-08-31  4:48 ` pinskia at gcc dot gnu.org
2023-08-31 18:03 ` pinskia at gcc dot gnu.org
2023-09-01  6:58 ` cvs-commit at gcc dot gnu.org
2023-09-01  6:58 ` pinskia at gcc dot gnu.org
2023-09-01 12:23 ` cvs-commit at gcc dot gnu.org
2023-12-25  4:02 ` cvs-commit at gcc dot gnu.org
2005-02-09  7:41 [Bug c/19832] New: Missed optimisation christophe dot jaillet at wanadoo dot fr
2005-02-09  7:46 ` [Bug tree-optimization/19832] don't remove an if when we know the value is the same as with the if (subtraction) pinskia at gcc dot gnu dot 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).