diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp @@ -172,7 +172,7 @@ int ImmS = MI->getOperand(4).getImm(); if ((Op2.getReg() == AArch64::WZR || Op2.getReg() == AArch64::XZR) && - (ImmR == 0 || ImmS < ImmR)) { + (ImmR == 0 || ImmS < ImmR) && STI.getFeatureBits()[AArch64::HasV8_2aOps]) { // BFC takes precedence over its entire range, sligtly differently to BFI. int BitWidth = Opcode == AArch64::BFMXri ? 64 : 32; int LSB = (BitWidth - ImmR) % BitWidth; diff --git a/llvm/test/MC/AArch64/armv8.2a-bfc.s b/llvm/test/MC/AArch64/armv8.2a-bfc.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/AArch64/armv8.2a-bfc.s @@ -0,0 +1,11 @@ +// RUN: llvm-mc -triple aarch64-linux-gnu -o - %s | FileCheck %s --check-prefix=BFI +// RUN: llvm-mc -triple aarch64-linux-gnu -o - %s -mattr=+v8.1a | FileCheck %s --check-prefix=BFI +// RUN: llvm-mc -triple aarch64-linux-gnu -o - %s -mattr=-v8.2a | FileCheck %s --check-prefix=BFI +// RUN: llvm-mc -triple aarch64-linux-gnu -o - %s -mattr=+v8.2a | FileCheck %s --check-prefix=BFC +// RUN: llvm-mc -triple aarch64-linux-gnu -o - %s -mattr=+v8.3a | FileCheck %s --check-prefix=BFC +// RUN: llvm-mc -triple aarch64-linux-gnu -o - %s -mattr=+v8.4a | FileCheck %s --check-prefix=BFC +// RUN: llvm-mc -triple aarch64-linux-gnu -o - %s -mattr=+v8.5a | FileCheck %s --check-prefix=BFC + bfc w0, #1, #5 + +// BFI: bfi w0, wzr, #1, #5 +// BFC: bfc w0, #1, #5