Files
ladybird/Tests/LibJS/Bytecode/input/right-shift-by-zero.js
Andreas Kling bb0acb54ae LibJS: Optimize x >> 0 to ToInt32 in bytecode codegen
x >> 0 is a common JS idiom equivalent to ToInt32(x). We already had
this optimization for x | 0, now do it for right shift by zero as well.

This allows the asmint handler for ToInt32 to run instead of the more
expensive RightShift handler, which wastes time loading and checking the
rhs operand and performing a shift by zero.
2026-03-20 00:51:23 -05:00

6 lines
50 B
JavaScript

function foo(x) {
return x >> 0;
}
foo(1.5);