summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/fold-needless-control-flow.js
blob: 7f5b461d43c56e60af7c8e357f872dd183da9d4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
function test(str, needle) {
  // We should be able to fold away the complete indexOf instruction, because
  // executing the right-hand side of the && operator is a no-op.
  (str.indexOf(needle) > -1) && needle;
}

const needles = [
  "a", "b",
];

for (let i = 0; i < 100; ++i) {
  test("aaa", needles[i & 1]);
}