public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/16187] New: extra casts to unsigned int generated for array references
@ 2004-06-25  0:52 dann at godzilla dot ics dot uci dot edu
  2004-06-25 22:58 ` [Bug middle-end/16187] " dann at godzilla dot ics dot uci dot edu
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: dann at godzilla dot ics dot uci dot edu @ 2004-06-25  0:52 UTC (permalink / raw)
  To: gcc-bugs

The .vars dump for this function:

int f1(int *  data, int j)
{
      return  data[j];                                 
}

looks like: 

  return *((int *)((unsigned int)j * 4) + data);

The cast to "unsigned int" is probably not needed, emitting it increases the
number of statements generated, so it probably increases the memory consumption
and the amount of work the optimizers have to perform.

-- 
           Summary: extra casts to unsigned int generated for array
                    references
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: middle-end
        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=16187


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

* [Bug middle-end/16187] extra casts to unsigned int generated for array references
  2004-06-25  0:52 [Bug middle-end/16187] New: extra casts to unsigned int generated for array references dann at godzilla dot ics dot uci dot edu
@ 2004-06-25 22:58 ` dann at godzilla dot ics dot uci dot edu
  2004-06-25 23:04 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: dann at godzilla dot ics dot uci dot edu @ 2004-06-25 22:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dann at godzilla dot ics dot uci dot edu  2004-06-25 22:47 -------
The cast to unsigned int is generated by c-common.c:pointer_int_sum

See the difference in the gimple code generated for the following 2 functions:

int f1(int *  data, int j) | int f1(int *  data, unsigned int j)
{                            {
      return  data[j];             return  data[j];
}                            }

  j.1 = (unsigned int)j;   |   T.1 = j * 4;
  T.2 = j.1 * 4;           |   T.2 = (int *)T.1;
  T.3 = (int *)T.2;        |   T.3 = T.2 + data;
  T.4 = T.3 + data;        |   T.0 = *T.3;
  T.0 = *T.4;              <
  return T.0;                  return T.0;

The first case generates one extra gimple statement.


-- 


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


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

* [Bug middle-end/16187] extra casts to unsigned int generated for array references
  2004-06-25  0:52 [Bug middle-end/16187] New: extra casts to unsigned int generated for array references dann at godzilla dot ics dot uci dot edu
  2004-06-25 22:58 ` [Bug middle-end/16187] " dann at godzilla dot ics dot uci dot edu
@ 2004-06-25 23:04 ` pinskia at gcc dot gnu dot org
  2004-06-26 11:49 ` falk at debian dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-25 23:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-25 23:04 -------
Confirmed, what should be happening is that we should support ARRAY_REF for pointers too.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |memory-hog
   Last reconfirmed|0000-00-00 00:00:00         |2004-06-25 23:04:21
               date|                            |


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


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

* [Bug middle-end/16187] extra casts to unsigned int generated for array references
  2004-06-25  0:52 [Bug middle-end/16187] New: extra casts to unsigned int generated for array references dann at godzilla dot ics dot uci dot edu
  2004-06-25 22:58 ` [Bug middle-end/16187] " dann at godzilla dot ics dot uci dot edu
  2004-06-25 23:04 ` pinskia at gcc dot gnu dot org
@ 2004-06-26 11:49 ` falk at debian dot org
  2005-03-26  5:38 ` [Bug middle-end/16187] ARRAY_REF should be used for pointers also pinskia at gcc dot gnu dot org
  2005-07-24  1:03 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: falk at debian dot org @ 2004-06-26 11:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2004-06-26 10:58 -------
What architecture is that on? On 64-bit architectures, these two functions are
not equivalent; with

int a[10] = { 0 };
f1(a + 2, -2)

the first one works and the second crashes.

-- 


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


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

* [Bug middle-end/16187] ARRAY_REF should be used for pointers also
  2004-06-25  0:52 [Bug middle-end/16187] New: extra casts to unsigned int generated for array references dann at godzilla dot ics dot uci dot edu
                   ` (2 preceding siblings ...)
  2004-06-26 11:49 ` falk at debian dot org
@ 2005-03-26  5:38 ` pinskia at gcc dot gnu dot org
  2005-07-24  1:03 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-26  5:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-26 05:38 -------
