public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/15350] New: [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0).
@ 2004-05-09 19:50 kazu at cs dot umass dot edu
  2004-05-09 20:37 ` [Bug optimization/15350] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-09 19:50 UTC (permalink / raw)
  To: gcc-bugs

Convert foo() into baz().

void bar (void);

void
foo (int a)
{
  int b = 1 << a;
  if (b & 1)
    bar ();
}

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

You might think this is so artificial but actually comes from
simplify_comparison() in combine.c, a part of which looks like

<L344>:;
  T.4338_976 = (int)T.4337_966;
  T.4546_977 = T.4338_976 - 1;
  T.4547_978 = 1 << T.4546_977;
  T.4548_979 = T.4547_978 & 1;
  T.4549_980 = (_Bool)T.4548_979;
  if (T.4549_980 == 0) goto <L555>; else goto <L345>;

-- 
           Summary: [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0).
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Keywords: pessimizes-code
          Severity: enhancement
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug optimization/15350] [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0).
  2004-05-09 19:50 [Bug optimization/15350] New: [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0) kazu at cs dot umass dot edu
@ 2004-05-09 20:37 ` pinskia at gcc dot gnu dot org
  2004-05-09 21:40 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-09 20:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-09 20:37 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-05-09 20:37:47
               date|                            |


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


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

* [Bug optimization/15350] [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0).
  2004-05-09 19:50 [Bug optimization/15350] New: [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0) kazu at cs dot umass dot edu
  2004-05-09 20:37 ` [Bug optimization/15350] " pinskia at gcc dot gnu dot org
@ 2004-05-09 21:40 ` pinskia at gcc dot gnu dot org
  2004-05-15 22:58 ` [Bug tree-optimization/15350] " kazu at cs dot umass dot edu
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-09 21:40 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |tree-ssa


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


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

* [Bug tree-optimization/15350] [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0).
  2004-05-09 19:50 [Bug optimization/15350] New: [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0) kazu at cs dot umass dot edu
  2004-05-09 20:37 ` [Bug optimization/15350] " pinskia at gcc dot gnu dot org
  2004-05-09 21:40 ` pinskia at gcc dot gnu dot org
@ 2004-05-15 22:58 ` kazu at cs dot umass dot edu
  2004-05-17 17:50 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-15 22:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-05-15 11:39 -------
As of today, the last tree-ssa form of foo() looks like:

foo (a)
{
  int b;
  _Bool T.1;
  int T.0;

<bb 0>:
  b_2 = 1 << a_1;
  T.0_3 = b_2 & 1;
  if (T.0_3 != 0) goto <L0>; else goto <L1>;

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

<L1>:;
  return;

}

-- 


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


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

* [Bug tree-optimization/15350] [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0).
  2004-05-09 19:50 [Bug optimization/15350] New: [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0) kazu at cs dot umass dot edu
                   ` (2 preceding siblings ...)
  2004-05-15 22:58 ` [Bug tree-optimization/15350] " kazu at cs dot umass dot edu
@ 2004-05-17 17:50 ` pinskia at gcc dot gnu dot org
  2004-05-24 23:10 ` pinskia at gcc dot gnu dot org
  2005-05-08 19:08 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-17 17:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-17 01:57 -------
When fold could optimize (1 << a) & 1, PR 15495 will fix the testcase in this bug.

-- 


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


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

* [Bug tree-optimization/15350] [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0).
  2004-05-09 19:50 [Bug optimization/15350] New: [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0) kazu at cs dot umass dot edu
                   ` (3 preceding siblings ...)
  2004-05-17 17:50 ` pinskia at gcc dot gnu dot org
@ 2004-05-24 23:10 ` pinskia at gcc dot gnu dot org
  2005-05-08 19:08 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-24 23:10 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.5.0                       |---


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


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

* [Bug tree-optimization/15350] [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0).
  2004-05-09 19:50 [Bug optimization/15350] New: [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0) kazu at cs dot umass dot edu
                   ` (4 preceding siblings ...)
  2004-05-24 23:10 ` pinskia at gcc dot gnu dot org
@ 2005-05-08 19:08 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-08 19:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-08 19:08 -------
Hmm, we do optimize this with ashiftrt but not with ashift.
We also fold ((1 << a) & 1) != 0  into ((1 >> a & 1) != 0) which gets optimized on the RTL level.

-- 


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


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

* [Bug tree-optimization/15350] [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0).
       [not found] <bug-15350-4@http.gcc.gnu.org/bugzilla/>
  2014-10-31  4:02 ` pinskia at gcc dot gnu.org
@ 2015-06-09 17:23 ` glisse at gcc dot gnu.org
  1 sibling, 0 replies; 9+ messages in thread
From: glisse at gcc dot gnu.org @ 2015-06-09 17:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15350

Marc Glisse <glisse at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to work|                            |5.1.0
         Resolution|---                         |FIXED
      Known to fail|                            |4.9.2

--- Comment #5 from Marc Glisse <glisse at gcc dot gnu.org> ---
This was fixed in gcc-5.


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

* [Bug tree-optimization/15350] [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0).
       [not found] <bug-15350-4@http.gcc.gnu.org/bugzilla/>
@ 2014-10-31  4:02 ` pinskia at gcc dot gnu.org
  2015-06-09 17:23 ` glisse at gcc dot gnu.org
  1 sibling, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-10-31  4:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15350
Bug 15350 depends on bug 15459, which changed state.

Bug 15459 Summary: [meta-bug] there should be a tree combiner like the rtl one
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15459

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED


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

end of thread, other threads:[~2015-06-09 17:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-09 19:50 [Bug optimization/15350] New: [tree-ssa] Convert if ((1 << a) & 1) into if (a == 0) kazu at cs dot umass dot edu
2004-05-09 20:37 ` [Bug optimization/15350] " pinskia at gcc dot gnu dot org
2004-05-09 21:40 ` pinskia at gcc dot gnu dot org
2004-05-15 22:58 ` [Bug tree-optimization/15350] " kazu at cs dot umass dot edu
2004-05-17 17:50 ` pinskia at gcc dot gnu dot org
2004-05-24 23:10 ` pinskia at gcc dot gnu dot org
2005-05-08 19:08 ` pinskia at gcc dot gnu dot org
     [not found] <bug-15350-4@http.gcc.gnu.org/bugzilla/>
2014-10-31  4:02 ` pinskia at gcc dot gnu.org
2015-06-09 17:23 ` glisse 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).