Skip to content

rvjit: preserve immediate comparison semantics for x0 sources - #273

Merged
LekKit merged 1 commit into
LekKit:stagingfrom
carlosqwqqwq:fix/rvjit-slti-x0
Aug 12, 2026
Merged

rvjit: preserve immediate comparison semantics for x0 sources#273
LekKit merged 1 commit into
LekKit:stagingfrom
carlosqwqqwq:fix/rvjit-slti-x0

Conversation

@carlosqwqqwq

Copy link
Copy Markdown

rvjit: preserve immediate comparison semantics for x0 sources

Fixes #268

Commit message

rvjit: preserve immediate comparison semantics for x0 sources

Description

The RVJIT_IMM_ZERO_OPTIMIZE peephole rewrites SLTI and SLTIU with rs1=x0 as zero-producing operations. These are comparisons, so the result depends on the immediate (slti rd,x0,1 is 1). Use the non-zero-optimizing emission macros for both instructions.

Validation

  • Native RV64, QEMU, interpreter, and fixed-JIT controls were run; the witness outputs are attached.
  • The proposed change is limited to the two immediate-emitter registrations in src/rvjit/rvjit_emit.c.
  • This root is separate from the division-overflow, MULHSU aliasing, JALR target-mask, compressed-jump, and LR fixed-field fixes.

@LekKit
LekKit merged commit 9835eac into LekKit:staging Aug 12, 2026
15 checks passed
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.

x86 JIT miscompiles SLTI/SLTIU when rs1 is x0

2 participants