Skip to content
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

PR for llvm/llvm-project#64794 #768

Merged
merged 1 commit into from
Nov 13, 2023
Merged

PR for llvm/llvm-project#64794 #768

merged 1 commit into from
Nov 13, 2023

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Nov 8, 2023

If we start with an i128 shift, the initial shift amount would usually
have zeros in bit 8 and above. xoring the shift amount with -1 will set
those upper bits to 1. If DAGCombiner is able to prove those bits are
now 1, then the shift that uses the xor will be replaced with undef.
Which we don't want.

Reduce the xor constant to VT.bits-1 where VT is half the size of the
larger shift type. This avoids toggling the upper bits. The hardware
shift instruction only uses the lower bits of the shift amount. I assume
the code used NOT because the hardware doesn't use the upper bits, but
that isn't compatible with the LLVM poison semantics.

Fixes #71142.

(cherry picked from commit 8d24d3900ec3f28902b2fad4a2c2c2b789257424)
@tru
Copy link
Contributor

tru commented Nov 13, 2023

@nikic ok to backport?

@nikic
Copy link
Contributor

nikic commented Nov 13, 2023

LGTM

@tru tru merged commit e7dc53b into release/17.x Nov 13, 2023
14 of 15 checks passed
@tru tru deleted the llvm-issue64794 branch November 13, 2023 09:50
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.

[MIPS] miscompile of 64-bit shift with masked shift amount
4 participants