mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:00:52 +01:00
[PR #2013] shader_ir: preserve sign inside lit(-V) instead of turning it into VOP3 neg(V) (SHADER-IR-LIT-NEGATIVE-SIGN) #2020
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#2020
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/2013
Author: @ShotTechOp
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/shader-ir-lit-neg📝 Commits (1)
9b7af80shader_ir: preserve sign inside lit(-V) instead of turning it into VOP3 neg(V)📊 Changes
3 files changed (+106 additions, -5 deletions)
View changed files
➕
tests/semantic/test_shader_ir_lit_neg.py(+85 -0)📝
tests/test_shader_ir.py(+14 -2)📝
tools/shader_ir.py(+7 -3)📄 Description
Claimed in #1608 as
SHADER-IR-LIT-NEGATIVE-SIGN.What and why
tools/shader_ir.py::operand, thelit(...)unwrap checkedif t.startswith("-"):after substitutinglit(V)->V:lit(...)such aslit(-1)orlit(-0x10)became"-1"/"-0x10"and was immediately rewritten to"neg(1)"/"neg(0x10)"— i.e.,{"k": "imm", "v": 1, "neg": True}instead of{"k": "imm", "v": -1}!tools/rdna2spirv.py,"neg": Trueapplies a VOP3 sign-bit XOR (^ 0x80000000), sos_mov_b32 s4, lit(-1)andv_add_nc_u32_e32 v2, lit(-0x10), v0silently produced0x80000001andv0 + 0x80000010instead of0xFFFFFFFFandv0 - 16.outer_neg = t.startswith("-")before_LIT.sub(r"\1", t)keeps a leading-onlit(...)itself as the VOP3neg(...)modifier (e.g.,-lit(0x3f800000),-lit(-1.5),-|lit(-1.5)|) while preserving the negative value insidelit(-V)(matchingoperand("-1"),operand("-0x10"),operand("-1.5")).Testing
tests/test_shader_ir.py::OperandTests::test_llvm23_lit_is_the_constantwithlit(-1),lit(-0x10),lit(-1.5),-lit(-1),-lit(-1.5),|lit(-1.5)|,-|lit(-1.5)|,neg(lit(-1)).tests/semantic/test_shader_ir_lit_neg.pyend-to-end throughtools/rdna2spirv.py+spirv_mini_interp.py.origin/main:tests/semantic/test_shader_ir_lit_neg.pyfails onorigin/mainwith2147483649 (0x80000001) != 4294967295 (0xFFFFFFFF).python -I tests/test_shader_ir.py -v(39/39 OK)python -I tests/test_shader_ir_parse.py -v(3/3 OK)python -I tests/semantic/test_shader_ir_lit_neg.py -v(1/1 OK)python -I tests/test_text_write_line_endings.py(3/3 OK)python -m compileall -q tools/shader_ir.py tests/test_shader_ir.py tests/semantic/test_shader_ir_lit_neg.pypython -I scripts/check_no_game_data.py tools/shader_ir.py tests/test_shader_ir.py tests/semantic/test_shader_ir_lit_neg.pygit diff --check🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.