Skip to content

Commit

Permalink
Use union in AArch64_AM_isSVEMaskOfIdenticalElements type punning…
Browse files Browse the repository at this point in the history
… fix
  • Loading branch information
kazarmy committed Jan 9, 2024
1 parent 0d0edad commit 48a787b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arch/AArch64/AArch64AddressingModes.h
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,12 @@ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType12(uint8_t Imm)
#define DEFINE_isSVEMaskOfIdenticalElements(T) \
static inline bool CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, T)(int64_t Imm) \
{ \
T Parts[sizeof(int64_t) / sizeof(T)]; \
memcpy(Parts, &Imm, sizeof(int64_t) / sizeof(T) * sizeof(T)); \
union { \
uint64_t L; \
T A[sizeof(int64_t) / sizeof(T)]; \
} U; \
U.L = Imm; \
T *Parts = U.A; \
for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \
if (Parts[i] != Parts[0]) \
return false; \
Expand Down

0 comments on commit 48a787b

Please sign in to comment.