Bug 10988 - [m32r-elf] wrong blockmove code with -O3
[m32r-elf] wrong blockmove code with -O3
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: target
3.3
: P2 normal
: 3.3.2
Assigned To: Not yet assigned to anyone
: wrong-code
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-05-27 03:17 UTC by inaoka.kazuhiro
Modified: 2003-09-02 19:06 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: m32r-elf
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-05-28 19:58:29


Attachments
PATCH (3.74 KB, patch)
2003-05-27 03:23 UTC, inaoka.kazuhiro
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description inaoka.kazuhiro 2003-05-27 03:17:29 UTC
Executing on host: /home4/inaoka/work/work-org_src/build.gcc-3.3/gcc/xgcc -
B/home4/inaoka/work/work-org_src/build.gcc-3.3/gcc/ /home4/inaoka/work/work-
org_src/gcc-3.3/gcc/testsuite/gcc.c-torture/execute/931004-11.c testglue.o  -
w  -O3 -fomit-frame-pointer       -Wl,-wrap,exit -Wl,-wrap,main -Wl,-
wrap,abort -lm   -o /home4/inaoka/work/work-org_src/build.gcc-
3.3/gcc/testsuite/931004-11.x3    (timeout = 300)
PASS: gcc.c-torture/execute/931004-11.c compilation,  -O3 -fomit-frame-pointer

*** EXIT code 4242
FAIL: gcc.c-torture/execute/931004-11.c execution,  -O3 -fomit-frame-pointer
Executing on host: /home4/inaoka/work/work-org_src/build.gcc-3.3/gcc/xgcc -
B/home4/inaoka/work/work-org_src/build.gcc-3.3/gcc/ /home4/inaoka/work/work-
org_src/gcc-3.3/gcc/testsuite/gcc.c-torture/execute/931004-11.c testglue.o  -
w  -O3 -g       -Wl,-wrap,exit -Wl,-wrap,main -Wl,-wrap,abort -lm   -
o /home4/inaoka/work/work-org_src/build.gcc-3.3/gcc/testsuite/931004-11.x4    
(timeout = 300)
PASS: gcc.c-torture/execute/931004-11.c compilation,  -O3 -g

*** EXIT code 4242
FAIL: gcc.c-torture/execute/931004-11.c execution,  -O3 -g

The following is a testcase.
<blockmove.c>
struct tiny
{
  char c;
  char d;
  char e;
};

inline f (int n, struct tiny x, struct tiny y)
{
  if (x.c != 10)
    abort();
  if (x.d != 20)
    abort();
  if (x.e != 30)
    abort();
}
  
main ()
{ 
  struct tiny x[2];
  x[0].c = 10;
  x[1].c = 11;
  x[0].d = 20;
  x[1].d = 21;
  x[0].e = 30;
  x[1].e = 31;
  f (3, x[0], x[1]);
  exit(sizeof(struct tiny));
}   

Command Line: m32r-elf-gcc -S -O3 blockmove.c
<blockmove.s>
Assemble source output:
	.section .text
	.balign 4
	.global	main
	.type	main, @function
main:
	; PROLOGUE, vars= 16, regs= 1, args= 0, extra= 0
	push lr
	ldi r1,#31
	addi sp,#-16
	ldi r4,#20
	stb r1,@(5,sp)		; x[1].e = 31
	stb r4,@(1,sp)		; x[0].d = 20
	add3 r2,sp,#8
	ldi r5,#21
	ldi r6,#11
	ldi r3,#30
	stb r6,@(3,sp)		; x[1].c = 11
	stb r5,@(4,sp)		; x[1].d = 21
	stb r3,@(2,sp)		; x[0].e = 30
	ldi r0,#10
	mv r1,sp		; R1 == &x[0]  *** NG *** 
	stb r0,@(sp)			; x[0].c = 10
	ld	r5, @r1
	sra3	r4, r5, #16		; r4 = x[0].c x[0].d
	sth	r4, @(0,r2)
	srai	r5, #8
	stb	r5, @(2,r2)		; r5 = x[0].e
	add3 r0,sp,#12
	ldi r2,#3	; 0x3
	bl memcpy		; R1 (wrong address)
	ldb r0,@(8,sp)
	addi r0,#-10
	bnez r0,.L6
	ldb r7,@(9,sp)
	addi r7,#-20
	bnez r7,.L6
	ldb lr,@(10,sp)
	addi lr,#-30
	beqz lr,.L5
