Skip to content

[flang] Control alignment of constant folded reals #149381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flang/include/flang/Evaluate/integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Integer {
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)};
Expand Down
5 changes: 4 additions & 1 deletion flang/include/flang/Evaluate/real.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,10 @@ template <typename WORD, int PREC> class Real {
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
Expand Down
Loading