Closed Bug 1678049 Opened 4 years ago Closed 4 years ago

Optimize compare with immediate zero on zero/nonzero

Categories

(Core :: JavaScript Engine: JIT, enhancement, P3)

ARM64
All
enhancement

Tracking

()

RESOLVED FIXED
85 Branch
Tracking Status
firefox85 --- fixed

People

(Reporter: lth, Assigned: lth)

Details

Attachments

(3 files)

ARM64 has CBZ / CBNZ for compares with zero for equality / nonequality. We should emit these when it's convenient to do so.

Arm64 has special instructions for compare-with-zero for equality/nonequality,
so use them when we can. This makes code more compact, and may be a very small
speed win.

The branchTest primitives can use CBZ/CBNZ just as easily as the branch primitives can.

Depends on D97454

ARM64 is able to do a test-for-zero-and-branch in one instruction, and
branchTest32 will emit good code for that. The code generation for
testIAndBranch should therefore use branchTest32, not separate test
and branch operations.

Depends on D97477

Pushed by lhansen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7d79ac9d7608
Use CBZ/CBNZ on ARM64 when we can. r=nbp
https://hg.mozilla.org/integration/autoland/rev/07a158ac17b3
Use CBZ/CBNZ on ARM64 also for branchTest. r=nbp
https://hg.mozilla.org/integration/autoland/rev/28db3a41c2fe
Fuse test and branch for testIAndBranch on ARM64. r=nbp

Backed out for causing arm64 bustages.

Backout link: https://hg.mozilla.org/integration/autoland/rev/cc6b9d58862f9a03b2223b3c696e8fcaba5ba94b

Push with failures: https://treeherder.mozilla.org/jobs?repo=autoland&resultStatus=testfailed%2Cbusted%2Cexception%2Crunning%2Cpending%2Crunnable&revision=a2b460b0ea61f4aed0f5ad85cf477555bbf76fee&selectedTaskRun=TYZZU40jSjC60YsMh9Bugg.0

Failure log: https://treeherder.mozilla.org/logviewer?job_id=322296805&repo=autoland&lineNumber=11026

TEST-PASS | js/src/jit-test/tests/sunspider/check-string-fasta.js | Success (code 0, args "") [7.0 s]
[task 2020-11-19T13:15:05.697Z] WARNING: VIXL simulator support for load-/store-/clear-exclusive instructions is limited. Refer to the README for details.
[task 2020-11-19T13:15:05.697Z] /builds/worker/checkouts/gecko/js/src/jit-test/tests/wasm/atomic.js line 185 > WebAssembly.Module:63:1 RuntimeError: unaligned memory access
[task 2020-11-19T13:15:05.697Z] Stack:
[task 2020-11-19T13:15:05.697Z] @/builds/worker/checkouts/gecko/js/src/jit-test/tests/wasm/atomic.js:350:18
[task 2020-11-19T13:15:05.697Z] Exit code: 3
[task 2020-11-19T13:15:05.697Z] FAIL - wasm/atomic.js
[task 2020-11-19T13:15:05.697Z] TEST-UNEXPECTED-FAIL | js/src/jit-test/tests/wasm/atomic.js | WARNING: VIXL simulator support for load-/store-/clear-exclusive instructions is limited. Refer to the README for details. (code 3, args "--wasm-compiler=baseline") [0.6 s]
[task 2020-11-19T13:15:05.698Z] INFO exit-status : 3
[task 2020-11-19T13:15:05.698Z] INFO timed-out : False
[task 2020-11-19T13:15:05.698Z] INFO stderr 2> WARNING: VIXL simulator support for load-/store-/clear-exclusive instructions is limited. Refer to the README for details.
[task 2020-11-19T13:15:05.698Z] INFO stderr 2> /builds/worker/checkouts/gecko/js/src/jit-test/tests/wasm/atomic.js line 185 > WebAssembly.Module:63:1 RuntimeError: unaligned memory access
[task 2020-11-19T13:15:05.698Z] INFO stderr 2> Stack:
[task 2020-11-19T13:15:05.698Z] INFO stderr 2> @/builds/worker/checkouts/gecko/js/src/jit-test/tests/wasm/atomic.js:350:18
[task 2020-11-19T13:15:05.833Z] TEST-PASS | js/src/jit-test/tests/sunspider/check-access-fannkuch.js | Success (code 0, args "") [11.3 s]

Flags: needinfo?(lhansen)

There were problems in both of the later patches: branchTest32(..., imm32) should not be optimized, because that imm is never zero and when it is zero it means something else than what the new code made it mean; and the two optimizations that made calls to branchTest32(..., Imm32(0)) should not call that but should instead call branch32(..., Imm32(0)), which then implements the correct optimization.

Flags: needinfo?(lhansen)
Pushed by lhansen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a932382525cf
Use CBZ/CBNZ on ARM64 when we can. r=nbp
https://hg.mozilla.org/integration/autoland/rev/220d93fdaa19
Use CBZ/CBNZ on ARM64 also for branchTest. r=nbp
https://hg.mozilla.org/integration/autoland/rev/c20b492e2ebe
Fuse test and branch for testIAndBranch on ARM64. r=nbp
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 85 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: