Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VBCC backend generates unnecessary register assignments (even when using -O3) #182

Open
sy2002 opened this issue Oct 31, 2020 · 0 comments
Assignees
Labels

Comments

@sy2002
Copy link
Owner

sy2002 commented Oct 31, 2020

Possibly a challenge in the backend (c/qnice/compiler-backend/machine.c). Volker said that it is not trivial. I am creating this issue, so that we are not forgetting about it. Right now, we can for sure live with it. But we are wasting 4 CPU cycles (or more) in certain function calls in C, for example in Monitor wrapper functions.


Here is the email I wrote to Volker on October, 28 2020:

[...]

qmon is a wrapper library, that wraps our "Operating System" functions.

For example this here calls the OS function "mulu" that takes two 16bit unsigned values and returns a 32bit signed value:

unsigned long def_qmon_mulu(unsigned int a, unsigned int b) =
  "          ASUB     " M2S(QMON_EP_MULU) ", 1\n"           //call MTH$MULU in monitor (expects a in R8, b in R9)
  "          MOVE     R10, R8\n"                            //R10 = low word
  "          MOVE     R11, R9\n";                           //R11 = high word

unsigned long qmon_mulu(unsigned int a, unsigned int b)
{
    return def_qmon_mulu(a, b);
}

The library code, is compiled with these switches and looks like this:

vc src/qmon.c -o lib/qmon.o -c -O3 -k -c99 -rw-threshold=0 -speed

_qmon_mulu:
	incrb
	move	R8,R0
	move	R9,R10
	move	R0,R8
	move	R10,R9
          ASUB     0x0028, 1
          MOVE     R10, R8
          MOVE     R11, R9

	decrb
	move	@R13++,R15

Note the redundant

MOVE R8, R0 
MOVE R0, R8

and

MOVE R9, R10
MOVE R10, R9

statements.

Is this an easy or hard fix?

This is not a big deal, so we for sure can live with it for the time being. Particularly, if this is due to some structural challenges or if fixing this might lead to an increased danger of regressions.


Here is his answer:

[...]

It is not easy enough to make any promises unfortunately.

@sy2002 sy2002 added the V2.0 label Oct 31, 2020
@sy2002 sy2002 self-assigned this Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant