[Bug target/19683] MIPS wrong-code for 64-bit multiply.

daney at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Feb 23 06:58:00 GMT 2005


------- Additional Comments From daney at gcc dot gnu dot org  2005-02-22 22:02 -------
The new 'C' test case will reproduce the bug on:

$ mipsel-linux-gcc -v
Using built-in specs.
Target: mipsel-linux
Configured with: ../gcccvsmain/gcc/configure --target=mipsel-linux
--with-sysroot=/usr/local/mipsel-linux-test --with-arch=mips32 --with-float=soft
--prefix=/usr/local/mipsel-linux-test --with-system-zlib
--enable-languages=c,c++,java
Thread model: posix
gcc version 4.0.0 20050222 (experimental)

I have not been able to generate a 'C' test case that fails on 3.4.x.  A similar
java testcase failed on 3.3.1, but I have not tried the attached java case on 3.3.1.

Here is the setup for failure:
$ mipsel-linux-gcc -O3 -c tm.c
$ mipsel-linux-gcc -O3 -c tm_driver.c
$ mipsel-linux-gcc -o tm tm_driver.o tm.o

Then on the host:
#./tm
The answer is: 3989327253662920704

Here is the setup for success:
$ mipsel-linux-gcc -O0 -c tm.c
$ mipsel-linux-gcc -O3 -c tm_driver.c
$ mipsel-linux-gcc -o tm tm_driver.o tm.o

Then on the host:
# ./tm
The answer is: 1109030400000


If we look at the relevent part of the disassembly we see:

        li      $6,86376448                     # 0x5260000
        ori     $6,$6,0x5c00
        multu   $2,$6
        lw      $28,16($sp)
        li      $5,92340224                     # 0x5810000
        ori     $5,$5,0x1392
        lw      $25,%call16(f4)($28)
        mflo    $4
        sw      $4,24($sp)
        lw      $4,%got($LC0)($28)
        madd    $6,$3

The problem is that before the madd, we need to copy the contents of hi -> low
and then clear hi to zero.  This is not happening.




-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.0.0 3.4.3 3.3.1
            Summary|MIPS wrong-code for 64-bit  |MIPS wrong-code for 64-bit
                   |multiply from java program. |multiply.


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



More information about the Gcc-bugs mailing list