From 8a06bb28a0ab7f40dd77172845f87ee28b076d89 Mon Sep 17 00:00:00 2001 From: mratsim Date: Fri, 20 Apr 2018 11:55:15 +0200 Subject: [PATCH] Improve codegen for borrow. Fix #10 --- src/private/uint_binary_ops.nim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/private/uint_binary_ops.nim b/src/private/uint_binary_ops.nim index bf06540..d5ae0fb 100644 --- a/src/private/uint_binary_ops.nim +++ b/src/private/uint_binary_ops.nim @@ -35,9 +35,8 @@ proc `-=`*(x: var MpUintImpl, y: MpUintImpl) {.noSideEffect, inline.}= # Optimized assembly should contain sbb instruction (substract with borrow) # Clang on MacOS does with the -d:release switch and MpUint[uint32] (uint64) type SubTy = type x.lo - let original = x.lo + x.hi -= (x.lo < x.lo).toSubtype(SubTy) + y.hi x.lo -= y.lo - x.hi -= (original < x.lo).toSubtype(SubTy) + y.hi proc `-`*(x, y: MpUintImpl): MpUintImpl {.noSideEffect, noInit, inline.}= # Substraction for multi-precision unsigned int