Truly independent web browser
LibJS/JIT: Fold int32 checks of boxed int32 values
Tim Ledbetter9d4dfd7f24b6
diff --git a/Libraries/LibJS/JIT/Rust/src/passes/simplify.rs b/Libraries/LibJS/JIT/Rust/src/passes/simplify.rsindex 874da76bd79..d2be7e52408 100644--- a/Libraries/LibJS/JIT/Rust/src/passes/simplify.rs+++ b/Libraries/LibJS/JIT/Rust/src/passes/simplify.rs@@ -473,6 +473,7 @@ fn simplify(graph: &mut Graph, dissolve_checks: bool) {{Some(graph.node(double).inputs[0])}+ Op::CheckInt32 if let Some(integer) = boxed(Op::BoxInt32, inputs[0]) => Some(integer),Op::CheckInt32 => constant_bits(graph, 0).filter(|bits| graph.node(inputs[0]).repr == Some(Repr::Tagged) && value::as_int32(*bits).is_some()).map(|bits| constants.get_typed(graph, bits & u64::from(u32::MAX), Repr::Int32)),diff --git a/Tests/LibJS/JIT/ir/osr-loop-test-counter.js b/Tests/LibJS/JIT/ir/osr-loop-test-counter.jsnew file mode 100644index 00000000000..cbd01a419f2--- /dev/null+++ b/Tests/LibJS/JIT/ir/osr-loop-test-counter.js@@ -0,0 +1,21 @@+// OPTIONS: stress-osr+// A loop entered by on-stack replacement at its test compares its counter without checking it to be an int32 again,+// so bounds check elimination can drop the increment's overflow check. The bound is a global constant because loops+// with a literal or a parameter as their bound never had that check.++const COUNT = 100;+function sum() {+ let total = 0;+ for (let i = 0; i < COUNT; ++i) total += i;+ return total;+}+jit.prepare(sum);+for (let i = 0; i < 10; ++i) sum();+jit.compile(sum);++// CHECK-FUNCTION: sum+// CHECK-PASS: frame initialization+// CHECK: loop:+// CHECK: [[NEXT:v[0-9]+]]:int32 = Int32WrappingAdd ({{v[0-9]+}}, #i32:1)+// CHECK-NOT: CheckInt32+// CHECK: BranchInt32LessThan ([[NEXT]], #i32:100)