Skip to content

Made the logical shift / artihmetic shift not rely on signs of intigers #749

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FractalFir
Copy link
Contributor

Currently, ashr & lshr share the same implementation, and the shift type is guessed based on the sign of the type.

This is incorrect W.R.T. cg_ssa semantics(type don't have signs, operations do), and has caused silent miscompilations in the past(cg_ssa requested a logcal shift, but cg_gcc inserted an arithmetic one). This bug was pretty rare, but was still a miscompilation.

This PR fixes that bug, by introducing a new parameter(ShiftKind) to gcc_shr(renamed from gcc_lshr). This allows both shift kinds to still share an implementation, while being very explicit about the requested shift.

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.

1 participant