diff options
author | Kevin Newton <[email protected]> | 2022-07-21 14:48:44 -0400 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2022-08-29 08:47:03 -0700 |
commit | 76b05ba9e8f72ce98057d3817f6f353c9e62a892 (patch) | |
tree | fb4b6a84fb9d4b43d0e9adf4940c1f230dae3009 /yjit/src/asm/arm64 | |
parent | b1dbc5f1a683e4727f463c0a5a3e0195e5c2cc7f (diff) |
Better splitting for Op::Test on AArch64 (https://github.com/Shopify/ruby/pull/335)
Diffstat (limited to 'yjit/src/asm/arm64')
-rw-r--r-- | yjit/src/asm/arm64/arg/bitmask_imm.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/yjit/src/asm/arm64/arg/bitmask_imm.rs b/yjit/src/asm/arm64/arg/bitmask_imm.rs index 7e5a21c7b4..847b735eaa 100644 --- a/yjit/src/asm/arm64/arg/bitmask_imm.rs +++ b/yjit/src/asm/arm64/arg/bitmask_imm.rs @@ -41,13 +41,19 @@ impl TryFrom<u64> for BitmaskImmediate { /// Attempt to convert a u64 into a BitmaskImm. fn try_from(value: u64) -> Result<Self, Self::Error> { + // 0 is not encodable as a bitmask immediate. Immediately return here so + // that we don't have any issues with underflow. + if value == 0 { + return Err(()); + } + /// Is this number's binary representation all 1s? fn is_mask(imm: u64) -> bool { if imm == u64::MAX { true } else { ((imm + 1) & imm) == 0 } } - /// Is this number's binary representation one or more 1s followed by one or - /// more 0s? + /// Is this number's binary representation one or more 1s followed by + /// one or more 0s? fn is_shifted_mask(imm: u64) -> bool { is_mask((imm - 1) | imm) } |