public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19835] New: [AVR] Loop variable gets widened to LONG instead of int
@ 2005-02-09 10:13 andrewhutchinson at cox dot net
  2005-02-09 10:21 ` [Bug tree-optimization/19835] [4.0 Regression] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: andrewhutchinson at cox dot net @ 2005-02-09 10:13 UTC (permalink / raw)
  To: gcc-bugs

GNU C version 4.0.0 20041205 (experimental) (avr)

Loop variable gets widened to LONG instead of unsigned int (or perhaps even
int). Seems we forgeot how big the target is?

Testcase:

struct S19 { unsigned char i[19]; };
void						
init (struct S19 *p, int i)			
{						
  int j;					
  for (j = 0; j < 19; j++)			
    p->i[j] = i + j;				
}	


tree dump:


;; Function init (init)

init (p, i)
{
  long unsigned int ivtmp.3;

<bb 0>:
  ivtmp.3 = 0;

<L0>:;
  ((unsigned char *) ivtmp.3 + &p->i[0])->i[0] = (unsigned char) ivtmp.3 +
(unsigned char) (signed char) i;
  ivtmp.3 = ivtmp.3 + 1;
  if (ivtmp.3 != 19) goto <L0>; else goto <L2>;

<L2>:;
  return;

}

Not surprisingly, backend code reflects long (SImode) decrement and compare :

/* prologue: frame size=0 */
/* prologue end (size=0) */
	movw r26,r24
	ldi r18,lo8(0)
	ldi r19,hi8(0)
	ldi r20,hlo8(0)
	ldi r21,hhi8(0)
.L2:
	movw r30,r26
	add r30,r18
	adc r31,r19
	mov r24,r18
	add r24,r22
	st Z,r24
	subi r18,lo8(-(1))
	sbci r19,hi8(-(1))
	sbci r20,hlo8(-(1))
	sbci r21,hhi8(-(1))
	cpi r18,lo8(19)
	cpc r19,__zero_reg__
	cpc r20,__zero_reg__
	cpc r21,__zero_reg__
	brne .L2
/* epilogue: frame size=0 */
	ret

-- 
           Summary: [AVR] Loop variable gets widened to LONG instead of int
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrewhutchinson at cox dot net
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: cygwin
GCC target triplet: avr


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


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

* [Bug tree-optimization/19835] [4.0 Regression] [AVR] Loop variable gets widened to LONG instead of int
  2005-02-09 10:13 [Bug c/19835] New: [AVR] Loop variable gets widened to LONG instead of int andrewhutchinson at cox dot net
@ 2005-02-09 10:21 ` pinskia at gcc dot gnu dot org
  2005-02-09 13:07 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-09 10:21 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |tree-optimization
           Keywords|                            |missed-optimization
            Summary|[AVR] Loop variable gets    |[4.0 Regression] [AVR] Loop
                   |widened to LONG instead of  |variable gets widened to
                   |int                         |LONG instead of int


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


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

* [Bug tree-optimization/19835] [4.0 Regression] [AVR] Loop variable gets widened to LONG instead of int
  2005-02-09 10:13 [Bug c/19835] New: [AVR] Loop variable gets widened to LONG instead of int andrewhutchinson at cox dot net
  2005-02-09 10:21 ` [Bug tree-optimization/19835] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2005-02-09 13:07 ` pinskia at gcc dot gnu dot org
  2005-02-14  0:37 ` schlie at comcast dot net
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-09 13:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-09 07:17 -------
There has to be a reason why we want to use long int instead of the integer type which is the same size 
of the pointer.

Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   GCC host triplet|cygwin                      |
   Last reconfirmed|0000-00-00 00:00:00         |2005-02-09 07:17:58
               date|                            |


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


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

* [Bug tree-optimization/19835] [4.0 Regression] [AVR] Loop variable gets widened to LONG instead of int
  2005-02-09 10:13 [Bug c/19835] New: [AVR] Loop variable gets widened to LONG instead of int andrewhutchinson at cox dot net
  2005-02-09 10:21 ` [Bug tree-optimization/19835] [4.0 Regression] " pinskia at gcc dot gnu dot org
  2005-02-09 13:07 ` pinskia at gcc dot gnu dot org
@ 2005-02-14  0:37 ` schlie at comcast dot net
  2005-03-05 19:58 ` [Bug tree-optimization/19835] [4.0/4.1 " pinskia at gcc dot gnu dot org
  2005-09-20 22:29 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: schlie at comcast dot net @ 2005-02-14  0:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schlie at comcast dot net  2005-02-13 18:30 -------
(In reply to comment #1)
> There has to be a reason why we want to use long int instead of the integer
> type which is the same size 

There's no doubt that someone may have thought so, but it's wrong;
as there's no valid reason to effectively transform (int)j into a temp of
any greater rank unsigned type. (as there is no valid reason to ever
require an unsigned index to memory of greater rank than a pointer). 

Further, given that GCC knows the bounds of the variable (i.e. 0 >= j <= 19)
temp should most correctly have been typed as an (unsigned char) QI mode.
(which undoubtedly could only likely help subsequent optimizations to know)


-- 


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


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

* [Bug tree-optimization/19835] [4.0/4.1 Regression] [AVR] Loop variable gets widened to LONG instead of int
  2005-02-09 10:13 [Bug c/19835] New: [AVR] Loop variable gets widened to LONG instead of int andrewhutchinson at cox dot net
                   ` (2 preceding siblings ...)
  2005-02-14  0:37 ` schlie at comcast dot net
@ 2005-03-05 19:58 ` pinskia at gcc dot gnu dot org
  2005-09-20 22:29 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-05 19:58 UTC (permalink / raw)
  To: gcc-bugs



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


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


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

* [Bug tree-optimization/19835] [4.0/4.1 Regression] [AVR] Loop variable gets widened to LONG instead of int
  2005-02-09 10:13 [Bug c/19835] New: [AVR] Loop variable gets widened to LONG instead of int andrewhutchinson at cox dot net
                   ` (3 preceding siblings ...)
  2005-03-05 19:58 ` [Bug tree-optimization/19835] [4.0/4.1 " pinskia at gcc dot gnu dot org
@ 2005-09-20 22:29 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-20 22:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-20 22:29 -------
Fixed on the mainline.

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


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


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

end of thread, other threads:[~2005-09-20 22:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-09 10:13 [Bug c/19835] New: [AVR] Loop variable gets widened to LONG instead of int andrewhutchinson at cox dot net
2005-02-09 10:21 ` [Bug tree-optimization/19835] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-02-09 13:07 ` pinskia at gcc dot gnu dot org
2005-02-14  0:37 ` schlie at comcast dot net
2005-03-05 19:58 ` [Bug tree-optimization/19835] [4.0/4.1 " pinskia at gcc dot gnu dot org
2005-09-20 22: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).