[flang] Control alignment of constant folded reals (#149381)
When REAL types are constant folded, the underneath implementation uses arrays of integers. Ensure that these arrays are properly aligned. This matters when building flang with clang. In some cases, the resulting code for flang compiler ended up using SSE2 aligned load instructions for REAL(16) constant folding on x86_64, and these instructions require that the values are loaded from the aligned addresses.
This commit is contained in:
parent
2a78c6d45d
commit
45a6c02c21
@ -74,6 +74,7 @@ public:
|
||||
static_assert(std::is_unsigned_v<BigPart>);
|
||||
static_assert(CHAR_BIT * sizeof(BigPart) >= 2 * partBits);
|
||||
static constexpr bool littleEndian{IS_LITTLE_ENDIAN};
|
||||
static constexpr int alignment{ALIGNMENT};
|
||||
|
||||
private:
|
||||
static constexpr int maxPartBits{CHAR_BIT * sizeof(Part)};
|
||||
|
@ -490,7 +490,10 @@ private:
|
||||
bool isNegative, int exponent, const Fraction &, Rounding, RoundingBits,
|
||||
bool multiply = false);
|
||||
|
||||
Word word_{}; // an Integer<>
|
||||
// Require alignment, in case code generation on x86_64 decides that our
|
||||
// Real object is suitable for SSE2 instructions and then gets surprised
|
||||
// by unaligned address.
|
||||
alignas(Word::alignment / 8) Word word_{}; // an Integer<>
|
||||
};
|
||||
|
||||
extern template class Real<Integer<16>, 11>; // IEEE half format
|
||||
|
Loading…
x
Reference in New Issue
Block a user