Shaders: a signed 64-bit operand sign-extends its 32-bit literal (port of VIctory#447) #41
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/uiliannn--VItoriaBr!41
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/41/head"
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?
@lcg007xd-c on GitHub · 2026-11-25 20:09 UTC · original
lcg007xd-c:port/i64-literal-sign-extend→main· +43 −1 · 2 files · 1 commits · merged 2026-11-25 20:33 UTCPort of Marvisak/VIctory#447 by Dufftwt, cherry-picked with
-x, so the commit keeps its author. VItoriaBr's issue #4 lists it as a sync candidate, and no PR claims it.What it fixes
A 32-bit literal in a signed 64-bit operand is sign-extended on the hardware (LLVM's AMDGPU operand rules), but the lowering zero-extends every literal. So
v_cmp_lt_i64 v[1:2], -100currently compares against4294967196, ands_ashr_i64of a negative literal shifts in zeros. Onmain, the zero-extend is atcrates/victory-shader/src/emit/lower.rs:8066.The change touches both places a 64-bit operand is built, the vector path and the scalar high-half path. Unsigned and bit operands keep the zero-extension. The diff is 12 lines plus upstream's test,
valu_tests::signed_64_bit_operands_sign_extend_their_literal.Tested (Linux, Rust 1.98.1)
mainwithout conflicts.cargo test -p victory-shader --lib --locked: 186 passed, 0 failed, 2 ignored.cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings: clean.Not run here: the hardware test.
valu_testsis Windows-only, and I have no Windows machine, so the Windows CI job runs it.🤖 Generated with Claude Code