Conversation
|
It has nothing to do with the argument aliasiing. Here's a repro: I think it's related to the early return here: https://github.com/holiman/uint256/pull/111/files#diff-af4a4c8b4e176a360fd1472a72691c2ffab2426e94f4e69829a48bd12f01a908R512 |
|
Shouldn't it rather be something like this: |
|
in case thanks @holiman |
I have tested and all tests got |
| } | ||
| } | ||
|
|
||
| if uLen < dLen { |
There was a problem hiding this comment.
from #111 (comment) ,so it should be
if uLen < dLen {
copy(rem[:], u[:])
return rem
}
There was a problem hiding this comment.
Heh, I think the point has already been made :)
There was a problem hiding this comment.
Sorry, I just wanted to formal mark this point 😂
There was a problem hiding this comment.
Except we need to handle u[:] more carefully here because it may be bigger than Int. Is rem Int all zeros at function start?
|
Should be good now. Do you think we should benchmark this? |
Codecov Report
@@ Coverage Diff @@
## master #111 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 1385 1388 +3
=========================================
+ Hits 1385 1388 +3 |
I mean, doesn't hurt, but not a blocker for me |
|
It makes it faster (probably by accident). |
|
It looks that with additional check and "copy/return" block the total number of instructions is almost exactly the same as before so maybe this saves us some additional bounds checks down the line. https://godbolt.org/z/jq5KesEen |
|
|
I wanted to make
udivrem()more robust by making it handle the case where nominator is smaller than divisor (currently it will panic weirdly in this case).I'm testing the change though
TestRandomDivandTestRandomModwheredivrawandmodrawwrappers are provided.The
modrawfails a test when a param and result are aliased. I have not been able to figure out the cause of the problem so far.