Subject: Re: today's build fails
To: Matt Thomas <matt@3am-software.com>
From: Rhialto <rhialto@falu.nl>
List: port-vax
Date: 04/20/2007 01:25:24
On Wed 18 Apr 2007 at 01:03:40 +0200, Rhialto wrote:
> No luck though on finding the vax-gcc problem (not that I really
> expected much from that but hey, I could have been lucky).

I have tried to find differences by building the toolchain on my i386
laptop, and compiling the offending file with both compilers (amd64 and
i386) with as many debugging options as I could find, and diffing the
results. I used -daP -fdump-tree-original --fdump-tree-optimized.

And differences there are! All negative numbers are sign-extended to 64
bits, for instance. I hope this is only a printing artifact, because I
don't think the host size of "long" should determine the size of
internal computations. So finding real differences was rather made more
difficult.

Here first the offending instruction and its predecessor from the .s
file:

64 (bad):

#(insn 3446 3445 3447 (set (reg:SI 0 %r0 [1940])
#        (and:SI (reg:SI 0 %r0 [1939])
#            (const_int 15 [0xf]))) 81 {*andsi_const_int} (insn_list:REG_DEP_TRUE 3445 (nil))
#    (nil))
    bicl2 $-16,%r0	# 3446	*andsi_const_int/1
#(insn 3447 3446 3448 (set (reg:SI 0 %r0 [1942])
#        (plus:SI (plus:SI (mult:SI (reg:SI 0 %r0 [1940])
#                    (const_int 8 [0x8]))
#                (reg/f:SI 17 virtual-stack-vars))
#            (const_int -128 [0xffffffffffffff80]))) 160 {movaddrdi} (insn_list:REG_DEP_TRUE 3446 (nil))
#    (nil))
    movaq -128(ALL_REGS)[%r0],%r0	# 3447	movaddrdi


32 (good):

#(insn 3446 3445 3447 (set (reg:SI 0 %r0 [1940])
#        (and:SI (reg:SI 0 %r0 [1939])
#            (const_int 15 [0xf]))) 81 {*andsi_const_int} (insn_list:REG_DEP_TRUE 3445 (nil))
#    (nil))
    bicl2 $-16,%r0	# 3446	*andsi_const_int/1
#(insn 3447 3446 3448 (set (reg:SI 0 %r0 [1942])
#        (plus:SI (plus:SI (mult:SI (reg:SI 0 %r0 [1940])
#                    (const_int 8 [0x8]))
#                (reg:SI 0 %r0 [17]))
#            (const_int -128 [0xffffff80]))) 160 {movaddrdi} (insn_list:REG_DEP_TRUE 3446 (nil))
#    (nil))
    movaq -128(%r0)[%r0],%r0	# 3447	movaddrdi

The real difference is
(reg/f:SI 17 virtual-stack-vars) vs (reg:SI 0 %r0 [17])

So we're apparently talking about expression [1940].

There is also a strange difference in int versus double, decimal versus
hex notation (it seems like a trick to fit a qword in a single entity in
the 32 bit host where it can be simply an integer on the 64 bit host)
and basic block indication. I'm not sure if it is relevant (here is 1
example):

diff -ru tmp32/sha512.SSS tmp64/sha512.SSS
--- tmp32/sha512.SSS	2007-04-20 00:12:56.000000000 +0200
+++ tmp64/sha512.SSS	2007-04-17 16:54:52.000000000 +0200
@@ -7,6 +7,7 @@
 SHA384_Init:
    .word 0x0
    subl2 $4,%sp
+	# basic block 0
 #(insn 6 9 7 (set (reg/v/f:SI 0 %r0 [orig:22 c ] [22])
 #        (mem/c/i:SI (plus:SI (reg/f:SI 12 %ap)
 #                (const_int 4 [0x4])) [0 c+0 S4 A32])) 16 {movsi_2} (nil)
@@ -15,44 +16,44 @@
 #        (nil)))
    movl 4(%ap),%r0	# 6	movsi_2
 #(insn 12 7 14 (set (mem/s/j:DI (reg/v/f:SI 0 %r0 [orig:22 c ] [22]) [0 <variable>.h+0 S8 A32])
