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

48-bit bitwise not emits __snot instead of __i48not #48

Open
runer112 opened this issue Nov 11, 2024 · 0 comments
Open

48-bit bitwise not emits __snot instead of __i48not #48

runer112 opened this issue Nov 11, 2024 · 0 comments

Comments

@runer112
Copy link

runer112 commented Nov 11, 2024

Demonstration: https://discord.com/channels/432891584451706892/1184990251769397380/1305595574246182952

Compiling c -std=gnu11 in -Oz for ez80:

int48_t foo(int48_t x) { return ~x; }
public	_foo
_foo:
	call	__frameset0
	ld	hl, (ix + 6)
	ld	de, (ix + 9)
	call	__snot
	pop	ix
	ret

	extern	__snot
	extern	__frameset0
jacobly0 pushed a commit that referenced this issue Nov 29, 2024
…5185)

As function calls do not generally preserve X16 and X17, it is beneficial
to allow AddrDisc operand of BLRA instruction to reside in these
registers and make use of this condition when computing the
discriminator.

This can save up to two MOVs in cases such as loading a (signed) virtual
function pointer via a (signed) pointer to vtable, for example

    ldr   x9, [x16]
    mov   x8, x16
    mov   x17, x8
    movk  x17, llvm#34646, lsl #48
    blraa x9, x17

can be simplified to

    ldr   x8, [x16]
    movk  x16, llvm#34646, lsl #48
    blraa x8, x16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant