* nasty bug in `as'
@ 1999-03-11 5:00 Tim Mooney
1999-03-16 5:00 ` Jeff Sullivan
0 siblings, 1 reply; 2+ messages in thread
From: Tim Mooney @ 1999-03-11 5:00 UTC (permalink / raw)
While compiling parts of GNU Privacy Guard (gnupg, http://www.gnupg.org) I've
stumbled upon a nasty bug in either the compiler or more likely in the `as'
for Digital Unix. The system is 4.0d, with patch set #3 (version 1 :-| )
applied.
I'm using the system C compiler and the system as, with CFLAGS set to
-std1 -tune host -arch host -Olimit 3000 -portable -readonly_strings
Here's an ls of some of the assembly files:
04:17pm dogbert mpi$ls -al mpih-mul?.S
lrwxrwxrwx 1 mooney local 26 Mar 11 16:16 mpih-mul1.S@ -> .././mpi/alpha/mpih-mul1.S
lrwxrwxrwx 1 mooney local 26 Mar 11 16:09 mpih-mul2.S@ -> .././mpi/alpha/mpih-mul2.S
lrwxrwxrwx 1 mooney local 26 Mar 11 16:09 mpih-mul3.S@ -> .././mpi/alpha/mpih-mul3.S
Here's what the first file looks like:
04:17pm dogbert mpi$cat mpih-mul1.S
/* Alpha 21064 mpih-mul1.S -- Multiply a limb vector with a limb and store
* the result in a second limb vector.
*
* Copyright (C) 1992, 1994, 1995, 1998 Free Software Foundation, Inc.
*
* This file is part of GNUPG.
*
* GNUPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GNUPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/*******************
* mpi_limb_t
* mpihelp_mul_1( mpi_ptr_t res_ptr, (r16)
* mpi_ptr_t s1_ptr, (r17)
* mpi_size_t s1_size, (r18)
* mpi_limb_t s2_limb) (r19)
*
* This code runs at 42 cycles/limb on the EV4 and 18 cycles/limb on the EV5.
*
* To improve performance for long multiplications, we would use
* 'fetch' for S1 and 'fetch_m' for RES. It's not obvious how to use
* these instructions without slowing down the general code: 1. We can
* only have two prefetches in operation at any time in the Alpha
* architecture. 2. There will seldom be any special alignment
* between RES_PTR and S1_PTR. Maybe we can simply divide the current
* loop into an inner and outer loop, having the inner loop handle
* exactly one prefetch block?
*/
.set noreorder
.set noat
.text
.align 3
.globl mpihelp_mul_1
.ent mpihelp_mul_1 2
mpihelp_mul_1:
.frame $30,0,$26
ldq $2,0($17) # $2 = s1_limb
subq $18,1,$18 # size--
mulq $2,$19,$3 # $3 = prod_low
bic $31,$31,$4 # clear cy_limb
umulh $2,$19,$0 # $0 = prod_high
beq $18,Lend1 # jump if size was == 1
ldq $2,8($17) # $2 = s1_limb
subq $18,1,$18 # size--
stq $3,0($16)
beq $18,Lend2 # jump if size was == 2
.align 3
Loop: mulq $2,$19,$3 # $3 = prod_low
addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
subq $18,1,$18 # size--
umulh $2,$19,$4 # $4 = cy_limb
ldq $2,16($17) # $2 = s1_limb
addq $17,8,$17 # s1_ptr++
addq $3,$0,$3 # $3 = cy_limb + prod_low
stq $3,8($16)
cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
addq $16,8,$16 # res_ptr++
bne $18,Loop
Lend2: mulq $2,$19,$3 # $3 = prod_low
addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
umulh $2,$19,$4 # $4 = cy_limb
addq $3,$0,$3 # $3 = cy_limb + prod_low
cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
stq $3,8($16)
addq $4,$0,$0 # cy_limb = prod_high + cy
ret $31,($26),1
Lend1: stq $3,0($16)
ret $31,($26),1
.end mpihelp_mul_1
Here's what happens when I try compile that file through the C compiler:
04:18pm dogbert mpi$gmake
cc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -std1 -tune host -arch host -Olimit 3000 -portable -readonly_strings -w -c mpih-mul1.S
-arch not understood
input buffer on non-ucode-word boundry
gmake: *** [mpih-mul1.o] Error 1
Here's the bug:
04:20pm dogbert mpi$ls -al mpih-mul?.S
lrwxrwxrwx 1 mooney local 26 Mar 11 16:09 mpih-mul2.S@ -> .././mpi/alpha/mpih-mul2.S
lrwxrwxrwx 1 mooney local 26 Mar 11 16:09 mpih-mul3.S@ -> .././mpi/alpha/mpih-mul3.S
Some part of the toolchain, has deleted the source file! Not exactly the
behavior you want from your development tools.
Note that if I invoke `as' directly, after removing the `-portable' option
since as objects to it, the source file is not deleted and an `a.out' object
file is produced.
Tim
--
Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu
Information Technology Services (701) 231-1076 (Voice)
Room 242-J1, IACC Building (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: nasty bug in `as'
1999-03-11 5:00 nasty bug in `as' Tim Mooney
@ 1999-03-16 5:00 ` Jeff Sullivan
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Sullivan @ 1999-03-16 5:00 UTC (permalink / raw)
I'm not the 'cc' driver expert, but I did ask around...
I think that you want to use .s files for Assembly source
code, not .S. The .s files are mentioned in the cc(1) man
page, but there's no mention of .S.
Here's what I found out from one of the experts:
The .S suffix has a special meaning to the driver,
which tells it to run umerge on the file first.
Because of the -O option setting, it doesn't do the umerge, but the
first thing it tries to do is a ugen, which fails.
It considers the .S file an intermediate file which it can delete.
So, the bottom line is, don't use the .S suffix.
I believe that even if the above did not happen, the .S suffix
will not be recognised as being Assembly source code. So, even
if the file is not deleted, I don't expect that it would give
you your expected results.
Let me know if you need more info.
-Jeff
--
Jeff Sullivan | Compaq Computer Corp | mailto:jps@zk3.dec.com
DEC C and C++ | Nashua, NH ZK3-2/X29 | Jeff.Sullivan@compaq.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-03-16 5:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-03-11 5:00 nasty bug in `as' Tim Mooney
1999-03-16 5:00 ` Jeff Sullivan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox