Mike
Mike
Manually written code utilizing WHILE primitive: ``` gcd: ; (a b -- gcd) PUSHCONT { DUP ; ( -- a b b) ISPOS ; ( -- a b s) }...
An experimental version with cfg as state machine ``` gcd: ;; static cfg description NIL ; placeholder, zero bb PUSHCONT { ; bb 1, entry DUP ISPOS ; branch condition...
The c13 global register used in the code above must be saved and restored around a call to any functions generated in such a manner. So here is a version...
Results of measuring gas consumption for all gcd variants. ``` #include "ton-sdk/tvm.h" extern int gcd(int, int); TVM_CUSTOM_EXCEPTION(FAILED, 101); void bench_Impl() { ACCEPT(); tvm_assert(gcd(20988936657440586486151264256610222593863921, 67280421310721) == 1, FAILED); } ``` |...
Update: | Variant | Gas | | --- | --- | | baseline | 4547 | | clang | 10235 | | structured cf | 6005 | | state machine...
Keeping basic blocks on the stack right before arguments, 6875 units of gas: ``` gcd: PUSHCONT { ; entry DUP ISPOS PUSH s4 ; {loop} PUSH s4 ; {exit} IFELSE...
The idea is surely eligible for the kind of machine you have. Though I'm not sure that LLVM is a right framework for trying to implement the idea. To answer...
What actually bothers me about this approach is a support of high-level control-flow primitives like WHILE, UNTIL, REPEAT...
From what I see from performance analysis of a certain C++ sample, a huge number of basic blocks (301 in that code to be precise) looks like a problem by...