Files
scriptc/tests/corpus/2937-bitwise-hot-loop.ts
Chris TateandFábio Pereira c5129449ab perf(llvm): inline numeric bitwise operations (#366)
- Emit JavaScript bitwise operators with native i32 instructions.
- Cover native emission and hot-loop coercion semantics.

Fixes #357

Co-authored-by: Fábio Pereira <300015+redvulps@users.noreply.github.com>
2026-09-21 10:51:41 -05:00

10 lines
358 B
TypeScript

// Dependent bitwise chains keep JavaScript's 32-bit coercion and unsigned
// result semantics when every intermediate value feeds the next operation.
let value = 0x12345678;
for (let i = 0; i < 1_000_000; i++) {
value = (value ^ (value << 13)) >>> 0;
value = (value ^ (value >>> 17)) >>> 0;
value = (value ^ (value << 5)) >>> 0;
}
console.log(value);