diff --git a/cranelift/codegen/src/isa/aarch64/inst/emit.rs b/cranelift/codegen/src/isa/aarch64/inst/emit.rs index 3d08d524b4..e872acd18c 100644 --- a/cranelift/codegen/src/isa/aarch64/inst/emit.rs +++ b/cranelift/codegen/src/isa/aarch64/inst/emit.rs @@ -534,8 +534,16 @@ impl MachInstEmit for Inst { ALUOp::Lsr64 => (0b1101001101, u32::from(amt), 0b111111), ALUOp::Asr32 => (0b0001001100, u32::from(amt), 0b011111), ALUOp::Asr64 => (0b1001001101, u32::from(amt), 0b111111), - ALUOp::Lsl32 => (0b0101001100, u32::from(32 - amt), u32::from(31 - amt)), - ALUOp::Lsl64 => (0b1101001101, u32::from(64 - amt), u32::from(63 - amt)), + ALUOp::Lsl32 => ( + 0b0101001100, + u32::from((32 - amt) % 32), + u32::from(31 - amt), + ), + ALUOp::Lsl64 => ( + 0b1101001101, + u32::from((64 - amt) % 64), + u32::from(63 - amt), + ), _ => unimplemented!("{:?}", alu_op), }; sink.put4( diff --git a/cranelift/codegen/src/isa/aarch64/inst/emit_tests.rs b/cranelift/codegen/src/isa/aarch64/inst/emit_tests.rs index 2656c0ccfe..8f25043e6f 100644 --- a/cranelift/codegen/src/isa/aarch64/inst/emit_tests.rs +++ b/cranelift/codegen/src/isa/aarch64/inst/emit_tests.rs @@ -934,6 +934,26 @@ fn test_aarch64_binemit() { "280141D3", "lsl x8, x9, #63", )); + insns.push(( + Inst::AluRRImmShift { + alu_op: ALUOp::Lsl32, + rd: writable_xreg(10), + rn: xreg(11), + immshift: ImmShift::maybe_from_u64(0).unwrap(), + }, + "6A7D0053", + "lsl w10, w11, #0", + )); + insns.push(( + Inst::AluRRImmShift { + alu_op: ALUOp::Lsl64, + rd: writable_xreg(10), + rn: xreg(11), + immshift: ImmShift::maybe_from_u64(0).unwrap(), + }, + "6AFD40D3", + "lsl x10, x11, #0", + )); insns.push(( Inst::AluRRImmLogic {