public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions
@ 2004-02-25  4:11 kazu at cs dot umass dot edu
  2004-02-25  4:55 ` [Bug optimization/14287] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-02-25  4:11 UTC (permalink / raw)
  To: gcc-bugs

/* test.c */

short g, h;

void
foo (long a)
{
  short b = a & 3;
  long c = b;
  g = c;
  h = c;
}

test.c.t20.dom1 looks like so:

foo (a)
{
  long int c;
  short int b;
  short int T.1;
  short int T.0;

<bb 0>:
  T.0_2 = (short int)a_1;
  b_3 = T.0_2 & 3;
  c_4 = (long int)b_3;
  T.1_5 = (short int)c_4; <- Hey, T.1_5 == b_3!
  g = T.1_5;
  T.1_6 = T.1_5;
  h = T.1_5;
  return;
}

Here is the asm:

foo:
	movl	4(%esp), %eax
	andl	$3, %eax
	cwtl                   <- ugly
	movw	%ax, g
	movw	%ax, h
	ret

I inserted "g" and "h" to kill the combiner as it performs badly
when there are multiple uses of variables. :-)
The exactly same problem appears on H8.

-- 
           Summary: [tree-ssa] does not remove unnecessary extensions
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          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
GCC target triplet: i686-pc-linux-gnu, h8300-elf


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


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

* [Bug optimization/14287] [tree-ssa] does not remove unnecessary extensions
  2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
@ 2004-02-25  4:55 ` pinskia at gcc dot gnu dot org
  2004-02-25  5:18 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-25  4:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-02-25 04:55 -------
Confirmed, this is a performance regression from the mainline.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |normal
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |pessimizes-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-02-25 04:55:03
               date|                            |
   Target Milestone|---                         |tree-ssa


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


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

* [Bug optimization/14287] [tree-ssa] does not remove unnecessary extensions
  2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
  2004-02-25  4:55 ` [Bug optimization/14287] " pinskia at gcc dot gnu dot org
@ 2004-02-25  5:18 ` pinskia at gcc dot gnu dot org
  2004-02-25 18:51 ` amacleod at redhat dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-25  5:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-02-25 05:18 -------
No this is not a regression, I was looking at the asm wrong as the compiler that Kazu used was an i386 
compiler while mine is for i686.  This happens on the mainline too.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


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


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

* [Bug optimization/14287] [tree-ssa] does not remove unnecessary extensions
  2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
  2004-02-25  4:55 ` [Bug optimization/14287] " pinskia at gcc dot gnu dot org
  2004-02-25  5:18 ` pinskia at gcc dot gnu dot org
@ 2004-02-25 18:51 ` amacleod at redhat dot com
  2004-03-03 18:13 ` kazu at cs dot umass dot edu
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: amacleod at redhat dot com @ 2004-02-25 18:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From amacleod at redhat dot com  2004-02-25 18:51 -------
huh, how did that happen, this went to the wrong bugzilla case. 
Sorry.... this patch is not for this case . I didnt even have this one open
anywhere. huh.

Andrew



-- 


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


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

* [Bug optimization/14287] [tree-ssa] does not remove unnecessary extensions
  2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
                   ` (2 preceding siblings ...)
  2004-02-25 18:51 ` amacleod at redhat dot com
@ 2004-03-03 18:13 ` kazu at cs dot umass dot edu
  2004-03-04  4:08 ` kazu at cs dot umass dot edu
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-03-03 18:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-03-03 18:13 -------
Mine.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |kazu at cs dot umass dot edu
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug optimization/14287] [tree-ssa] does not remove unnecessary extensions
  2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
                   ` (3 preceding siblings ...)
  2004-03-03 18:13 ` kazu at cs dot umass dot edu
@ 2004-03-04  4:08 ` kazu at cs dot umass dot edu
  2004-03-16 21:50 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-03-04  4:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-03-04 04:08 -------
I'm not sure if I can quickly implement remove sign/zero extensions elimination
in a (almost always) profitable way.

It's more involved than I thought. :-(


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|kazu at cs dot umass dot edu|unassigned at gcc dot gnu
                   |                            |dot org
             Status|ASSIGNED                    |NEW


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


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

* [Bug optimization/14287] [tree-ssa] does not remove unnecessary extensions
  2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
                   ` (4 preceding siblings ...)
  2004-03-04  4:08 ` kazu at cs dot umass dot edu
