Made the logical shift / artihmetic shift not rely on signs of intigers #749
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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, butcg_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
) togcc_shr
(renamed fromgcc_lshr
). This allows both shift kinds to still share an implementation, while being very explicit about the requested shift.