http://gcc.gnu.org/wiki/Add%20MEM_REF%20operation

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


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


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

* [Bug middle-end/16187] ARRAY_REF should be used for pointers also
  2004-06-25  0:52 [Bug middle-end/16187] New: extra casts to unsigned int generated for array references dann at godzilla dot ics dot uci dot edu
                   ` (3 preceding siblings ...)
  2005-03-26  5:38 ` [Bug middle-end/16187] ARRAY_REF should be used for pointers also pinskia at gcc dot gnu dot org
@ 2005-07-24  1:03 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-24  1:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-24 01:00 -------
http://gcc.gnu.org/ml/gcc-patches/2005-06/msg02025.html

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2005-06-25 18:40:29         |2005-07-24 01:00:30
               date|                            |


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


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

* [Bug middle-end/16187] ARRAY_REF should be used for pointers also
       [not found] <bug-16187-1008@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2008-01-29  0:20 ` pinskia at gcc dot gnu dot org
@ 2008-01-29  1:04 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-01-29  1:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2008-01-29 00:19 -------
With the trunk we get:
  return *(data + (long unsigned int) j * 4);


Which is much better.  The cast is still needed though.


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

* [Bug middle-end/16187] ARRAY_REF should be used for pointers also
       [not found] <bug-16187-1008@http.gcc.gnu.org/bugzilla/>
  2005-11-13 16:47 ` pinskia at gcc dot gnu dot org
  2007-04-16  1:56 ` dberlin at gcc dot gnu dot org
@ 2008-01-29  0:20 ` pinskia at gcc dot gnu dot org
  2008-01-29  1:04 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-01-29  0:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2008-01-29 00:17 -------
I think this is basically fixed with the pointer plus work I did.


-- 


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


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

* [Bug middle-end/16187] ARRAY_REF should be used for pointers also
       [not found] <bug-16187-1008@http.gcc.gnu.org/bugzilla/>
  2005-11-13 16:47 ` pinskia at gcc dot gnu dot org
@ 2007-04-16  1:56 ` dberlin at gcc dot gnu dot org
  2008-01-29  0:20 ` pinskia at gcc dot gnu dot org
  2008-01-29  1:04 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 10+ messages in thread
From: dberlin at gcc dot gnu dot org @ 2007-04-16  1:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from dberlin at gcc dot gnu dot org  2007-04-16 02:56 -------
The version I produced was turned down, and I have not had time to rewrite it
to be what others wanted


-- 

dberlin at gcc dot gnu dot org changed:

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


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


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

* [Bug middle-end/16187] ARRAY_REF should be used for pointers also
       [not found] <bug-16187-1008@http.gcc.gnu.org/bugzilla/>
@ 2005-11-13 16:47 ` pinskia at gcc dot gnu dot org
  2007-04-16  1:56 ` dberlin at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-13 16:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2005-11-13 16:47 -------
New project for 4.2:
http://gcc.gnu.org/wiki/Array%20references%20on%20pointers


-- 


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


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

end of thread, other threads:[~2008-01-29  0:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-25  0:52 [Bug middle-end/16187] New: extra casts to unsigned int generated for array references dann at godzilla dot ics dot uci dot edu
2004-06-25 22:58 ` [Bug middle-end/16187] " dann at godzilla dot ics dot uci dot edu
2004-06-25 23:04 ` pinskia at gcc dot gnu dot org
2004-06-26 11:49 ` falk at debian dot org
2005-03-26  5:38 ` [Bug middle-end/16187] ARRAY_REF should be used for pointers also pinskia at gcc dot gnu dot org
2005-07-24  1:03 ` pinskia at gcc dot gnu dot org
     [not found] <bug-16187-1008@http.gcc.gnu.org/bugzilla/>
2005-11-13 16:47 ` pinskia at gcc dot gnu dot org
2007-04-16  1:56 ` dberlin at gcc dot gnu dot org
2008-01-29  0:20 ` pinskia at gcc dot gnu dot org
2008-01-29  1:04 ` 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).