Improve codegen for borrow. Fix #10

This commit is contained in:
mratsim 2018-04-20 11:55:15 +02:00
parent 6eeba3d41a
commit 8a06bb28a0
1 changed files with 1 additions and 2 deletions

View File

@ -35,9 +35,8 @@ proc `-=`*(x: var MpUintImpl, y: MpUintImpl) {.noSideEffect, inline.}=
# Optimized assembly should contain sbb instruction (substract with borrow) # Optimized assembly should contain sbb instruction (substract with borrow)
# Clang on MacOS does with the -d:release switch and MpUint[uint32] (uint64) # Clang on MacOS does with the -d:release switch and MpUint[uint32] (uint64)
type SubTy = type x.lo type SubTy = type x.lo
let original = x.lo x.hi -= (x.lo < x.lo).toSubtype(SubTy) + y.hi
x.lo -= y.lo x.lo -= y.lo
x.hi -= (original < x.lo).toSubtype(SubTy) + y.hi
proc `-`*(x, y: MpUintImpl): MpUintImpl {.noSideEffect, noInit, inline.}= proc `-`*(x, y: MpUintImpl): MpUintImpl {.noSideEffect, noInit, inline.}=
# Substraction for multi-precision unsigned int # Substraction for multi-precision unsigned int