mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #1493] [MERGED] rdna2spirv: sign-extend the 32-bit literal of v_cmp(x)_*_i64, v_ashrrev_i64, v_mad_i64_i32 (SHADER-VALU-LITERAL-SEXT) #1520
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1520
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1493
Author: @QemmHD
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @QemmHD
Base:
main← Head:claude/valu-literal-sext📝 Commits (1)
bc2d333rdna2spirv: sign-extend the 32-bit literal of v_cmp(x)_*_i64, v_ashrrev_i64, v_mad_i64_i32 (SHADER-VALU-LITERAL-SEXT)📊 Changes
3 files changed (+185 additions, -6 deletions)
View changed files
📝
docs/design.md(+1 -0)➕
tests/semantic/test_valu_signed_literal64.py(+156 -0)📝
tools/rdna2spirv.py(+28 -6)📄 Description
Claimed in the coordination issue as: SHADER-VALU-LITERAL-SEXT (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7149621293)
Related: #978 (OlaiFG7, the scalar half; no conflict, merges cleanly in either order)
What and why
A 32-bit literal used as a signed 64-bit vector operand is now sign-extended (
Gen.valu_imm_i64/Gen.src64_i64), following LLVM's AMDGPU operand-syntax rule ("Conversion of Integer Values"): i64 →{-1,num.i32}, u64/b64 →{0,num.u32}. llvm-mc prints-100as0xffffff9c(both spellings encode to the same bytes on gfx1030), and the translator zero-extended that for every 64-bit VALU source, so:v_cmp_lt_i64 5, 0xffffff9cgave 1 instead of 0;v_ashrrev_i64 v[2:3], 4, 0xffffff9cgave0x0ffffff9:0instead of0xfffffff9:0xffffffff;v_mad_i64_i32 …, 1, 1, 0xffffff9chad a high word of 0 instead of0xffffffff.Covered:
v_cmp(x)_{lt,le,gt,ge,eq,ne,lg}_i64,v_ashrrev_i64S1 andv_mad_i64_i32S2. Unchanged by design: the u64/b64 sources (v_cmp_*_u64,v_lshlrev/lshrrev_b64,v_mad_u64_u32S2, the qsad forms) still zero-extend; f64 literals keep their high-word rule (already correct); inline constants (-16..64) were already full width.src64_dataitself is unchanged.This is the vector half of #978. Found while comparing with VIctory (Marvisak/VIctory
1134418); written anew here.docs/design.md: a contract-table row, confirmed by the LLVM operand-syntax doc, the llvm-mc encodings and #978's precedent. Not measured on hardware.tests/semantic/test_valu_signed_literal64.py: 8 hand-written tests, no game data. Each signed case uses three spellings (decimal, printed hex, explicit SGPR pair), with controls: a positive literal, an inline constant, and the unsigned ops.Tested
0aecc5efa(after #984): 484 files, 6,262 tests, 0 failed.compileallis clean. Merges cleanly onto current main.test_alu_ashr_i64andtest_alu_mad64all pass (90 tests). Once both are in, #978'simm64_signedand this PR'svalu_imm_i64do the same thing, so a follow-up could fold them into one.GPUs tested: n/a (translator; CPU interpreter)
AI-assisted: yes
Checklist
mainand merges cleanly.docs/design.md, with how it was confirmed.AI-assisted (Claude Code, Claude Opus 5.5).
🤖 Generated with Claude Code
https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.