You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
Use a fixed 6-bit immediate for CBP-type c.andi (riscv#2316)
Issue riscv#2147 item 23.
CBP is only `c.andi`, whose immediate is a fixed 6-bit signed field,
`[-32,31]` on both RV32 and
RV64. The config declared `imm_bits="xlen_log2"`, which resolves to 5 on
RV32, confining RV32 random
immediates to `[-16,15]`. It also set `imm_nonzero=True`, but `c.andi`
reserves nothing — `imm=0` is
a legal encoding that clears the register (UDB: `X[xd] = X[xd] &
$signed(imm)`, no constraint).
Both settings are correct for CBS, the shift type `c.srli`/`c.srai`,
where the immediate really is an
`xlen_log2` shift amount and `shamt=0` is a HINT. They were copied to
CBP, which shares neither
property. Of the five types setting `imm_nonzero`, CBP was the only one
whose instruction has no
architectural nonzero requirement — `c.addi4spn`, `c.lui` and
`c.addi16sp` reserve a zero immediate,
and the shift types make it a HINT.
Two files regenerate, RV32 only; RV64 already resolved `xlen_log2` to 6
and is byte-identical. Random
immediates move from `[-16,13]` to `[-32,27]`; the 156 testcases under
`cp_imm_edges` and
`cr_rs1_imm_edges_6bit` pin their immediates and already spanned the
full range. Zca passes 32/32 on
spike-rv64-max and 26/26 on spike-rv32-max.
Thanks @copilot-pull-request-reviewer for catching `imm_nonzero` — it is
the same copy-paste as the
width. Worth noting for the record that it changes no generated output
today: no random draw in the
current stream lands on 0, so the re-roll never fired, and `imm=0` is
already exercised 16 times per
file by the edge cross. The value is preventing a future seed or edit
from silently suppressing a
legal encoding in the random path.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01PTjX9BBLNAQkWwTTq6vfxq
---------
Signed-off-by: David Harris <David_Harris@hmc.edu>
Signed-off-by: Jordan Carlin <jcarlin@qti.qualcomm.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Jordan Carlin <jcarlin@qti.qualcomm.com>
0 commit comments