shader: fold constant bit reversal before flat stack classification

Co-authored-by: TheCruZ <thecruzwtf@gmail.com>
Co-authored-by: Ali Almohaya <AliAlmohaya@gmail.com>
This commit is contained in:
committed 2026-10-04 18:39:34 +04:00
1 parent a55a28380d
commit 139b564c01
2 files changed
+14 -1

No files matched your search

@@ -503,6 +503,17 @@ void FoldInstruction(Block& block, Block::iterator instruction,
}
return;
}
case ValueOpcode::BitReverse32: {
const auto value = Arg(inst, 0);
if (IsImmediate(value, Type::U32)) {
uint32_t source = value.U32(), reversed = 0;
for (uint32_t bit = 0; bit < 32u; ++bit, source >>= 1u) {
reversed = (reversed << 1u) | (source & 1u);
}
Replace(inst, Value(reversed));
}
return;
}
case ValueOpcode::BitCount32: {
const auto value = Arg(inst, 0);
if (IsImmediate(value, Type::U32)) {