Skip to content

[ARM64] Fix lifting of tbz / tbnz for bits >= 32#7209

Merged
bdash merged 1 commit into
devfrom
arm64-tbz-tbnz
Jul 30, 2025
Merged

[ARM64] Fix lifting of tbz / tbnz for bits >= 32#7209
bdash merged 1 commit into
devfrom
arm64-tbz-tbnz

Conversation

@bdash

@bdash bdash commented Jul 30, 2025

Copy link
Copy Markdown
Contributor

Fixes #7205.

Since the integer literal 1 fits in an int, that is its type. Shifting it by values larger than 31 give unexpected behavior in this context. I'm not entirely sure how we get 0xffffffff80000000 as the result. That doesn't match my reading of https://en.cppreference.com/w/cpp/language/operator_arithmetic.html#Built-in_bitwise_shift_operators. Prior to C++20 this was undefined behavior territory, but with C++20 it should be well defined.

The fix is to ensure that the value we are shifting is a uint64_t.

@plafosse plafosse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at this this morning and identified this as the problem too. 👍

@bdash bdash merged commit 3e9f643 into dev Jul 30, 2025
4 of 5 checks passed
@bdash bdash deleted the arm64-tbz-tbnz branch July 30, 2025 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tbnz condition generates incorrect mask

2 participants