Bug 15348 - [tree-ssa] Convert (x < 0) || (y < 0) into (x | y) < 0.
Summary: [tree-ssa] Convert (x < 0) || (y < 0) into (x | y) < 0.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: tree-ssa
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on: 15357 15459
Blocks: 19987
  Show dependency treegraph
 
Reported: 2004-05-09 19:30 UTC by Kazu Hirata
Modified: 2023-12-30 01:15 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-12-30 22:22:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazu Hirata 2004-05-09 19:30:50 UTC
Convert foo() into baz().

void bar (void);

int
foo (int x, int y)
{
  int t1 = x < 0;
  int t2 = y < 0;
  return t1 || t2;
}

int
baz (int x, int y)
{
  return (x | y) < 0;
}

Needless to mention, we should do this fairly late in SSA optimizations.
Comment 1 Kazu Hirata 2004-05-09 19:32:30 UTC
Another one just like above:

void bar (void);

void
foo (int a, int b)
{
  if (a != 0)
    return;
  if (b != 0)
    return;
  bar ();
}

void
baz (int a, int b)
{
  if ((a | b) == 0)
    bar ();
}

See also PR 15241.
Comment 2 Andrew Pinski 2004-05-09 19:41:56 UTC
Confirmed.  
Comment 3 Steven Bosscher 2005-09-30 22:29:24 UTC
For AMD64, the functions from the first test case don't produce the 
same code either, so combine is not catching this either. 
 
Comment 4 Dmitry G. Dyachenko 2020-03-11 07:06:16 UTC
x86_64 r10-7080 for me produce identical code
-- c#0 with -O2
-- c#1 with -O
Comment 5 Jeffrey A. Law 2020-04-19 18:17:42 UTC
Resolved at some point in the past.  Not worth the trouble to bisect.