public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/20083] New: Missed optimization with conditional and basically ||
@ 2005-02-19 22:54 pinskia at gcc dot gnu dot org
  2005-02-23  1:29 ` [Bug tree-optimization/20083] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-19 22:54 UTC (permalink / raw)
  To: gcc-bugs

The following three functions should result in the same assembly (the last is the best, branchless and 
only does one compare):
int f(int i, int j, int l)
{
  int k = 0;
  if (i)
   k = 1;
  if (j)
   k = 1; 
  if (l)
    k = 1;
  return k;
}
int f1(int i, int j, int l)
{
  int k = 0;
  if (i)
   k = 1;
  else if (j)
   k = 1; 
  else if (l)
   k = 1;
  return k;
}
int f2(int i, int j, int l)
{
  return i||j||l;
}

Note I came up with this testcase after adding code like the above code to gcc and I was wondering how 
we optimizated it.

-- 
           Summary: Missed optimization with conditional and basically ||
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2023-06-07  2:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-20083-4@http.gcc.gnu.org/bugzilla/>
2012-01-21 22:23 ` [Bug tree-optimization/20083] Missed optimization with conditional and basically || pinskia at gcc dot gnu.org
2021-06-03  0:56 ` pinskia at gcc dot gnu.org
2023-05-24  0:01 ` pinskia at gcc dot gnu.org
2023-05-24  0:03 ` pinskia at gcc dot gnu.org
2023-06-07  0:30 ` pinskia at gcc dot gnu.org
2023-06-07  2:43 ` cvs-commit at gcc dot gnu.org
2023-06-07  2:45 ` pinskia at gcc dot gnu.org
2023-06-07  2:46 ` pinskia at gcc dot gnu.org
2005-02-19 22:54 [Bug tree-optimization/20083] New: " pinskia at gcc dot gnu dot org
2005-02-23  1:29 ` [Bug tree-optimization/20083] " 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).