diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -855,11 +855,12 @@ if (!isShiftedImm() && (!isImm() || !isa(getImm()))) return DiagnosticPredicateTy::NoMatch; - bool IsByte = std::is_same>::value; + int ImmBytes = sizeof(T); + bool IsByte = ImmBytes == 1; if (auto ShiftedImm = getShiftedVal<8>()) if (!(IsByte && ShiftedImm->second) && - AArch64_AM::isSVECpyImm(uint64_t(ShiftedImm->first) - << ShiftedImm->second)) + AArch64_AM::isSVECpyImm( + uint64_t(ShiftedImm->first) << ShiftedImm->second, ImmBytes)) return DiagnosticPredicateTy::Match; return DiagnosticPredicateTy::NearMatch; @@ -872,11 +873,12 @@ if (!isShiftedImm() && (!isImm() || !isa(getImm()))) return DiagnosticPredicateTy::NoMatch; - bool IsByte = std::is_same>::value; + int ImmBytes = sizeof(T); + bool IsByte = ImmBytes == 1; if (auto ShiftedImm = getShiftedVal<8>()) if (!(IsByte && ShiftedImm->second) && - AArch64_AM::isSVEAddSubImm(ShiftedImm->first - << ShiftedImm->second)) + AArch64_AM::isSVEAddSubImm(ShiftedImm->first << ShiftedImm->second, + ImmBytes)) return DiagnosticPredicateTy::Match; return DiagnosticPredicateTy::NearMatch; diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h @@ -758,41 +758,39 @@ } /// Returns true if Imm is valid for CPY/DUP. -template -static inline bool isSVECpyImm(int64_t Imm) { +static inline bool isSVECpyImm(int64_t Imm, int ImmBytes) { bool IsImm8 = int8_t(Imm) == Imm; bool IsImm16 = int16_t(Imm & ~0xff) == Imm; - if (std::is_same>::value) + if (ImmBytes == 1) return IsImm8 || uint8_t(Imm) == Imm; - if (std::is_same>::value) + if (ImmBytes == 2) return IsImm8 || IsImm16 || uint16_t(Imm & ~0xff) == Imm; return IsImm8 || IsImm16; } /// Returns true if Imm is valid for ADD/SUB. -template -static inline bool isSVEAddSubImm(int64_t Imm) { - bool IsInt8t = std::is_same>::value; - return uint8_t(Imm) == Imm || (!IsInt8t && uint16_t(Imm & ~0xff) == Imm); +static inline bool isSVEAddSubImm(int64_t Imm, int ImmBytes) { + bool IsByte = ImmBytes == 1; + return uint8_t(Imm) == Imm || (!IsByte && uint16_t(Imm & ~0xff) == Imm); } /// Return true if Imm is valid for DUPM and has no single CPY/DUP equivalent. static inline bool isSVEMoveMaskPreferredLogicalImmediate(int64_t Imm) { - if (isSVECpyImm(Imm)) + if (isSVECpyImm(Imm, 8)) return false; auto S = bit_cast>(Imm); auto H = bit_cast>(Imm); auto B = bit_cast>(Imm); - if (isSVEMaskOfIdenticalElements(Imm) && isSVECpyImm(S[0])) + if (isSVEMaskOfIdenticalElements(Imm) && isSVECpyImm(S[0], 4)) return false; - if (isSVEMaskOfIdenticalElements(Imm) && isSVECpyImm(H[0])) + if (isSVEMaskOfIdenticalElements(Imm) && isSVECpyImm(H[0], 2)) return false; - if (isSVEMaskOfIdenticalElements(Imm) && isSVECpyImm(B[0])) + if (isSVEMaskOfIdenticalElements(Imm) && isSVECpyImm(B[0], 1)) return false; return isLogicalImmediate(Imm, 64); }