![]() |
![]() |
#1 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 829
|
vbcc code generation and dbf
Does vbcc can generate a loop with dbf ?
I'm trying to make such loop in C but without success. Without asm insertion of course. Any ideas ? |
![]() |
![]() |
#2 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
Since a byte branch offset with a subtract is smaller and faster than DBF, I wouldn't imagine it would generate a DBF for anything smaller than 128 bytes forward or 130 bytes back as an offset. Even then, I don't recall seeing a DBF optimization mentioned in the manual. The only real frequent time to see an improvement in speed with DBcc is if the condition code is not false.
|
![]() |
![]() |
#3 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 829
|
Let consider two very small examples: first take 142c second one 108c. Both doing same thing, mean nothing
Code:
moveq #10,d0 loop1 subq.b #1,d0 bne loop1 ;total 142c Code:
moveq #10-1,d0 loop2 dbf d0,loop2 ;total 108c |
![]() |
![]() |
#4 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
I doubt the vbcc 68k backend will currently generate a dbf. Some of the C static library code and assembler inlines will use it though. If i recall correctly, the startup code and 68000 inlined memcpy() will use it.
Quote:
SUBQ+Bcc.B is used by the compiler because it is more flexible. DBcc only works with a 16 bit counter and 16 bit displacement and often needs to be branched into at the start. It would be possible to make an optimization that uses DBF when the counter is 16 bit or less and static but most C code today is using 32 bit and 64 bit counters as they avoid the chances of the counter variable overflowing. Last edited by matthey; 03 October 2015 at 19:22. |
|
![]() |
![]() |
#5 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
There is code in the M68K backend to use DBF for loop constructs actually, but the conditions are never met, probably due to a bug somewhere, and it always ends up emitting the SUBQ+Bcc sequence instead.
|
![]() |
![]() |
#6 | |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 829
|
Quote:
Code:
if(loops>0){ if(!cf&&loops<=32767&&loops>=-32768){ emit(f,"\tdbra\t%s,%s%d\n",mregnames[dreg],labprefix,label); }else{ emit(f,"\tsubq.l\t#1,%s\n\tbge\t%s%d\n",mregnames[dreg],labprefix,label); } } |
|
![]() |
![]() |
#7 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Yeah I assumed that's what it was, but it seems to be part of the code for copying structs around, so matthey is right that VBCC doesn't use DBF for loops.
|
![]() |
![]() |
#8 |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Copying structures and memory use loops, at least when the copy can't be unrolled. Vbcc has sophisticated loop unrolling settings so the most common loop generating code is likely more complex than the code above. The code above almost looks too simple even for a structure copy.
|
![]() |
![]() |
#9 |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,847
|
@PHX
Not sure you read this but in case...What is the status of Vbcc regarding UB? http://www.complang.tuwien.ac.at/kps...mission_29.pdf Kamelito |
![]() |
![]() |
#10 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
|
|
![]() |
![]() |
#11 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,545
|
I agree with everything matthey has said. There is nothing to add.
![]() |
![]() |
![]() |
#12 |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,847
|
Is there any other C compiler that is doing it the right way like VBcc?
Any plan to support X64? (or 80x86 (386 and above) mean also x64...) is VBcc for plateform other than Amiga is distributed as source code only? Kamelito |
![]() |
![]() |
#13 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,545
|
Quote:
![]() BTW, Visual C++ is certainly not one of them. Last time I checked it didn't even implement the most basic C99 functionality. And Microsoft's attitude is that it doesn't matter, because everybody will use C++ anyway ... ![]() Quote:
Quote:
BTW, vbcc 0.9e is currently in the final testing phase for the release. |
|||
![]() |
![]() |
#14 |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,847
|
Maybe GCC with -Wall -Wextra -ansi -pedantic
I knew about MS, but is C99/C11 features any good, I'm sure some of them should be avoided. Kamelito |
![]() |
![]() |
#15 | ||
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Quote:
GCC is by default in slop mode (-std=GNU11). This includes POSIX support and GCCisms which can interfere with the standard (this is why phx has a different set of includes for his PosixLib). Some older GCC behavior is retained for compatibility with older GCC versions. Standards and errors are relaxed in general. GCC can be put in strict C99 (-std=c99) or C11 (-std=c11) mode. GCC with -std=c99 -pedantic switches would probably be closer to vbcc with -c99. I expect many existing GCC programs would no longer compile though. |
||
![]() |
![]() |
#16 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
I consider C11 to be interesting if for no other reason than the preprocessor supports "generic" style functionality and allows some unpopular features of C99 to be optional.
-edit- This is a subject for another thread. Last edited by Samurai_Crow; 12 March 2016 at 01:59. Reason: Off topic discussion |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
vbcc 0.9d | phx | News | 43 | 13 July 2015 19:41 |
Debugging vbcc code | tolkien | Coders. C/C++ | 5 | 14 February 2015 06:45 |
VBCC code generation | Asman | Coders. C/C++ | 9 | 17 August 2014 09:33 |
Mixed 68k / PPC code on VBCC. | Cowcat | Coders. General | 10 | 01 August 2013 16:01 |
3D code and/or internet code for Blitz Basic 2.1 | EdzUp | Retrogaming General Discussion | 0 | 10 February 2002 11:40 |
|
|