unexpected call to ASH-LEFT-MOD64

Bug #903821 reported by Nikodemus Siivola on 2011-12-13
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

(defun lowmask (x n)
  (declare (sb-ext:word x)
           (type (integer 0 #.(1- sb-vm:n-word-bits)) n)
           (optimize speed))
  (logandc2 x (ash -1 n)))

; 05C0B0C2: 488D5C24F0 LEA RBX, [RSP-16] ; no-arg-parsing entry point
; 0C7: 4883EC18 SUB RSP, 24
; 0D2: 488B0507FFFFFF MOV RAX, [RIP-249] ; #<FDEFINITION object for SB-VM::ASH-LEFT-MOD64>
; 0D9: B904000000 MOV ECX, 4
; 0DE: 48892B MOV [RBX], RBP
; 0E1: 488BEB MOV RBP, RBX
; 0E4: FF5009 CALL QWORD PTR [RAX+9]
; 0E7: 488BC2 MOV RAX, RDX
; 0EA: A801 TEST AL, 1
; 0EC: 7406 JEQ L0
; 0EE: 488B40F9 MOV RAX, [RAX-7]
; 0F2: EB03 JMP L1
; 0F4: L0: 48D1F8 SAR RAX, 1
; 0F7: L1: 48F7D0 NOT RAX
; 0FA: 488B4DF8 MOV RCX, [RBP-8]
; 0FE: 4821C1 AND RCX, RAX
; 101: 486BD102 IMUL RDX, RCX, 2
; 105: 710E JNO L2
; 107: 488BD1 MOV RDX, RCX
; 10A: 4C8D1C2550060020 LEA R11, [#x20000650] ; ALLOC-SIGNED-BIGNUM-IN-RDX
; 112: 41FFD3 CALL R11
; 115: L2: 488BE5 MOV RSP, RBP
; 118: F8 CLC
; 119: 5D POP RBP
; 11A: C3 RET

 status fixcommitted

commit 52b1041d3a14eaa4e45f6d8edfbdc0dec4292239
Author: Christophe Rhodes <email address hidden>
Date: Thu Apr 5 19:55:05 2012 +0100

    Fix bug in unsigned modular arithmetic using a signed implementation

    If we aim to be clever by implementing an unsigned modular arithmetic
    computation using signed arithmetic, we need to make sure that we
    don't accidentally contaminate the computation with any extraneous
    high bits. This means that we must be sure to cut constants to the
    appropriate width, as well as computations, so do so; this fixes
    bug #974406 from Paul Dietz. (In addition the change from cutting
    to the requested width to the implementation width fixes #903821,
    so Go Team!)

    Test cases. Minimally horrible test case for #903821; far worse
    suggestions were made on #sbcl IRC...

Changed in sbcl:
status: Triaged → Fix Committed
Stas Boukarev (stassats) on 2012-05-21
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers