Skip to content

perf: elide some jumps in jump#3347

Merged
rakita merged 1 commit intobluealloy:mainfrom
DaniPopes:dani/jump-conds
Jan 25, 2026
Merged

perf: elide some jumps in jump#3347
rakita merged 1 commit intobluealloy:mainfrom
DaniPopes:dani/jump-conds

Conversation

@DaniPopes
Copy link
Collaborator

@DaniPopes DaniPopes commented Jan 23, 2026

  1. legacy bytecode check (nullptr check); replace expect with unwrap_unchecked (still panics in debug mode)
  2. saturate instead of early fail in jump_inner, since usize::MAX is always an invalid jump regardless
  3. cleanups (use TryFrom impl in ruint since I optimized it, same code gen)

JUMPI diff:

diff --git a/a.s b/d.s
index 379024bb..49d5f819 100644
--- a/a.s
+++ b/d.s
@@ -8,10 +8,9 @@ revm_interpreter::instructions::control::jumpi::<revm_interpreter::interpreter::
 	.cfi_offset rbp, -16
 	mov rbp, rsp
 	.cfi_def_cfa_register rbp
-	sub rsp, 32
 	mov r8, qword ptr [rdi + 192]
 	cmp r8, 2
-	jb .LBB148_8
+	jb .LBB148_6
 	mov r9, qword ptr [rdi + 184]
 	mov rsi, r8
 	add r8, -2
@@ -30,49 +29,38 @@ revm_interpreter::instructions::control::jumpi::<revm_interpreter::interpreter::
 	or r9, qword ptr [rbp - 8]
 	or r8, qword ptr [rbp - 16]
 	or r8, r9
-	je .LBB148_7
+	je .LBB148_5
 	or rcx, rdx
 	or rcx, rsi
-	jne .LBB148_10
-	cmp dword ptr [rdi], 1
-	jne .LBB148_9
-	mov rcx, qword ptr [rdi + 8]
-	cmp rax, qword ptr [rcx + 64]
-	jae .LBB148_10
-	mov rdx, qword ptr [rcx + 56]
-	mov rsi, rax
+	mov rcx, -1
+	cmove rcx, rax
+	mov rax, qword ptr [rdi + 8]
+	cmp rcx, qword ptr [rax + 64]
+	jae .LBB148_7
+	mov rdx, qword ptr [rax + 56]
+	mov rsi, rcx
 	shr rsi, 3
 	movzx edx, byte ptr [rdx + rsi]
-	mov esi, eax
+	mov esi, ecx
 	and esi, 7
 	bt edx, esi
-	jae .LBB148_10
-	add rax, qword ptr [rcx + 24]
-	mov qword ptr [rdi + 96], rax
-.LBB148_7:
-	add rsp, 32
+	jae .LBB148_7
+	add rcx, qword ptr [rax + 24]
+	mov qword ptr [rdi + 96], rcx
+.LBB148_5:
 	pop rbp
 	.cfi_def_cfa rsp, 8
 	vzeroupper
 	ret
-.LBB148_8:
+.LBB148_6:
 	.cfi_def_cfa rbp, 16
-	add rsp, 32
 	pop rbp
 	.cfi_def_cfa rsp, 8
 	jmp qword ptr [rip + <revm_interpreter::interpreter::Interpreter>::halt_underflow@GOTPCREL]
-.LBB148_10:
+.LBB148_7:
 	.cfi_def_cfa rbp, 16
 	mov esi, 42
-	add rsp, 32
 	pop rbp
 	.cfi_def_cfa rsp, 8
 	vzeroupper
 	jmp qword ptr [rip + <revm_interpreter::interpreter::Interpreter>::halt@GOTPCREL]
-.LBB148_9:
-	.cfi_def_cfa rbp, 16
-	lea rdi, [rip + .Lanon.393361ac5c29a9e6e6e4d251883b8a2b.38]
-	lea rdx, [rip + .Lanon.393361ac5c29a9e6e6e4d251883b8a2b.40]
-	mov esi, 19
-	vzeroupper
-	call qword ptr [rip + core::option::expect_failed@GOTPCREL]

@DaniPopes DaniPopes requested a review from rakita January 23, 2026 23:13
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 23, 2026

Merging this PR will degrade performance by 3.04%

❌ 1 regressed benchmark
✅ 172 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
MSTORE_50 19.3 µs 19.9 µs -3.04%

Comparing DaniPopes:dani/jump-conds (bf9925b) with main (69083f1)

Open in CodSpeed

@rakita rakita merged commit 0dc217a into bluealloy:main Jan 25, 2026
30 of 31 checks passed
@github-actions github-actions bot mentioned this pull request Jan 21, 2026
@DaniPopes DaniPopes deleted the dani/jump-conds branch January 27, 2026 16:06
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

Successfully merging this pull request may close these issues.

2 participants