[llvm] r341750 - Revert "NFC: use bit_cast more in AArch64AddressingModes"
JF Bastien via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 8 09:50:56 PDT 2018
Author: jfb
Date: Sat Sep 8 09:50:56 2018
New Revision: 341750
URL: http://llvm.org/viewvc/llvm-project?rev=341750&view=rev
Log:
Revert "NFC: use bit_cast more in AArch64AddressingModes"
It seems some bots think std::array is either not trivially-copyable, or isn't
the right size.
Modified:
llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h
Modified: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h?rev=341750&r1=341749&r2=341750&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h (original)
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h Sat Sep 8 09:50:56 2018
@@ -754,8 +754,12 @@ static inline uint64_t decodeAdvSIMDModI
/// Returns true if Imm is the concatenation of a repeating pattern of type T.
template <typename T>
static inline bool isSVEMaskOfIdenticalElements(int64_t Imm) {
- auto Parts = bit_cast<std::array<T, sizeof(int64_t) / sizeof(T)>>(Imm);
- return all_of(Parts, [&](T Elem) { return Elem == Parts[0]; });
+ union {
+ int64_t Whole;
+ T Parts[sizeof(int64_t)/sizeof(T)];
+ } Vec { Imm };
+
+ return all_of(Vec.Parts, [Vec](T Elem) { return Elem == Vec.Parts[0]; });
}
/// Returns true if Imm is valid for CPY/DUP.
@@ -783,20 +787,29 @@ static inline bool isSVEAddSubImm(int64_
/// Return true if Imm is valid for DUPM and has no single CPY/DUP equivalent.
static inline bool isSVEMoveMaskPreferredLogicalImmediate(int64_t Imm) {
- if (isSVECpyImm<int64_t>(Imm))
- return false;
+ union {
+ int64_t D;
+ int32_t S[2];
+ int16_t H[4];
+ int8_t B[8];
+ } Vec = { Imm };
- auto S = bit_cast<std::array<int32_t, 2>>(Imm);
- auto H = bit_cast<std::array<int16_t, 4>>(Imm);
- auto B = bit_cast<std::array<int8_t, 8>>(Imm);
+ if (isSVECpyImm<int64_t>(Vec.D))
+ return false;
- if (isSVEMaskOfIdenticalElements<int32_t>(Imm) && isSVECpyImm<int32_t>(S[0]))
+ if (isSVEMaskOfIdenticalElements<int32_t>(Imm) &&
+ isSVECpyImm<int32_t>(Vec.S[0]))
return false;
- if (isSVEMaskOfIdenticalElements<int16_t>(Imm) && isSVECpyImm<int16_t>(H[0]))
+
+ if (isSVEMaskOfIdenticalElements<int16_t>(Imm) &&
+ isSVECpyImm<int16_t>(Vec.H[0]))
return false;
- if (isSVEMaskOfIdenticalElements<int8_t>(Imm) && isSVECpyImm<int8_t>(B[0]))
+
+ if (isSVEMaskOfIdenticalElements<int8_t>(Imm) &&
+ isSVECpyImm<int8_t>(Vec.B[0]))
return false;
- return isLogicalImmediate(Imm, 64);
+
+ return isLogicalImmediate(Vec.D, 64);
}
inline static bool isAnyMOVZMovAlias(uint64_t Value, int RegWidth) {
More information about the llvm-commits
mailing list