.L6:
	bl abort
.L5:
	ldi r0,#3	; 0x3
	bl exit
	; EPILOGUE
	addi sp,#16
	pop lr
	jmp lr
	.size	main, .-main
	.balign 4
	.global	f
	.type	f, @function
f:
	; PROLOGUE, vars= 8, regs= 1, args= 0, extra= 0
	push lr
	slli r1,#8
	addi sp,#-8
	slli r2,#8
	st r2,@(4,sp)
	st r1,@(sp)
	ldb r1,@(sp)
	addi r1,#-10
	bnez r1,.L11
	ldb r1,@(1,sp)
	addi r1,#-20
	bnez r1,.L11
	ldb r2,@(2,sp)
	addi r2,#-30
	beqz r2,.L10
.L11:
	bl abort
.L10:
	; EPILOGUE
	addi sp,#8
	pop lr
	jmp lr
	.size	f, .-f
	.ident	"GCC: (GNU) 3.3"
Comment 1 inaoka.kazuhiro 2003-05-27 03:23:05 UTC
Created attachment 4085 [details]
PATCH
Comment 2 Dara Hazeghi 2003-05-28 19:58:29 UTC
Hello,

I can confirm this behavior on gcc 3.3 branch and mainline (20030526). Hopefully someone will 
review you patch soon.

Dara
Comment 3 Dara Hazeghi 2003-06-29 05:56:10 UTC
Kazuhiro,

has your patch been applied yet? Thanks,

Dara
Comment 4 inaoka.kazuhiro 2003-06-30 01:53:54 UTC
Subject: Re:  [m32r-elf] wrong blockmove code with -O3

It's not applied yet.
I signed to Copyright Assignment and sent it off two days ago.

Kazuhiro
Comment 5 CVS Commits 2003-09-02 11:02:26 UTC
Subject: Bug 10988

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	nickc@gcc.gnu.org	2003-09-02 11:02:16

Modified files:
	gcc            : ChangeLog 
	gcc/config/m32r: m32r-protos.h m32r.c m32r.h m32r.md 

Log message:
	Apply fix for PR 10988:
	* m32r.c (m32r_print_operand): Correct comment.
	(m32r_expand_block_move): Correct the handling of leftover/small blocks.
	(m32r_block_small_immediate_operand): New predicate.
	* m32r.md (movstrsi_small_internal): New pattern.
	* m32r.h (PREDICATE_CODES): Add m32r_block_small_immediate_operand.
	* m32r-protos.h: Add prototype for m32r_block_small_immediate_operand.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.718&r2=1.16114.2.719
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m32r/m32r-protos.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.13&r2=1.13.20.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m32r/m32r.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.57&r2=1.57.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m32r/m32r.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.73&r2=1.73.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m32r/m32r.md.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.25&r2=1.25.4.1

Comment 6 Andrew Pinski 2003-09-02 13:33:03 UTC
Nick should this be closed as it does not effect the mainline and now the patch went in for 
the 3.3 branch?
Comment 7 Nick Clifton 2003-09-02 17:23:59 UTC
Subject: Re:  [m32r-elf] wrong blockmove code with -O3

Hi Pinskia,

> Nick should this be closed as it does not effect the mainline and
> now the patch went in for  the 3.3 branch?

Yes please.

Cheers
        Nick

Comment 8 Andrew Pinski 2003-09-02 19:06:48 UTC
Fixed for 3.3.2.