qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] f17e02: target/riscv: Zero extend the inputs


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] f17e02: target/riscv: Zero extend the inputs of divuw and ...
Date: Tue, 26 Mar 2019 02:27:54 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: f17e02cd3731bdfe2942d1d0b2a92f26da02408c
      
https://github.com/qemu/qemu/commit/f17e02cd3731bdfe2942d1d0b2a92f26da02408c
  Author: Palmer Dabbelt <address@hidden>
  Date:   2019-03-22 (Fri, 22 Mar 2019)

  Changed paths:
    M target/riscv/insn_trans/trans_rvm.inc.c
    M target/riscv/translate.c

  Log Message:
  -----------
  target/riscv: Zero extend the inputs of divuw and remuw

While running the GCC test suite against 4.0.0-rc0, Kito found a
regression introduced by the decodetree conversion that caused divuw and
remuw to sign-extend their inputs.  The ISA manual says they are
supposed to be zero extended:

    DIVW and DIVUW instructions are only valid for RV64, and divide the
    lower 32 bits of rs1 by the lower 32 bits of rs2, treating them as
    signed and unsigned integers respectively, placing the 32-bit
    quotient in rd, sign-extended to 64 bits. REMW and REMUW
    instructions are only valid for RV64, and provide the corresponding
    signed and unsigned remainder operations respectively.  Both REMW
    and REMUW always sign-extend the 32-bit result to 64 bits, including
    on a divide by zero.

Here's Kito's reduced test case from the GCC test suite

    unsigned calc_mp(unsigned mod)
    {
         unsigned a,b,c;
         c=-1;
         a=c/mod;
         b=0-a*mod;
         if (b > mod) { a += 1; b-=mod; }
         return b;
    }

    int main(int argc, char *argv[])
    {
         unsigned x = 1234;
         unsigned y = calc_mp(x);

         if ((sizeof (y) == 4 && y != 680)
      || (sizeof (y) == 2 && y != 134))
    abort ();
         exit (0);
    }

I haven't done any other testing on this, but it does fix the test case.

Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Palmer Dabbelt <address@hidden>


  Commit: 4aef51963924fd58ffe88daebbe8055a360d7c10
      
https://github.com/qemu/qemu/commit/4aef51963924fd58ffe88daebbe8055a360d7c10
  Author: Peter Maydell <address@hidden>
  Date:   2019-03-26 (Tue, 26 Mar 2019)

  Changed paths:
    M target/riscv/insn_trans/trans_rvm.inc.c
    M target/riscv/translate.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/palmer/tags/riscv-for-master-4.0-rc1' 
into staging

A Single RISC-V Patch for 4.0-rc1

If this is too late I'm OK with it being in rc2, but it fixes a concrete
regression and nobody has complained yet so I'd prefer it to be in rc1
if possible.

The fix is to zero-extend the inputs to DIVUW and REMUW, which was
exposed by the GCC test suite.

# gpg: Signature made Tue 26 Mar 2019 05:54:20 GMT
# gpg:                using RSA key 00CE76D1834960DFCE886DF8EF4CA1502CCBAB41
# gpg:                issuer "address@hidden"
# gpg: Good signature from "Palmer Dabbelt <address@hidden>" [unknown]
# gpg:                 aka "Palmer Dabbelt <address@hidden>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 00CE 76D1 8349 60DF CE88  6DF8 EF4C A150 2CCB AB41

* remotes/palmer/tags/riscv-for-master-4.0-rc1:
  target/riscv: Zero extend the inputs of divuw and remuw

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/7e9a2137ce3b...4aef51963924



reply via email to

[Prev in Thread] Current Thread [Next in Thread]