-#        (const_double -1056596264 [0xc1059ed8] -876896931 [0xcbbb9d5d] 0 [0x0] 0 [0x0] 0 [0x0] 0 [0x0])) 15 {movdi} (insn_list:REG_DEP_TRUE 6 (nil))
+#        (const_int -3766243637369397544 [0xcbbb9d5dc1059ed8])) 15 {movdi} (insn_list:REG_DEP_TRUE 6 (nil))
 #    (nil))
-	movq $0xcbbb9d5dc1059ed8,(%r0)	# 12	movdi
+	movq $-3766243637369397544,(%r0)	# 12	movdi
 #(insn 14 12 16 (set (mem/s/j:DI (plus:SI (reg/v/f:SI 0 %r0 [orig:22 c ] [22])
 #                (const_int 8 [0x8])) [0 <variable>.h+8 S8 A32])
....

So, looking in the intermediate files for the first difference regarding
[1940], I find this last file where there is no difference:

diff -ru tmp32/sha512.c.43.ce3 tmp64/sha512.c.43.ce3
--- tmp32/sha512.c.43.ce3	2007-04-20 00:12:54.000000000 +0200
+++ tmp64/sha512.c.43.ce3	2007-04-17 16:54:52.000000000 +0200
...
@@ -15770,7 +15770,7 @@
         (plus:SI (plus:SI (mult:SI (reg:SI 0 %r0 [1940])
                     (const_int 8 [0x8]))
                 (reg/f:SI 17 virtual-stack-vars))
-            (const_int -128 [0xffffff80]))) 160 {movaddrdi} (insn_list:REG_DEP_TRUE 3446 (nil))
+            (const_int -128 [0xffffffffffffff80]))) 160 {movaddrdi} (insn_list:REG_DEP_TRUE 3446 (nil))
     (nil))
 
and here is the first one that differs (the next one):

diff -ru tmp32/sha512.c.44.rnreg tmp64/sha512.c.44.rnreg
--- tmp32/sha512.c.44.rnreg	2007-04-20 00:12:54.000000000 +0200
+++ tmp64/sha512.c.44.rnreg	2007-04-17 16:54:52.000000000 +0200
@@ -16,42 +16,42 @@
...
@@ -15763,8 +15747,8 @@
 (insn 3447 3446 3448 3 (set (reg:SI 0 %r0 [1942])
         (plus:SI (plus:SI (mult:SI (reg:SI 0 %r0 [1940])
                     (const_int 8 [0x8]))
-                (reg:SI 0 %r0 [17]))
-            (const_int -128 [0xffffff80]))) 160 {movaddrdi} (insn_list:REG_DEP_TRUE 3446 (nil))
+                (reg/f:SI 17 virtual-stack-vars))
+            (const_int -128 [0xffffffffffffff80]))) 160 {movaddrdi} (insn_list:REG_DEP_TRUE 3446 (nil))
     (nil))

Another difference in sha512.c.44.rnreg is that the 32 bit host lists a
bunch of lines like the following that the the 64 bit host doesn't:

insn 3447: replaced reg 17 with 0
insn 3488: replaced reg 17 with 0
insn 3680: replaced reg 17 with 0
...


So between dump file 43.ce3 and 44.rnreg, the compiler turns
virtual-stack-vars 17 into %r0, at least in the 32 bit host, and not on
the 64 bit host. The 44.rnreg file is produced in regrename.c.
The "replaced reg" string occurs 3 times, unfortunately.

So someone knowledgeable about gcc internals hopefully knows what it's
doing there. I hope I narrowed down the problem sufficiently to make it
~trivial.

Including the log files would make this mail about 8.3 MB longer (even
compressed) so I put them at http://www.falu.nl/~rhialto/gcc.tar.gz .

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert      -- You author it, and I'll reader it.
\X/ rhialto/at/xs4all.nl        -- Cetero censeo "authored" delendum esse.