diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -297,18 +297,13 @@ .addImm(0) .addImm(0), *STI); - OutStreamer->EmitInstruction(MCInstBuilder(AArch64::UBFMXri) - .addReg(AArch64::X17) - .addReg(Reg) - .addImm(56) - .addImm(63), - *STI); - OutStreamer->EmitInstruction(MCInstBuilder(AArch64::SUBSWrs) - .addReg(AArch64::WZR) - .addReg(AArch64::W16) - .addReg(AArch64::W17) - .addImm(0), - *STI); + OutStreamer->EmitInstruction( + MCInstBuilder(AArch64::SUBSXrs) + .addReg(AArch64::XZR) + .addReg(AArch64::X16) + .addReg(Reg) + .addImm(AArch64_AM::getShifterImm(AArch64_AM::LSR, 56)), + *STI); MCSymbol *HandleMismatchSym = OutContext.createTempSymbol(); OutStreamer->EmitInstruction( MCInstBuilder(AArch64::Bcc) diff --git a/llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll b/llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll --- a/llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll +++ b/llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll @@ -38,8 +38,7 @@ ; CHECK-NEXT: __hwasan_check_x0_456: ; CHECK-NEXT: ubfx x16, x0, #4, #52 ; CHECK-NEXT: ldrb w16, [x9, x16] -; CHECK-NEXT: lsr x17, x0, #56 -; CHECK-NEXT: cmp w16, w17 +; CHECK-NEXT: cmp x16, x0, lsr #56 ; CHECK-NEXT: b.ne .Ltmp0 ; CHECK-NEXT: ret ; CHECK-NEXT: .Ltmp0: @@ -58,8 +57,7 @@ ; CHECK-NEXT: __hwasan_check_x1_123: ; CHECK-NEXT: ubfx x16, x1, #4, #52 ; CHECK-NEXT: ldrb w16, [x9, x16] -; CHECK-NEXT: lsr x17, x1, #56 -; CHECK-NEXT: cmp w16, w17 +; CHECK-NEXT: cmp x16, x1, lsr #56 ; CHECK-NEXT: b.ne .Ltmp1 ; CHECK-NEXT: ret ; CHECK-NEXT: .Ltmp1: