Bugfix: scaled addressing mode: round B1 up to one byte.

Issue uncovered by Ben Bouvier during regalloc work.
This commit is contained in:
Chris Fallin
2020-06-10 12:47:08 -07:00
parent 5d5b39d685
commit ed7e410111

View File

@@ -233,6 +233,9 @@ impl UImm12Scaled {
/// Create a UImm12Scaled from a raw offset and the known scale type, if /// Create a UImm12Scaled from a raw offset and the known scale type, if
/// possible. /// possible.
pub fn maybe_from_i64(value: i64, scale_ty: Type) -> Option<UImm12Scaled> { pub fn maybe_from_i64(value: i64, scale_ty: Type) -> Option<UImm12Scaled> {
// Ensure the type is at least one byte.
let scale_ty = if scale_ty == B1 { B8 } else { scale_ty };
let scale = scale_ty.bytes(); let scale = scale_ty.bytes();
assert!(scale.is_power_of_two()); assert!(scale.is_power_of_two());
let scale = scale as i64; let scale = scale as i64;