public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/16052] New: strength reduction produces wrong code
@ 2004-06-18 10:28 yamt at mwd dot biglobe dot ne dot jp
  2004-06-18 16:12 ` [Bug rtl-optimization/16052] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: yamt at mwd dot biglobe dot ne dot jp @ 2004-06-18 10:28 UTC (permalink / raw)
  To: gcc-bugs

siro% /usr/local/gcc3/bin/gcc -v
Reading specs from /usr/local/gcc3/lib/gcc/i386-unknown-netbsdelf2.0F/3.4.0/specs
Configured with: ./configure --prefix=/usr/local/gcc3_4 : (reconfigured) ./configure --prefix=/usr/local/gcc3 --enable-languages=c
Thread model: posix
gcc version 3.4.0


"gcc -O2 -S a.c" produces wrong code.

note that the produced code uses "jle" insn for loop condition.
because what it attempts to check is "p < (original value of p)+N*M",
it should use an unsigned comparison.

== a.c (source code) ==================================================

#include <stdio.h>

typedef int a_t;

inline void
h1(const a_t *p)
{

	printf("%p\n", p);
}

#define	N 800
#define	M 4

void
h(const a_t *p)
{
	int j;

	for (j = 0; j < N; j++) {
		h1(p + j*M);
	}
}

#if 1
#ifdef _LP64
#define	PTRBIT	64
#else
#define	PTRBIT	32
#endif
int
main(int argc, char **argv)
{

	h((void *) ((1ULL << (PTRBIT - 1)) - sizeof(a_t) * N * M));
}
#endif

== a.s (produced code) ==================================================

	.file	"a.c"
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%p\n"
	.text
	.p2align 2,,3
.globl h1
	.type	h1, @function
h1:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$16, %esp
	pushl	8(%ebp)
	pushl	$.LC0
	call	printf
	leave
	ret
	.size	h1, .-h1
	.p2align 2,,3
.globl h
	.type	h, @function
h:
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%esi
	pushl	%ebx
	movl	8(%ebp), %ebx
	leal	12784(%ebx), %esi
	.p2align 2,,3
.L7:
	subl	$8, %esp
	pushl	%ebx
	pushl	$.LC0
	addl	$16, %ebx
	call	printf
	addl	$16, %esp
	cmpl	%esi, %ebx
	jle	.L7
	leal	-8(%ebp), %esp
	popl	%ebx
	popl	%esi
	leave
	ret
	.size	h, .-h
	.p2align 2,,3
.globl main
	.type	main, @function
main:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
	andl	$-16, %esp
	subl	$28, %esp
	pushl	$2147470848
	call	h
	leave
	ret
	.size	main, .-main
	.ident	"GCC: (GNU) 3.4.0"

-- 
           Summary: strength reduction produces wrong code
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: yamt at mwd dot biglobe dot ne dot jp
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-unknown-netbsdelf2.0F
  GCC host triplet: i386-unknown-netbsdelf2.0F
GCC target triplet: i386-unknown-netbsdelf2.0F


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


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

* [Bug rtl-optimization/16052] strength reduction produces wrong code
  2004-06-18 10:28 [Bug c/16052] New: strength reduction produces wrong code yamt at mwd dot biglobe dot ne dot jp
@ 2004-06-18 16:12 ` pinskia at gcc dot gnu dot org
  2004-06-18 20:26 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-18 16:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-18 16:12 -------
Confirmed, -O2 -march=i386 is needed to reproduce it on i686-pc-linux-gnu (well any i?86 really)

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c                           |rtl-optimization
     Ever Confirmed|                            |1
           Keywords|                            |wrong-code
      Known to fail|                            |2.95.3 3.2.3 3.3.4 3.4.0
                   |                            |3.5.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-06-18 16:12:41
               date|                            |


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


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

