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:
@@ -285,12 +285,8 @@ macro_rules! isle_lower_prelude_methods {
|
||||
}
|
||||
}
|
||||
|
||||
fn avoid_div_traps(&mut self, _: Type) -> Option<()> {
|
||||
if self.backend.flags().avoid_div_traps() {
|
||||
Some(())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
fn avoid_div_traps(&mut self) -> bool {
|
||||
self.backend.flags().avoid_div_traps()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -637,6 +633,20 @@ macro_rules! isle_lower_prelude_methods {
|
||||
shuffle_imm_as_le_lane_idx(2, &bytes[14..16])?,
|
||||
))
|
||||
}
|
||||
|
||||
fn safe_divisor_from_imm64(&mut self, ty: Type, val: Imm64) -> Option<u64> {
|
||||
let minus_one = if ty.bytes() == 8 {
|
||||
-1
|
||||
} else {
|
||||
(1 << (ty.bytes() * 8)) - 1
|
||||
};
|
||||
let bits = val.bits() & minus_one;
|
||||
if bits == 0 || bits == minus_one {
|
||||
None
|
||||
} else {
|
||||
Some(bits as u64)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user