x64: Migrate {s,u}{div,rem} to ISLE (#6008)
* x64: Add precise-output tests for div traps
This adds a suite of `*.clif` files which are intended to test the
`avoid_div_traps=true` compilation of the `{s,u}{div,rem}` instructions.
* x64: Remove conditional regalloc in `Div` instruction
Move the 8-bit `Div` logic into a dedicated `Div8` instruction to avoid
having conditionally-used registers with respect to regalloc.
* x64: Migrate non-trapping, `udiv`/`urem` to ISLE
* x64: Port checked `udiv` to ISLE
* x64: Migrate urem entirely to ISLE
* x64: Use `test` instead of `cmp` to compare-to-zero
* x64: Port `sdiv` lowering to ISLE
* x64: Port `srem` lowering to ISLE
* Tidy up regalloc behavior and fix tests
* Update docs and winch
* Review comments
* Reword again
* More refactoring test fixes
* More test fixes
This commit is contained in:
@@ -957,13 +957,10 @@
|
||||
(result Reg (a64_sdiv $I64 valid_x64 y64)))
|
||||
result))
|
||||
|
||||
;; Helper for extracting an immediate that's not 0 and not -1 from an imm64.
|
||||
(decl safe_divisor_from_imm64 (u64) Imm64)
|
||||
(extern extractor safe_divisor_from_imm64 safe_divisor_from_imm64)
|
||||
|
||||
;; Special case for `sdiv` where no checks are needed due to division by a
|
||||
;; constant meaning the checks are always passed.
|
||||
(rule 1 (lower (has_type (fits_in_64 ty) (sdiv x (iconst (safe_divisor_from_imm64 y)))))
|
||||
(rule 1 (lower (has_type (fits_in_64 ty) (sdiv x (iconst imm))))
|
||||
(if-let y (safe_divisor_from_imm64 ty imm))
|
||||
(a64_sdiv $I64 (put_in_reg_sext64 x) (imm ty (ImmExtend.Sign) y)))
|
||||
|
||||
;; Helper for placing a `Value` into a `Reg` and validating that it's nonzero.
|
||||
|
||||
Reference in New Issue
Block a user