summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/merge-phi-usage-analysis.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/ion/merge-phi-usage-analysis.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/ion/merge-phi-usage-analysis.js')
-rw-r--r--js/src/jit-test/tests/ion/merge-phi-usage-analysis.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/merge-phi-usage-analysis.js b/js/src/jit-test/tests/ion/merge-phi-usage-analysis.js
new file mode 100644
index 0000000000..f239a8faf2
--- /dev/null
+++ b/js/src/jit-test/tests/ion/merge-phi-usage-analysis.js
@@ -0,0 +1,63 @@
+
+function expensive() {
+ with({}) {}
+}
+
+function phi_merge_0(i) {
+ // These computations can overflow, if the output is not truncated.
+ i = i | 0;
+ var a0 = i + i;
+ var a1 = i + i;
+
+ if ((a1 | 0) - ((2 * i) | 0)) {
+ // Good candidate for branch pruning, which marks only a1 as having
+ // removed uses.
+ expensive();
+ expensive();
+ expensive();
+ expensive();
+ expensive();
+ }
+
+ // Simple branch made to let GVN merge the Phi instructions.
+ if (a1 % 3 == 1) {
+ a1 = 2 * i;
+ a0 = 2 * i;
+ }
+
+ // a0 is never used, but a1 is truncated.
+ return a1 | 0;
+}
+
+function phi_merge_1(i) {
+ // These computations can overflow, if the output is not truncated.
+ i = i | 0;
+ var a1 = i + i;
+ var a0 = i + i;
+
+ if ((a1 | 0) - ((2 * i) | 0)) {
+ // Good candidate for branch pruning, which marks only a1 as having
+ // removed uses.
+ expensive();
+ expensive();
+ expensive();
+ expensive();
+ expensive();
+ }
+
+ // Simple branch made to let GVN merge the Phi instructions.
+ if (a1 % 3 == 1) {
+ a1 = 2 * i;
+ a0 = 2 * i;
+ }
+
+ // a0 is never used, but a1 is truncated.
+ return a1 | 0;
+}
+
+for (var j = 0; j < 300; j++) {
+ for (var i = 1; i == (i | 0); i = 2 * i + 1) {
+ assertEq(phi_merge_0(i) < 0x80000000, true);
+ assertEq(phi_merge_1(i) < 0x80000000, true);
+ }
+}