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

Compiler emits unreachable assembly code #966

Open
vbgl opened this issue Nov 26, 2024 · 1 comment
Open

Compiler emits unreachable assembly code #966

vbgl opened this issue Nov 26, 2024 · 1 comment

Comments

@vbgl
Copy link
Member

vbgl commented Nov 26, 2024

The following jasmin program

export fn main(reg u32 x) -> reg u32 {
  reg u32 s = 0;
  if x >s s {
    while (x > 1) { x >>= 1; }
  } else { s -= 1; }
  return s;
}

is compiled to

main:
	movl	$0, %eax
	cmpl	%eax, %edi
	jnle	Lmain$3
	addl	$-1, %eax
	jmp 	Lmain$2
Lmain$1:
	jmp 	Lmain$3
Lmain$4:
	shrl	$1, %edi
Lmain$3:
	cmpl	$1, %edi
	jnbe	Lmain$4
Lmain$2:
	ret

Label Lmain$1 is unreacheable so the instruction jmp Lmain$3 is dead.

@eponier
Copy link
Contributor

eponier commented Nov 26, 2024

It seems that tunneling does only half of its job?

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

2 participants