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

via flang-commits flang-commits at lists.llvm.org
Tue Dec 12 16:00:25 PST 2023


================
@@ -222,7 +222,15 @@ bool EditIntegerInput(
     value = -value;
   }
   if (any || !io.GetConnectionState().IsAtEOF()) {
-    std::memcpy(n, &value, kind); // a blank field means zero
+    // For integer kind <= 4, the value is stored in the lower order bits on
----------------
kkwli wrote:

If the 128-bit input, the full 128-bit will be copied. I don't think reverse is needed. It is also the case for 64-bit input. Since the value is stored in `low_`, the `memcpy` just copies from `value` for the entire `low_`. However, for 32-bit input, in big endian, the left-half of `low_` is all zero and the right-half of `low_` has the 32-bit value. The `memcpy`  will always gets zero.


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


More information about the flang-commits mailing list