emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master c1c8b67: Check that signed right shift is arithmeti


From: Paul Eggert
Subject: [Emacs-diffs] master c1c8b67: Check that signed right shift is arithmetic
Date: Fri, 19 May 2017 16:43:42 -0400 (EDT)

branch: master
commit c1c8b67246c4314b302cca2ac43f13a0baba4c16
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Check that signed right shift is arithmetic
    
    * src/data.c (ash_lsh_impl): Verify that signed right shift is
    arithmetic; if we run across a compiler that uses a logical shift
    we’ll need to complicate the code before removing this
    compile-time check.  Help the compiler do common subexpression
    elimination better.
---
 src/data.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/data.c b/src/data.c
index 3ff2a80..4242b90 100644
--- a/src/data.c
+++ b/src/data.c
@@ -3066,9 +3066,12 @@ usage: (logxor &rest INTS-OR-MARKERS)  */)
 }
 
 static Lisp_Object
-ash_lsh_impl (register Lisp_Object value, Lisp_Object count, bool lsh)
+ash_lsh_impl (Lisp_Object value, Lisp_Object count, bool lsh)
 {
-  register Lisp_Object val;
+  /* This code assumes that signed right shifts are arithmetic.  */
+  verify ((EMACS_INT) -1 >> 1 == -1);
+
+  Lisp_Object val;
 
   CHECK_NUMBER (value);
   CHECK_NUMBER (count);
@@ -3076,12 +3079,12 @@ ash_lsh_impl (register Lisp_Object value, Lisp_Object 
count, bool lsh)
   if (XINT (count) >= EMACS_INT_WIDTH)
     XSETINT (val, 0);
   else if (XINT (count) > 0)
-    XSETINT (val, XUINT (value) << XFASTINT (count));
+    XSETINT (val, XUINT (value) << XINT (count));
   else if (XINT (count) <= -EMACS_INT_WIDTH)
     XSETINT (val, lsh ? 0 : XINT (value) < 0 ? -1 : 0);
   else
-    XSETINT (val, lsh ? XUINT (value) >> -XINT (count) : \
-                        XINT (value) >> -XINT (count));
+    XSETINT (val, (lsh ? XUINT (value) >> -XINT (count)
+                  : XINT (value) >> -XINT (count)));
   return val;
 }
 



reply via email to

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