diff --git a/llvm/include/llvm/ADT/Bitset.h b/llvm/include/llvm/ADT/Bitset.h --- a/llvm/include/llvm/ADT/Bitset.h +++ b/llvm/include/llvm/ADT/Bitset.h @@ -56,23 +56,17 @@ } constexpr Bitset &set(unsigned I) { - // GCC <6.2 crashes if this is written in a single statement. - BitWord NewBits = Bits[I / BITWORD_SIZE] | (BitWord(1) << (I % BITWORD_SIZE)); - Bits[I / BITWORD_SIZE] = NewBits; + Bits[I / BITWORD_SIZE] |= BitWord(1) << (I % BITWORD_SIZE); return *this; } constexpr Bitset &reset(unsigned I) { - // GCC <6.2 crashes if this is written in a single statement. - BitWord NewBits = Bits[I / BITWORD_SIZE] & ~(BitWord(1) << (I % BITWORD_SIZE)); - Bits[I / BITWORD_SIZE] = NewBits; + Bits[I / BITWORD_SIZE] &= ~(BitWord(1) << (I % BITWORD_SIZE)); return *this; } constexpr Bitset &flip(unsigned I) { - // GCC <6.2 crashes if this is written in a single statement. - BitWord NewBits = Bits[I / BITWORD_SIZE] ^ (BitWord(1) << (I % BITWORD_SIZE)); - Bits[I / BITWORD_SIZE] = NewBits; + Bits[I / BITWORD_SIZE] ^= BitWord(1) << (I % BITWORD_SIZE); return *this; } @@ -109,9 +103,8 @@ } constexpr Bitset &operator&=(const Bitset &RHS) { - for (unsigned I = 0, E = Bits.size(); I != E; ++I) { + for (unsigned I = 0, E = Bits.size(); I != E; ++I) Bits[I] &= RHS.Bits[I]; - } return *this; } constexpr Bitset operator&(const Bitset &RHS) const { diff --git a/llvm/include/llvm/TargetParser/SubtargetFeature.h b/llvm/include/llvm/TargetParser/SubtargetFeature.h --- a/llvm/include/llvm/TargetParser/SubtargetFeature.h +++ b/llvm/include/llvm/TargetParser/SubtargetFeature.h @@ -60,23 +60,17 @@ } constexpr FeatureBitset &set(unsigned I) { - // GCC <6.2 crashes if this is written in a single statement. - uint64_t NewBits = Bits[I / 64] | (uint64_t(1) << (I % 64)); - Bits[I / 64] = NewBits; + Bits[I / 64] |= uint64_t(1) << (I % 64); return *this; } constexpr FeatureBitset &reset(unsigned I) { - // GCC <6.2 crashes if this is written in a single statement. - uint64_t NewBits = Bits[I / 64] & ~(uint64_t(1) << (I % 64)); - Bits[I / 64] = NewBits; + Bits[I / 64] &= ~(uint64_t(1) << (I % 64)); return *this; } constexpr FeatureBitset &flip(unsigned I) { - // GCC <6.2 crashes if this is written in a single statement. - uint64_t NewBits = Bits[I / 64] ^ (uint64_t(1) << (I % 64)); - Bits[I / 64] = NewBits; + Bits[I / 64] ^= uint64_t(1) << (I % 64); return *this; } @@ -113,9 +107,8 @@ } constexpr FeatureBitset &operator&=(const FeatureBitset &RHS) { - for (unsigned I = 0, E = Bits.size(); I != E; ++I) { + for (unsigned I = 0, E = Bits.size(); I != E; ++I) Bits[I] &= RHS.Bits[I]; - } return *this; } constexpr FeatureBitset operator&(const FeatureBitset &RHS) const { diff --git a/llvm/lib/TargetParser/X86TargetParser.cpp b/llvm/lib/TargetParser/X86TargetParser.cpp --- a/llvm/lib/TargetParser/X86TargetParser.cpp +++ b/llvm/lib/TargetParser/X86TargetParser.cpp @@ -42,9 +42,17 @@ } constexpr FeatureBitset &set(unsigned I) { - // GCC <6.2 crashes if this is written in a single statement. - uint32_t NewBits = Bits[I / 32] | (uint32_t(1) << (I % 32)); - Bits[I / 32] = NewBits; + Bits[I / 32] |= uint32_t(1) << (I % 32); + return *this; + } + + constexpr FeatureBitset &reset(unsigned I) { + Bits[I / 32] &= ~(uint32_t(1) << (I % 32)); + return *this; + } + + constexpr FeatureBitset &flip(unsigned I) { + Bits[I / 32] ^= uint32_t(1) << (I % 32); return *this; } @@ -54,36 +62,26 @@ } constexpr FeatureBitset &operator&=(const FeatureBitset &RHS) { - for (unsigned I = 0, E = std::size(Bits); I != E; ++I) { - // GCC <6.2 crashes if this is written in a single statement. - uint32_t NewBits = Bits[I] & RHS.Bits[I]; - Bits[I] = NewBits; - } + for (unsigned I = 0, E = std::size(Bits); I != E; ++I) + Bits[I] &= RHS.Bits[I]; return *this; } constexpr FeatureBitset &operator|=(const FeatureBitset &RHS) { - for (unsigned I = 0, E = std::size(Bits); I != E; ++I) { - // GCC <6.2 crashes if this is written in a single statement. - uint32_t NewBits = Bits[I] | RHS.Bits[I]; - Bits[I] = NewBits; - } + for (unsigned I = 0, E = std::size(Bits); I != E; ++I) + Bits[I] |= RHS.Bits[I]; return *this; } - // gcc 5.3 miscompiles this if we try to write this using operator&=. constexpr FeatureBitset operator&(const FeatureBitset &RHS) const { - FeatureBitset Result; - for (unsigned I = 0, E = std::size(Bits); I != E; ++I) - Result.Bits[I] = Bits[I] & RHS.Bits[I]; + FeatureBitset Result = *this; + Result &= RHS; return Result; } - // gcc 5.3 miscompiles this if we try to write this using operator&=. constexpr FeatureBitset operator|(const FeatureBitset &RHS) const { - FeatureBitset Result; - for (unsigned I = 0, E = std::size(Bits); I != E; ++I) - Result.Bits[I] = Bits[I] | RHS.Bits[I]; + FeatureBitset Result = *this; + Result |= RHS; return Result; }