Thought it was worth mentioning here for anyone following developments casually rather than closely in the Discord.
This substantially increases performance and decreases the size of the code, matching or exceeding optimized VB6 builds. Often exceeding by quite a bit; for example:
On wqweto's Sieve of Eratosthenes (finds prime numbers) implementation, Wayne reports the following on his Ryzen 7950X (higher is better):
This is triple the performance of VB6 native optimized code.Code:vb6(ide): wqweto;288;5.000;1;faithful=no,bits=8 vb6(all optimizations on): wqweto;1353;5.001;1;faithful=no,bits=8 tb(debug) wqweto;962;5.006;1;faithful=no,bits=8 tb(+llvm,+optimize) wqweto;4846;5.000;1;faithful=no,bits=8
Gains are consistently substantial over different tests. Size optimization is producing code that's usually around the same size as VB6 native, optimized exes, where before the code was considerably larger-- for the code above, it's reduced from 1320 bytes to 228 bytes.Code:[ CompilerOptions ("+llvm,+optimize,+optimizesize") ] [ ArrayBoundsChecks (False) ] [ IntegerOverflowChecks (False) ] Private Function RunSieve(ByVal lSize As Long) As Long Static Bits() As Byte Dim lFactor As Long Dim lIdx As Long Dim lCount As Long On Error Resume Next lIdx = UBound(Bits) If lIdx < lSize Then ReDim Bits(0 To lSize) As Byte End If lFactor = 3 Do While lFactor * lFactor <= lSize If Not Bits(lFactor) Then For lIdx = lFactor * lFactor To lSize Step 2 * lFactor Bits(lIdx) = 1 Next End If lFactor += 2 Loop lCount = -(lSize >= 2) For lIdx = 3 To lSize Step 2 lCount += 1 - Bits(lIdx) Next Return lCount End Function Public Sub TestSieve() Dim dblStart As Double Dim lPasses As Long Debug.Assert RunSieve(1000000) = 78498 dblStart = Timer Do While Timer < dblStart + 5 RunSieve 1000000 lPasses += 1 Loop Debug.Print "wqweto;" & lPasses & ";" & Format$(Timer - dblStart, "0.000") & ";1;faithful=no,bits=8" End Sub Sub Main() TestSieve End Sub
Here's Wayne's original announcement:
Exciting times... tB is really coming together towards the 1.0 level, with this work started and nearly all VB6 features supported.As of BETA 363, professional/ultimate edition users can now use the experimental LLVM backend compiler for optimizing code. Currently, support is limited to just the basic datatypes of Byte, Integer, Long, LongLong, Single and Double. We are currently only shipping the 32-bit version of the LLVM compiler, so Win64 compilation is not yet possible.
To get started, there is a new [ CompilerOptions("") ] attribute that you can apply to procedures in a standard module. The passed string takes a series of flags separated by commas and prefixed with either +/-. To enable LLVM optimized compilation of a procedure, use the following syntax:
Please note: in future you'll be able to control these flags at the project level, and will be able to define them independently depending on whether you're building for release or for within the IDE. There are lots of features not yet supported in our LLVM compiler backend. Please monitor the DEBUG CONSOLE for error messages when you hit upon something that is not yet implemented. You'll either get a nice message in the debug console, or a hard crashCode:[ CompilerOptions ("+llvm,+optimize,+optimizesize") ] [ ArrayBoundsChecks (False) ] [ IntegerOverflowChecks (False) ] Public Function Test() As Long Return 123 End Function
Note that in the above example, we've turned off the array-bounds checks and integer-overflow checks, since error handling is not yet supported by our LLVM backend.
What's definitely not yet supported: anything to do with classes, interfaces, variants, strings, or anything similar.
What is supported: the basic integral and floating point types as noted above, arrays, global variables, UDTs, standard module function calls, and all control-flow statements (edited)
The CompilerOptions attribute allows for passing other flags to the LLVM backend. In particular it allows us to refine the target CPU options. These are the current available flags that control target CPU instruction sets:
+aes,+avx,+avx2,+bmi2,+fma,+fxsr,+lzcnt,+popcnt,+rdseed,+sha,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3 ,+xsave,+xsavec,+xsaveopt,+xsaves




Reply With Quote
