From db9f64d2f3ddfdced770f6a29fe145c289b68dab Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 9 May 2017 11:43:58 -0700 Subject: [PATCH] Make `srem` have the sign of the dividend. This is how remainder is defined in C (as of C99), C++ (as of C++11), Rust, and WebAssembly, for example. --- lib/cretonne/meta/base/instructions.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/cretonne/meta/base/instructions.py b/lib/cretonne/meta/base/instructions.py index b9d2d5a5af..5777ed76ea 100644 --- a/lib/cretonne/meta/base/instructions.py +++ b/lib/cretonne/meta/base/instructions.py @@ -683,14 +683,13 @@ urem = Instruction( srem = Instruction( 'srem', """ - Signed integer remainder. + Signed integer remainder. The result has the sign of the dividend. This operation traps if the divisor is zero. .. todo:: Integer remainder vs modulus. - Clarify whether the result has the sign of the divisor or the - dividend. Should we add a ``smod`` instruction for the case where + Should we add a ``smod`` instruction for the case where the result has the same sign as the divisor? """, ins=(x, y), outs=a, can_trap=True)