* [Bug rtl-optimization/16052] strength reduction produces wrong code
  2004-06-18 10:28 [Bug c/16052] New: strength reduction produces wrong code yamt at mwd dot biglobe dot ne dot jp
  2004-06-18 16:12 ` [Bug rtl-optimization/16052] " pinskia at gcc dot gnu dot org
@ 2004-06-18 20:26 ` pinskia at gcc dot gnu dot org
  2004-06-18 20:28 ` [Bug rtl-optimization/16052] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-18 20:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-18 20:26 -------
*** Bug 16066 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |debian-gcc at lists dot
                   |                            |debian dot org


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


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

* [Bug rtl-optimization/16052] [3.4/3.5 Regression] strength reduction produces wrong code
  2004-06-18 10:28 [Bug c/16052] New: strength reduction produces wrong code yamt at mwd dot biglobe dot ne dot jp
  2004-06-18 16:12 ` [Bug rtl-optimization/16052] " pinskia at gcc dot gnu dot org
  2004-06-18 20:26 ` pinskia at gcc dot gnu dot org
@ 2004-06-18 20:28 ` pinskia at gcc dot gnu dot org
  2004-08-29 19:02 ` mmitchel at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-18 20:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-18 20:28 -------
Hmm, I did not test 3.3.4 at all, so this might be just a regression I do not know, but the debian folks 
think it is.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at codesourcery dot com
      Known to fail|2.95.3 3.2.3 3.3.4 3.4.0    |2.95.3 3.2.3 3.3.3 3.4.0
                   |3.5.0                       |3.5.0
            Summary|strength reduction produces |[3.4/3.5 Regression]
                   |wrong code                  |strength reduction produces
                   |                            |wrong code
   Target Milestone|---                         |3.4.2


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


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

* [Bug rtl-optimization/16052] [3.4/3.5 Regression] strength reduction produces wrong code
  2004-06-18 10:28 [Bug c/16052] New: strength reduction produces wrong code yamt at mwd dot biglobe dot ne dot jp
                   ` (2 preceding siblings ...)
  2004-06-18 20:28 ` [Bug rtl-optimization/16052] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-08-29 19:02 ` mmitchel at gcc dot gnu dot org
  2004-11-01  0:45 ` [Bug rtl-optimization/16052] [3.4/4.0 " mmitchel at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-29 19:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-08-29 19:02 -------
Postponed until GCC 3.4.3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.2                       |3.4.3


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


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

* [Bug rtl-optimization/16052] [3.4/4.0 Regression] strength reduction produces wrong code
  2004-06-18 10:28 [Bug c/16052] New: strength reduction produces wrong code yamt at mwd dot biglobe dot ne dot jp
                   ` (3 preceding siblings ...)
  2004-08-29 19:02 ` mmitchel at gcc dot gnu dot org
@ 2004-11-01  0:45 ` mmitchel at gcc dot gnu dot org
  2004-12-04 13:43 ` steven at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-11-01  0:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-11-01 00:45 -------
Postponed until GCC 3.4.4.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.3                       |3.4.4


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


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

* [Bug rtl-optimization/16052] [3.4/4.0 Regression] strength reduction produces wrong code
  2004-06-18 10:28 [Bug c/16052] New: strength reduction produces wrong code yamt at mwd dot biglobe dot ne dot jp
                   ` (4 preceding siblings ...)
  2004-11-01  0:45 ` [Bug rtl-optimization/16052] [3.4/4.0 " mmitchel at gcc dot gnu dot org
@ 2004-12-04 13:43 ` steven at gcc dot gnu dot org
  2004-12-05 12:08 ` [Bug rtl-optimization/16052] " ebotcazou at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: steven at gcc dot gnu dot org @ 2004-12-04 13:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2004-12-04 13:43 -------
Fails on all ix86

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|i386-unknown-netbsdelf2.0F  |
   GCC host triplet|i386-unknown-netbsdelf2.0F  |
 GCC target triplet|i386-unknown-netbsdelf2.0F  |


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


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

* [Bug rtl-optimization/16052] strength reduction produces wrong code
  2004-06-18 10:28 [Bug c/16052] New: strength reduction produces wrong code yamt at mwd dot biglobe dot ne dot jp
                   ` (5 preceding siblings ...)
  2004-12-04 13:43 ` steven at gcc dot gnu dot org
@ 2004-12-05 12:08 ` ebotcazou at gcc dot gnu dot org
  2005-01-31  6:54 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2004-12-05 12:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ebotcazou at gcc dot gnu dot org  2004-12-05 12:08 -------
> Fails on all ix86

Yeah, this is the classical problem with biv elimination to pointer givs.  See
gcc.c-torture/execute/loop-2e.c, which is XFAILed on x86.  Not a regression.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[3.4/4.0 Regression]        |strength reduction produces
                   |strength reduction produces |wrong code
                   |wrong code                  |
   Target Milestone|3.4.4                       |4.0.0


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


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

* [Bug rtl-optimization/16052] strength reduction produces wrong code
  2004-06-18 10:28 [Bug c/16052] New: strength reduction produces wrong code yamt at mwd dot biglobe dot ne dot jp
                   ` (6 preceding siblings ...)
  2004-12-05 12:08 ` [Bug rtl-optimization/16052] " ebotcazou at gcc dot gnu dot org
@ 2005-01-31  6:54 ` pinskia at gcc dot gnu dot org
  2005-05-02  0:54 ` pinskia at gcc dot gnu dot org
  2005-06-01 13:18 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-31  6:54 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.0                       |---


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


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

* [Bug rtl-optimization/16052] strength reduction produces wrong code
  2004-06-18 10:28 [Bug c/16052] New: strength reduction produces wrong code yamt at mwd dot biglobe dot ne dot jp
                   ` (7 preceding siblings ...)
  2005-01-31  6:54 ` pinskia at gcc dot gnu dot org
@ 2005-05-02  0:54 ` pinskia at gcc dot gnu dot org
  2005-06-01 13:18 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-02  0:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-02 00:54 -------
Fixed for 4.0.0.

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


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


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

* [Bug rtl-optimization/16052] strength reduction produces wrong code
  2004-06-18 10:28 [Bug c/16052] New: strength reduction produces wrong code yamt at mwd dot biglobe dot ne dot jp
                   ` (8 preceding siblings ...)
  2005-05-02  0:54 ` pinskia at gcc dot gnu dot org
@ 2005-06-01 13:18 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-01 13:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-01 13:18 -------
*** Bug 21862 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu dot org


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


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

end of thread, other threads:[~2005-06-01 13:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-18 10:28 [Bug c/16052] New: strength reduction produces wrong code yamt at mwd dot biglobe dot ne dot jp
2004-06-18 16:12 ` [Bug rtl-optimization/16052] " pinskia at gcc dot gnu dot org
2004-06-18 20:26 ` pinskia at gcc dot gnu dot org
2004-06-18 20:28 ` [Bug rtl-optimization/16052] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
2004-08-29 19:02 ` mmitchel at gcc dot gnu dot org
2004-11-01  0:45 ` [Bug rtl-optimization/16052] [3.4/4.0 " mmitchel at gcc dot gnu dot org
2004-12-04 13:43 ` steven at gcc dot gnu dot org
2004-12-05 12:08 ` [Bug rtl-optimization/16052] " ebotcazou at gcc dot gnu dot org
2005-01-31  6:54 ` pinskia at gcc dot gnu dot org
2005-05-02  0:54 ` pinskia at gcc dot gnu dot org
2005-06-01 13:18 ` 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).