Skip to content

[flang] Set the offset based on the significant bytes in the boz input in big endian #102334

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 1 commit into from
Aug 8, 2024

Conversation

kkwli
Copy link
Collaborator

@kkwli kkwli commented Aug 7, 2024

The offset to the input data should be counted from most significant bit instead of zero in the big endian environment.

@kkwli kkwli requested review from DanielCChen and klausler August 7, 2024 17:21
@llvmbot llvmbot added flang:runtime flang Flang issues not falling into any other category labels Aug 7, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 7, 2024

@llvm/pr-subscribers-flang-runtime

Author: Kelvin Li (kkwli)

Changes

The offset to the input data should be counted from most significant bit instead of zero in the big endian environment.


Full diff: https://github.com/llvm/llvm-project/pull/102334.diff

1 Files Affected:

  • (modified) flang/runtime/edit-input.cpp (+1-1)
diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp
index 37989bbcee0ab..71021dd8a0158 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang/runtime/edit-input.cpp
@@ -119,7 +119,7 @@ static RT_API_ATTRS bool EditBOZInput(
   std::memset(n, 0, bytes);
   int increment{isHostLittleEndian ? -1 : 1};
   auto *data{reinterpret_cast<unsigned char *>(n) +
-      (isHostLittleEndian ? significantBytes - 1 : 0)};
+      (isHostLittleEndian ? significantBytes - 1 : bytes - significantBytes)};
   int shift{((digits - 1) * LOG2_BASE) & 7};
   while (digits > 0) {
     char32_t ch{*io.NextInField(remaining, edit)};

@kkwli kkwli self-assigned this Aug 7, 2024
@kkwli
Copy link
Collaborator Author

kkwli commented Aug 8, 2024

@klausler Thanks for the review.

@kkwli kkwli merged commit 59531cf into llvm:main Aug 8, 2024
11 checks passed
@kkwli kkwli deleted the fix-boz-input-be branch August 8, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:runtime flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants