public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/15484] New: [tree-ssa] bool and short function arguments promoted to int
@ 2004-05-17 19:20 dann at godzilla dot ics dot uci dot edu
  2004-05-17 19:22 ` [Bug tree-optimization/15484] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: dann at godzilla dot ics dot uci dot edu @ 2004-05-17 19:20 UTC (permalink / raw)
  To: gcc-bugs

This code: 

_Bool bar (_Bool a);
_Bool foo1 (_Bool a)
{
  if (bar(a))     return 1;
  else            return 0;
}

static short barshort (short a);
short foo1short (short a)
{
  if (barshort(a))     return 1;
  else                 return 0;
}

is transformed to: (when using -O -fdump-tree-generic)

foo1 (a)
{
  int T.17;
  _Bool T.18;

  T.17 = (int)a; <------ this is not needed
  T.18 = bar (T.17);
  if (T.18 != 0)
    {
      return 1;
    }
  else
    {
      return 0;
    }
}

foo1short (a)
{
  int T.19;
  short int T.20;

  T.19 = (int)a; <------ this is not needed
  T.20 = barshort (T.19);
  if (T.20 != 0)
    {
      return 1;
    }
  else
    {
      return 0;
    }
}

the promotions shown are not needed, at least not at this point in the
compilation process.

-- 
           Summary: [tree-ssa] bool and short function arguments promoted to
                    int
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dann at godzilla dot ics dot uci dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug tree-optimization/15484] [tree-ssa] bool and short function arguments promoted to int
  2004-05-17 19:20 [Bug tree-optimization/15484] New: [tree-ssa] bool and short function arguments promoted to int dann at godzilla dot ics dot uci dot edu
@ 2004-05-17 19:22 ` pinskia at gcc dot gnu dot org
  2004-11-17 13:33 ` nathan at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-17 19:22 UTC (permalink / raw)
  To: gcc-bugs


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

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
 GCC target triplet|                            |i686-*-*
           Keywords|                            |pessimizes-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-05-17 04:37:40
               date|                            |


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


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

* [Bug tree-optimization/15484] [tree-ssa] bool and short function arguments promoted to int
  2004-05-17 19:20 [Bug tree-optimization/15484] New: [tree-ssa] bool and short function arguments promoted to int dann at godzilla dot ics dot uci dot edu
  2004-05-17 19:22 ` [Bug tree-optimization/15484] " pinskia at gcc dot gnu dot org
@ 2004-11-17 13:33 ` nathan at gcc dot gnu dot org
  2004-12-29  1:33 ` dann at godzilla dot ics dot uci dot edu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: nathan at gcc dot gnu dot org @ 2004-11-17 13:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2004-11-17 13:33 -------
The underlying ABI might require short & bool arguments to be passed as int. 
Some do, some don't.  Anyway, that's an argument marshalling issue, which is not
currently addressed at the tree level.

The cast to int has been inserted by the front end, I think C requires that.

This is a VRP issue, not an argument marshalling one.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |18373


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


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

* [Bug tree-optimization/15484] [tree-ssa] bool and short function arguments promoted to int
  2004-05-17 19:20 [Bug tree-optimization/15484] New: [tree-ssa] bool and short function arguments promoted to int dann at godzilla dot ics dot uci dot edu
  2004-05-17 19:22 ` [Bug tree-optimization/15484] " pinskia at gcc dot gnu dot org
  2004-11-17 13:33 ` nathan at gcc dot gnu dot org
