Bug 44727 - [4.6 Regression] Failed to bootstrap with --with-cpu=atom
Summary: [4.6 Regression] Failed to bootstrap with --with-cpu=atom
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-30 15:46 UTC by H.J. Lu
Modified: 2010-07-01 17:46 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
A patch (334 bytes, patch)
2010-07-01 00:09 UTC, H.J. Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2010-06-30 15:46:48 UTC
On Linux/x86-64, revision 161604 failed to bootstrap with
--with-cpu=atom.  I got

Premature end of .class file ../../../../src-trunk/libjava/classpath/lib/java/lang/AbstractStringBuffer.class.

Revision 161569 is OK. It could be related to peephole change.
Comment 1 H.J. Lu 2010-06-30 19:26:31 UTC
-mtune=atom miscompiled gcj.
Comment 2 H.J. Lu 2010-06-30 21:02:08 UTC
jcf-parse.o is miscompiled.
Comment 3 H.J. Lu 2010-06-30 21:10:09 UTC
-mtune=atom works with 32bit build.
Comment 4 Bernd Schmidt 2010-06-30 21:52:02 UTC
I can reproduce this.  I haven't found the problem, but it seems to go away if I remove m_ATOM from X86_TUNE_OPT_AGU.  Is it possible that there's a bug related to this in i386.*?
Comment 5 H.J. Lu 2010-06-30 21:53:38 UTC
Function get_attribute is miscompiled. The difference is

--
--- /tmp/good.s	2010-06-30 14:36:46.971155015 -0700
+++ /tmp/bad.s	2010-06-30 14:38:49.211031644 -0700
@@ -3966,18 +3966,18 @@ get_attribute:
 	jne	.L499
 	movq	104(%rdi), %rcx
 	movq	%rax, %rdi
-	addq	%rdx, %rax
+	leaq	(%rax,%rdx), %rax
 	subq	0(%rbp), %rdi
+	leaq	2(%rax), %rdx
 	orl	$-1, %ebx
 	movq	%rdi, 8(%rcx)
-	leaq	2(%rax), %rdx
 	movq	%rdx, 16(%rbp)
 	movzbl	(%rax), %eax
+	movl	%esi, %edi
 	sall	$8, %eax
 	movzbl	-1(%rdx), %ecx
 	orl	%eax, %ecx
-	sall	$3, %ecx
-	leal	(%rcx,%rsi), %esi
+	leal	(%rdi,%rcx,8), %esi
 	cmpl	%esi, %r13d
 	jb	.L381
 	movslq	%ecx, %rcx
--
Comment 6 Bernd Schmidt 2010-06-30 22:08:11 UTC
Ok, thanks for investigating.  I think we may need something like this:

@@ -17574,6 +17574,7 @@ (define_peephole2
 	    || GET_MODE (operands[0]) == HImode))
        || GET_MODE (operands[0]) == SImode
        || (TARGET_64BIT && GET_MODE (operands[0]) == DImode))
+   && peep2_reg_dead_p (2, operands[0])
    /* We reorder load and the shift.  */
    && !reg_overlap_mentioned_p (operands[0], operands[4])"
   [(set (match_dup 5) (match_dup 4))

Testing now.
Comment 7 H.J. Lu 2010-06-30 22:18:25 UTC
(In reply to comment #6)
> Ok, thanks for investigating.  I think we may need something like this:
> 
> @@ -17574,6 +17574,7 @@ (define_peephole2
>             || GET_MODE (operands[0]) == HImode))
>         || GET_MODE (operands[0]) == SImode
>         || (TARGET_64BIT && GET_MODE (operands[0]) == DImode))
> +   && peep2_reg_dead_p (2, operands[0])
>     /* We reorder load and the shift.  */
>     && !reg_overlap_mentioned_p (operands[0], operands[4])"
>    [(set (match_dup 5) (match_dup 4))
> 
> Testing now.
> 

The old peepgole2 pattern has

   /* The intermediate operand 0 must die or be same as output.  */
   && (rtx_equal_p (operands[0], operands[5])
       || peep2_reg_dead_p (3, operands[0]))"
Comment 8 H.J. Lu 2010-07-01 00:09:14 UTC
Created attachment 21051 [details]
A patch

Here is the a patch. We need

rtx_equal_p (operands[0], operands[3])

Otherwise, I got

FAIL: gcc.target/i386/lea.c scan-assembler leal
Comment 9 Bernd Schmidt 2010-07-01 09:20:56 UTC
Subject: Bug 44727

Author: bernds
Date: Thu Jul  1 09:20:40 2010
New Revision: 161656

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161656
Log:
	PR target/44727
	* config/i386/i386.md (peephole2 for arithmetic ops with memory):
	Make sure operand 0 dies.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.md

Comment 10 H.J. Lu 2010-07-01 17:46:01 UTC
Fixed.