This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/11198] [3.3 regression] -O2 -frename-registers generates wrong code


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From ebotcazou at gcc dot gnu dot org  2003-07-04 09:20 -------
Here's the code at stake (from the buggy version, but functionally identical to
the correct version):

.L17:
	fldl	(%eax)
	movl	-40(%ebp), %ecx
	movl	(%ecx), %edx
	xorl	%ecx, %ecx
	cmpl	(%edx), %ecx

The problem is the contents of -40(%ebp).

In the correct version, -40(%ebp) is written twice in a row

	movl	(%edx), %eax
	movl	%ecx, -40(%ebp)
	movl	%edx, -40(%ebp)
	movl	%eax, -36(%ebp)

In the buggy version, -40(%ebp) is written twice too, but in the reverse order

	movl	%edx, -40(%ebp)
	movl	%ecx, -20(%ebp)
	movl	%eax, -12(%ebp)
	movl	(%edx), %eax
	movl	-48(%ebp), %edx
	movl	$0, -32(%ebp)
	movl	%eax, -36(%ebp)
	movl	%edx, -28(%ebp)
	xorl	%edx, %edx
	cmpl	(%ecx), %edx
	movl	%ecx, -40(%ebp)

The 2nd scheduling pass swaps the two sets, because the memory locations are not
marked as aliasing:

(insn:HI 27 21 40 0 0x4020fc08 (set (mem/s:SI (plus:SI (reg/f:SI 6 ebp)
                (const_int -40 [0xffffffd8])) [7 <variable>.dead1+0 S4 A32])
        (reg/v/f:SI 2 ecx [64])) 38 {*movsi_1} (insn_list 21 (nil))
    (nil))

(insn:HI 83 73 87 0 0x4020fd10 (set (mem/s:SI (plus:SI (reg/f:SI 6 ebp)
                (const_int -40 [0xffffffd8])) [5 <variable>.a+0 S4 A32])
        (reg/v/u/f:SI 1 edx [59])) 38 {*movsi_1} (nil)
    (expr_list:REG_DEAD (reg/v/u/f:SI 1 edx [59])
        (nil)))

If I understand correctly the code, the variable 'dead1' comes from the first
iterator it1, while the variable 'a' comes from the second iterator it2. For
some reason, they are wrongly given the same stack slot.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]