@ 2004-12-29  1:33 ` dann at godzilla dot ics dot uci dot edu
  2005-05-16 13:55 ` rguenth at gcc dot gnu dot org
  2005-06-02 18:44 ` dnovillo at gcc dot gnu dot org
  4 siblings, 0 replies; 8+ messages in thread
From: dann at godzilla dot ics dot uci dot edu @ 2004-12-29  1:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dann at godzilla dot ics dot uci dot edu  2004-12-29 01:33 -------
(In reply to comment #2)
> The underlying ABI might require short & bool arguments to be passed as int. 
> Some do, some don't.  Anyway, that's an argument marshalling issue, which is not
> currently addressed at the tree level.
> 
> The cast to int has been inserted by the front end, I think C requires that.
> 
> This is a VRP issue, not an argument marshalling one.

A discussion about this is at:

http://gcc.gnu.org/ml/gcc/2004-05/msg00752.html

in that thread Jim Wilson has some more explanations about what is going on.

A patch that seems to work is also in that mail, but I won't have time to 
properly test it to try to get it committed anytime soon. If someone wants to
play with this, it would be great.

The problem is that the C and C++ front-ends generate casts to int when
c_promoting_integer_type_p returns true. Those casts are generated too early 
(if they are needed at all, and they might not be needed). Iff the casts are
needed they should be when lowering to RTL.



-- 


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


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

* [Bug tree-optimization/15484] [tree-ssa] bool and short function arguments promoted to int
  2004-05-17 19:20 [Bug tree-optimization/15484] New: [tree-ssa] bool and short function arguments promoted to int dann at godzilla dot ics dot uci dot edu
                   ` (2 preceding siblings ...)
  2004-12-29  1:33 ` dann at godzilla dot ics dot uci dot edu
@ 2005-05-16 13:55 ` rguenth at gcc dot gnu dot org
  2005-06-02 18:44 ` dnovillo at gcc dot gnu dot org
  4 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-05-16 13:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at gcc dot gnu dot org  2005-05-16 13:55 -------
Maybe the same problem results in

static inline bool wrap(bool f) { return f; }
bool bar(bool f)
{
        return wrap(f);
}

producing

  return (int) (bool) (int) (bool) (int) f;

(and more, if you add another wrap())

-- 


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


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

* [Bug tree-optimization/15484] [tree-ssa] bool and short function arguments promoted to int
  2004-05-17 19:20 [Bug tree-optimization/15484] New: [tree-ssa] bool and short function arguments promoted to int dann at godzilla dot ics dot uci dot edu
                   ` (3 preceding siblings ...)
  2005-05-16 13:55 ` rguenth at gcc dot gnu dot org
@ 2005-06-02 18:44 ` dnovillo at gcc dot gnu dot org
  4 siblings, 0 replies; 8+ messages in thread
From: dnovillo at gcc dot gnu dot org @ 2005-06-02 18:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dnovillo at gcc dot gnu dot org  2005-06-02 18:44 -------

How is this related to VRP at all?  Removing dependency on 18373.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|18373                       |


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


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

* [Bug tree-optimization/15484] [tree-ssa] bool and short function arguments promoted to int
       [not found] <bug-15484-1008@http.gcc.gnu.org/bugzilla/>
  2008-11-20 23:28 ` dann at godzilla dot ics dot uci dot edu
@ 2008-11-20 23:36 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-11-20 23:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2008-11-20 23:35 -------
(In reply to comment #6)
> Still happens in 4.4. 

But as mentioned this is not really a bug.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


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


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

* [Bug tree-optimization/15484] [tree-ssa] bool and short function arguments promoted to int
       [not found] <bug-15484-1008@http.gcc.gnu.org/bugzilla/>
@ 2008-11-20 23:28 ` dann at godzilla dot ics dot uci dot edu
  2008-11-20 23:36 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 8+ messages in thread
From: dann at godzilla dot ics dot uci dot edu @ 2008-11-20 23:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from dann at godzilla dot ics dot uci dot edu  2008-11-20 23:27 -------
Still happens in 4.4. 


-- 

dann at godzilla dot ics dot uci dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |memory-hog


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


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

end of thread, other threads:[~2008-11-20 23:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-17 19:20 [Bug tree-optimization/15484] New: [tree-ssa] bool and short function arguments promoted to int dann at godzilla dot ics dot uci dot edu
2004-05-17 19:22 ` [Bug tree-optimization/15484] " pinskia at gcc dot gnu dot org
2004-11-17 13:33 ` nathan at gcc dot gnu dot org
2004-12-29  1:33 ` dann at godzilla dot ics dot uci dot edu
2005-05-16 13:55 ` rguenth at gcc dot gnu dot org
2005-06-02 18:44 ` dnovillo at gcc dot gnu dot org
     [not found] <bug-15484-1008@http.gcc.gnu.org/bugzilla/>
2008-11-20 23:28 ` dann at godzilla dot ics dot uci dot edu
2008-11-20 23:36 ` 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).