From 49ddd5aca1ec1421d51da31aab2c356e4df83161 Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Tue, 11 Sep 2018 04:08:05 +0000 Subject: [PATCH] NFC: use bit_cast more in AArch64AddressingModes The was previously committed as r341749 then reverted as r341750 because bit_cast needed to do its own thing to check is_trivially_copyable on GCC 4.x. This is now done and std;:array should now get accepted. llvm-svn: 341897 --- .../AArch64/MCTargetDesc/AArch64AddressingModes.h | 35 +++++++--------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h index 34b732a..688ca75 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h @@ -754,12 +754,8 @@ static inline uint64_t decodeAdvSIMDModImmType12(uint8_t Imm) { /// Returns true if Imm is the concatenation of a repeating pattern of type T. template static inline bool isSVEMaskOfIdenticalElements(int64_t Imm) { - 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]; }); + auto Parts = bit_cast>(Imm); + return all_of(Parts, [&](T Elem) { return Elem == Parts[0]; }); } /// Returns true if Imm is valid for CPY/DUP. @@ -787,29 +783,20 @@ static inline bool isSVEAddSubImm(int64_t Imm) { /// Return true if Imm is valid for DUPM and has no single CPY/DUP equivalent. static inline bool isSVEMoveMaskPreferredLogicalImmediate(int64_t Imm) { - union { - int64_t D; - int32_t S[2]; - int16_t H[4]; - int8_t B[8]; - } Vec = { Imm }; - - if (isSVECpyImm(Vec.D)) + if (isSVECpyImm(Imm)) return false; - if (isSVEMaskOfIdenticalElements(Imm) && - isSVECpyImm(Vec.S[0])) - return false; + auto S = bit_cast>(Imm); + auto H = bit_cast>(Imm); + auto B = bit_cast>(Imm); - if (isSVEMaskOfIdenticalElements(Imm) && - isSVECpyImm(Vec.H[0])) + if (isSVEMaskOfIdenticalElements(Imm) && isSVECpyImm(S[0])) return false; - - if (isSVEMaskOfIdenticalElements(Imm) && - isSVECpyImm(Vec.B[0])) + if (isSVEMaskOfIdenticalElements(Imm) && isSVECpyImm(H[0])) return false; - - return isLogicalImmediate(Vec.D, 64); + if (isSVEMaskOfIdenticalElements(Imm) && isSVECpyImm(B[0])) + return false; + return isLogicalImmediate(Imm, 64); } inline static bool isAnyMOVZMovAlias(uint64_t Value, int RegWidth) { -- 2.7.4