From ed7e410111cab0d265e685dcbeb8d64b0950d3f3 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Wed, 10 Jun 2020 12:47:08 -0700 Subject: [PATCH] Bugfix: scaled addressing mode: round B1 up to one byte. Issue uncovered by Ben Bouvier during regalloc work. --- cranelift/codegen/src/isa/aarch64/inst/imms.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cranelift/codegen/src/isa/aarch64/inst/imms.rs b/cranelift/codegen/src/isa/aarch64/inst/imms.rs index 20a8225e7a..6fea5efb5c 100644 --- a/cranelift/codegen/src/isa/aarch64/inst/imms.rs +++ b/cranelift/codegen/src/isa/aarch64/inst/imms.rs @@ -233,6 +233,9 @@ impl UImm12Scaled { /// Create a UImm12Scaled from a raw offset and the known scale type, if /// possible. pub fn maybe_from_i64(value: i64, scale_ty: Type) -> Option { + // Ensure the type is at least one byte. + let scale_ty = if scale_ty == B1 { B8 } else { scale_ty }; + let scale = scale_ty.bytes(); assert!(scale.is_power_of_two()); let scale = scale as i64;