Bug 15457 - [tree-ssa] Convert a sign bit testing into "a < 0"
Summary: [tree-ssa] Convert a sign bit testing into "a < 0"
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.0.0
: P2 enhancement
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization, TREE
Depends on: 15459
Blocks:
  Show dependency treegraph
 
Reported: 2004-05-15 12:02 UTC by Kazu Hirata
Modified: 2023-12-30 01:15 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-05-05 08:37:35


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazu Hirata 2004-05-15 12:02:22 UTC
Convert a sign bit testing into "a < 0".

void bar (void);

void
foo (signed int a)
{
  signed int b = a & (signed int) 0x80000000;
  if (b)
    bar ();
}

void
baz (signed int a)
{
  signed int b = a & 0x80000000;
  if (b)
    bar ();
}

void
baa (signed int a)
{
  signed int b = a & (1 << 31);
  if (b)
    bar ();
}

The last tree-ssa form looks like:

;; Function foo (foo)

foo (a)
{
  int b;

<bb 0>:
  b_2 = a_1 & -2147483648;
  if (b_2 != 0) goto <L0>; else goto <L1>;

<L0>:;
  bar () [tail call];

<L1>:;
  return;

}



;; Function baz (baz)

baz (a)
{
  int b;
  int T.0;

<bb 0>:
  T.0_1 = -080000000;
  b_3 = a_2 & T.0_1;
  if (b_3 != 0) goto <L0>; else goto <L1>;

<L0>:;
  bar () [tail call];

<L1>:;
  return;

}



;; Function baa (baa)

baa (a)
{
  int b;

<bb 0>:
  b_2 = a_1 & -2147483648;
  if (b_2 != 0) goto <L0>; else goto <L1>;

<L0>:;
  bar () [tail call];

<L1>:;
  return;

}
Comment 1 Andrew Pinski 2004-05-15 12:06:11 UTC
Confirmed.
Comment 2 Andrew Pinski 2004-05-17 02:03:05 UTC
PR 15359 will fix foo and baa but not baz for some reason.
Comment 3 Andrew Pinski 2005-05-08 19:12:22 UTC
(In reply to comment #2)
> PR 15359 will fix foo and baa but not baz for some reason.
I mean 15459.
Also this is done on the RTL level at least on PPC.
Comment 4 Andrew Pinski 2005-05-24 22:04:28 UTC
All three are now done by PR 15459.
Comment 5 Andrew Pinski 2005-07-12 21:27:32 UTC
It might be a while for me to rewrite the tree combiner so unassigning for now.
Comment 6 Andrew Pinski 2012-01-05 23:12:07 UTC
Fixed since 4.3.0.