@ 2004-03-16 21:50 ` pinskia at gcc dot gnu dot org
  2004-03-17  1:46 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-16 21:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-16 21:50 -------
Mine.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


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


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

* [Bug optimization/14287] [tree-ssa] does not remove unnecessary extensions
  2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
                   ` (5 preceding siblings ...)
  2004-03-16 21:50 ` pinskia at gcc dot gnu dot org
@ 2004-03-17  1:46 ` pinskia at gcc dot gnu dot org
  2004-04-03  5:06 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-17  1:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-17 01:46 -------
Actually it is not that involved at all.
Basically here is how my pass works:
For each block:
  For each statement in the block:
    is the statement is a modify expression and the RHS is a cast then:
      is the cast's operand's definition a modifiy express and its RHS a cast also:
        Do the inner and outer types match and is the intermediate's type size is larger or 
equal to the outer's type then remove change the statement to point to the outer variable.

Let DCE do its work with respect to getting rid of the intermediate variable.

-- 


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


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

* [Bug optimization/14287] [tree-ssa] does not remove unnecessary extensions
  2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
                   ` (6 preceding siblings ...)
  2004-03-17  1:46 ` pinskia at gcc dot gnu dot org
@ 2004-04-03  5:06 ` pinskia at gcc dot gnu dot org
  2004-05-17 17:20 ` [Bug tree-optimization/14287] " pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-03  5:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-03 05:06 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-04/msg00169.html>, I forgot to 
mention this PR in the patch as this was the PR which got me thinking about casts in the 
first place.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


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


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

* [Bug tree-optimization/14287] [tree-ssa] does not remove unnecessary extensions
  2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
                   ` (7 preceding siblings ...)
  2004-04-03  5:06 ` pinskia at gcc dot gnu dot org
@ 2004-05-17 17:20 ` pinskia at gcc dot gnu dot org
  2004-05-24 16:53 ` pinskia at gcc dot gnu dot org
  2004-06-21  5:07 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-17 17:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-17 01:36 -------
Actually I found out that fold can do the same simplier and it also can be the done using 
the combine pass I am poposing in PR 15459.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |15459
           Keywords|patch                       |


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


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

* [Bug tree-optimization/14287] [tree-ssa] does not remove unnecessary extensions
  2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
                   ` (8 preceding siblings ...)
  2004-05-17 17:20 ` [Bug tree-optimization/14287] " pinskia at gcc dot gnu dot org
@ 2004-05-24 16:53 ` pinskia at gcc dot gnu dot org
  2004-06-21  5:07 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-24 16:53 UTC (permalink / raw)
  To: gcc-bugs



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


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


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

* [Bug tree-optimization/14287] [tree-ssa] does not remove unnecessary extensions
  2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
                   ` (9 preceding siblings ...)
  2004-05-24 16:53 ` pinskia at gcc dot gnu dot org
@ 2004-06-21  5:07 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-21  5:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-21 05:07 -------
With the tree-combiner (which I am going to post soon), I get:

foo (a)
{
  short int T.1;

<bb 0>:
  T.1 = (short int)a & 3;
  g = T.1;
  h = T.1;
  return;

}

-- 


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


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

end of thread, other threads:[~2004-06-21  5:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-25  4:11 [Bug optimization/14287] New: [tree-ssa] does not remove unnecessary extensions kazu at cs dot umass dot edu
2004-02-25  4:55 ` [Bug optimization/14287] " pinskia at gcc dot gnu dot org
2004-02-25  5:18 ` pinskia at gcc dot gnu dot org
2004-02-25 18:51 ` amacleod at redhat dot com
2004-03-03 18:13 ` kazu at cs dot umass dot edu
2004-03-04  4:08 ` kazu at cs dot umass dot edu
2004-03-16 21:50 ` pinskia at gcc dot gnu dot org
2004-03-17  1:46 ` pinskia at gcc dot gnu dot org
2004-04-03  5:06 ` pinskia at gcc dot gnu dot org
2004-05-17 17:20 ` [Bug tree-optimization/14287] " pinskia at gcc dot gnu dot org
2004-05-24 16:53 ` pinskia at gcc dot gnu dot org
2004-06-21  5:07 ` 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).