public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement.
@ 2004-04-05 22:50 kazu at cs dot umass dot edu
  2004-04-05 23:00 ` [Bug optimization/14859] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-04-05 22:50 UTC (permalink / raw)
  To: gcc-bugs

Consider:

void bar (void);

int
foo (int a)
{
  int b;
  switch (a)
    {
    case 14: b = 123; break;
    case 15: b = 123; break;
    case 16: b = 123; break;
    default: b = 0; break;
    }
  return b;
}

I get:

foo (a)
{
  int b;

<bb 0>:
  switch (a)
    {
      case 14: goto <L0>;
      case 15: goto <L1>;
      case 16: goto <L2>;
      default : goto <L6>;
    }

<L6>:;
  b = 0;
  goto <bb 4> (<L4>);

<L0>:;
  b = 123;
  goto <bb 4> (<L4>);

<L1>:;
  b = 123;
  goto <bb 4> (<L4>);

<L2>:;
  b = 123;

<L4>:;
  return b;

}

If we look at this t54.vars, the problem appears to be fomulated as
cross jumping, but if we look at t51.tailc, the problem appears to be
a simple jump optimization while updating PHI.

foo (a)
{
  int b;

<bb 0>:
  switch (a_2)
    {
      case 14: goto <L0>;
      case 15: goto <L1>;
      case 16: goto <L2>;
      default : goto <L4>;
    }

<L0>:;
  goto <bb 4> (<L4>);

<L1>:;
  goto <bb 4> (<L4>);

<L2>:;

  # b_1 = PHI <0(0), 123(3), 123(2), 123(1)>;
<L4>:;
  return b_1;

}

If cross jumping sounds too machine-dependent, we could limit ourselves
to the PHI-aware jump optimization like above.

-- 
           Summary: [tree-ssa] integrate identical cases of a switch
                    statement.
           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=14859


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

* [Bug optimization/14859] [tree-ssa] integrate identical cases of a switch statement.
  2004-04-05 22:50 [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement kazu at cs dot umass dot edu
@ 2004-04-05 23:00 ` pinskia at gcc dot gnu dot org
  2004-05-24 21:31 ` [Bug tree-optimization/14859] " pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-05 23:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-05 23:00 -------
Actually this is a size/speed win on every target because at least for this case you can do a range 
comparision after combing the BB in the switch statement.
For PPC, foo1 is the one where they are combined.
_foo:
        cmpwi cr7,r3,15
        cmpwi cr6,r3,16
        xori r0,r3,14
        addic r0,r0,-1
        subfe r0,r0,r0
        li r3,123
        beqlr- cr7
        andi. r3,r0,123
        bnelr+ cr6
        li r3,123
        blr
        .align 2
        .globl _foo1
_foo1:
        addi r0,r3,-14
        subfic r3,r0,2
        subfe r3,r3,r3
        nand r3,r3,r3
        andi. r3,r3,123
        blr

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-04-05 23:00:42
               date|                            |
   Target Milestone|---                         |tree-ssa


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


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

* [Bug tree-optimization/14859] [tree-ssa] integrate identical cases of a switch statement.
  2004-04-05 22:50 [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement kazu at cs dot umass dot edu
  2004-04-05 23:00 ` [Bug optimization/14859] " pinskia at gcc dot gnu dot org
@ 2004-05-24 21:31 ` pinskia at gcc dot gnu dot org
  2004-05-31  6:04 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-24 21:31 UTC (permalink / raw)
  To: gcc-bugs



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


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


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

* [Bug tree-optimization/14859] [tree-ssa] integrate identical cases of a switch statement.
  2004-04-05 22:50 [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement kazu at cs dot umass dot edu
  2004-04-05 23:00 ` [Bug optimization/14859] " pinskia at gcc dot gnu dot org
  2004-05-24 21:31 ` [Bug tree-optimization/14859] " pinskia at gcc dot gnu dot org
@ 2004-05-31  6:04 ` pinskia at gcc dot gnu dot org
  2004-08-12  1:51 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-31  6:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-30 04:52 -------
