The c.lui rd=x0 HINT code point is rejected as a reserved encoding

Open Beginner friendly
#321 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
compilers

Research direction

Start at the decode_q1 entry point and inspect the existing compressed-instruction tests, including the JIT boundary test. Verify that c.lui with rd=x0 and nzimm!=0 executes as a no-op, that a nonzero rd remains valid, and that nzimm==0 still traps as reserved.

Written by the indexing model from the issue text.

Description

Summary

The compressed c.lui code point with rd=x0 and nzimm!=0 is a HINT per the Zca specification (insns-c_lui: "The code points with rd=x0 and imm!=0 are HINTs"); HINTs execute as no-ops and must never trap. RAX's decode_q1 rejects the encoding as reserved (if v == 0 || rd == 0), so the legal HINT c.lui x0, 1 (0x6005) raises an illegal-instruction exception. Only the nzimm==0 code point is reserved.

Steps to reproduce

let mut c = cpu64();
let r = exec_rvc(&mut c, 0x6005, Xlen::Rv64, &Isa::rv64gc()); // c.lui x0, 1
assert!(r.is_err()); // defect: legal HINT rejected as reserved

Expected result

c.lui x0, imm (imm!=0) decodes as lui x0, imm, a no-op that executes normally; c.lui x0, 0 remains reserved.

Observed result

The HINT code point traps as an illegal instruction.

Environment

RAX master 7f162b19aeaa47825c82fb1c77ca042f535124e3 (checked 2026-08-23).

Suggested fix

Keep only the nzimm==0 reserved check in decode_q1 and let rd=x0 with nzimm!=0 decode as a normal (no-op) lui. A regression test covers the HINT decoding, a rd!=0 control, and the nzimm==0 reserved case; the JIT boundary test drops the now-legal C.LUI rd=x0 case.

I searched the issue tracker and found no existing report for c.lui rd=x0 HINT being rejected.

Dominant language
Rust
Stars
218
Forks
10
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HexRaysSA/rax

All issues in HexRaysSA/rax

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.