[flang-commits] [flang] [Flang] Shift the data from lower to higher order bits in the big endian environment (PR #73670)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Dec 18 11:24:06 PST 2023


================
@@ -34,14 +44,14 @@ template <bool IS_SIGNED = false> class Int128 {
   constexpr Int128(unsigned long n) : low_{n} {}
   constexpr Int128(unsigned long long n) : low_{n} {}
   constexpr Int128(int n)
-      : low_{static_cast<std::uint64_t>(n)}, high_{-static_cast<std::uint64_t>(
-                                                 n < 0)} {}
+      : SWAP(low_, static_cast<std::uint64_t>(n), high_,
----------------
klausler wrote:

Avoid the ugly macros with
```
constexpr Int128(... n) {
  low_ = n;
  high_ = -static_cast<std::uint64_t>(n<0);
}
```

https://github.com/llvm/llvm-project/pull/73670


More information about the flang-commits mailing list