mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 22:41:07 +00:00
6549a4f825
That's a workaround to avoid LLVM backend crash while selecting instruction for 256-bit integer division. The workaround needs to be removed after we switch to newest inkwell that has a fix in RISC-V backend --------- Signed-off-by: kvp <mammal_windier8j@icloud.com>
42 lines
814 B
Solidity
42 lines
814 B
Solidity
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.8;
|
|
|
|
contract LargeDivRem {
|
|
function rem_2(int n) public pure returns (int q) {
|
|
assembly {
|
|
q := smod(n, 2)
|
|
}
|
|
}
|
|
|
|
function div_2(int n) public pure returns (int q) {
|
|
assembly {
|
|
q := sdiv(n, 2)
|
|
}
|
|
}
|
|
|
|
function rem_7(int n) public pure returns (int q) {
|
|
assembly {
|
|
q := smod(n, 7)
|
|
}
|
|
}
|
|
|
|
function div_7(int n) public pure returns (int q) {
|
|
assembly {
|
|
q := sdiv(n, 2)
|
|
}
|
|
}
|
|
|
|
function rem_k(int n, int k) public pure returns (int q) {
|
|
assembly {
|
|
q := smod(n, k)
|
|
}
|
|
}
|
|
|
|
function div_k(int n, int k) public pure returns (int q) {
|
|
assembly {
|
|
q := sdiv(n, k)
|
|
}
|
|
}
|
|
}
|