Skip to content

Commit 9f69578

Browse files
authored
Update i64_from_iconst to only match iconst (#8739)
Previously this extractor would additionally match `f32const` and `f64const` which while theoretically not the end of the world can be confusing. Nowadays switch it to instead only matching the `iconst` instruction, as the name implies, and if necessary matching float constants is probably best done through separate ISLE lowering rules. Closes #8723
1 parent b010bfd commit 9f69578

File tree

1 file changed

+7
-1
lines changed
  • cranelift/codegen/src/machinst

1 file changed

+7
-1
lines changed

cranelift/codegen/src/machinst/isle.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,13 @@ macro_rules! isle_lower_prelude_methods {
223223
#[inline]
224224
fn i64_from_iconst(&mut self, val: Value) -> Option<i64> {
225225
let inst = self.def_inst(val)?;
226-
let constant = self.lower_ctx.get_constant(inst)? as i64;
226+
let constant = match self.lower_ctx.data(inst) {
227+
InstructionData::UnaryImm {
228+
opcode: Opcode::Iconst,
229+
imm,
230+
} => imm.bits(),
231+
_ => return None,
232+
};
227233
let ty = self.lower_ctx.output_ty(inst, 0);
228234
let shift_amt = std::cmp::max(0, 64 - self.ty_bits(ty));
229235
Some((constant << shift_amt) >> shift_amt)

0 commit comments

Comments
 (0)