I think this can be fixed when PR 11832 gets fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |11832


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


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

* [Bug tree-optimization/14859] [tree-ssa] integrate identical cases of a switch statement.
  2004-04-05 22:50 [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement kazu at cs dot umass dot edu
                   ` (2 preceding siblings ...)
  2004-05-31  6:04 ` pinskia at gcc dot gnu dot org
@ 2004-08-12  1:51 ` pinskia at gcc dot gnu dot org
  2004-10-03 21:06 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-12  1:51 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |16996
              nThis|                            |


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


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

* [Bug tree-optimization/14859] [tree-ssa] integrate identical cases of a switch statement.
  2004-04-05 22:50 [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement kazu at cs dot umass dot edu
                   ` (3 preceding siblings ...)
  2004-08-12  1:51 ` pinskia at gcc dot gnu dot org
@ 2004-10-03 21:06 ` pinskia at gcc dot gnu dot org
  2004-10-19  4:29 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-03 21:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-03 21:06 -------
Really a patch to fix PR 16447 should fix this one too because the PHI nodes elements are the same
and we combine cases which go to the same BB if they are next to each other after out of ssa happens.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |16447


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


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

* [Bug tree-optimization/14859] [tree-ssa] integrate identical cases of a switch statement.
  2004-04-05 22:50 [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement kazu at cs dot umass dot edu
                   ` (4 preceding siblings ...)
  2004-10-03 21:06 ` pinskia at gcc dot gnu dot org
@ 2004-10-19  4:29 ` pinskia at gcc dot gnu dot org
  2004-11-02  1:29 ` pinskia at gcc dot gnu dot org
  2004-11-02  1:29 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-19  4:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-19 04:29 -------
And I was right on the tree-cleanup-branch:
        addi r3,r3,-14
        subfic r3,r3,2
        subfe r3,r3,r3
        nand r3,r3,r3
        andi. r3,r3,123
        blr

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.1.0


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


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

* [Bug tree-optimization/14859] [tree-ssa] integrate identical cases of a switch statement.
  2004-04-05 22:50 [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement kazu at cs dot umass dot edu
                   ` (5 preceding siblings ...)
  2004-10-19  4:29 ` pinskia at gcc dot gnu dot org
@ 2004-11-02  1:29 ` pinskia at gcc dot gnu dot org
  2004-11-02  1:29 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-02  1:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-02 01:29 -------
Fixed also on the mainline.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.1.0                       |4.0.0


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


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

* [Bug tree-optimization/14859] [tree-ssa] integrate identical cases of a switch statement.
  2004-04-05 22:50 [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement kazu at cs dot umass dot edu
                   ` (6 preceding siblings ...)
  2004-11-02  1:29 ` pinskia at gcc dot gnu dot org
@ 2004-11-02  1:29 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-02  1:29 UTC (permalink / raw)
  To: gcc-bugs



-- 
Bug 14859 depends on bug 16447, which changed state.

Bug 16447 Summary: out of ssa generates bloated code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16447

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

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


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

end of thread, other threads:[~2004-11-02  1:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-05 22:50 [Bug optimization/14859] New: [tree-ssa] integrate identical cases of a switch statement kazu at cs dot umass dot edu
2004-04-05 23:00 ` [Bug optimization/14859] " pinskia at gcc dot gnu dot org
2004-05-24 21:31 ` [Bug tree-optimization/14859] " pinskia at gcc dot gnu dot org
2004-05-31  6:04 ` pinskia at gcc dot gnu dot org
2004-08-12  1:51 ` pinskia at gcc dot gnu dot org
2004-10-03 21:06 ` pinskia at gcc dot gnu dot org
2004-10-19  4:29 ` pinskia at gcc dot gnu dot org
2004-11-02  1:29 ` pinskia at gcc dot gnu dot org
2004-11-02  1:29 ` 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).