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

[patch] avoid tagging integers before right shifting it #5824

Closed
vicuna opened this issue Nov 14, 2012 · 1 comment
Closed

[patch] avoid tagging integers before right shifting it #5824

vicuna opened this issue Nov 14, 2012 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Nov 14, 2012

Original bug ID: 5824
Reporter: @chambart
Status: closed (set by @xavierleroy on 2015-12-11T18:08:24Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 4.01.0+dev
Category: back end (clambda to assembly)

Bug description

When right shifting a value, the rightmost bit can be ignored:

let f a =
(a lsl 3) lsr 2

is compiled as:

(or (>>u (+ (<< (+ a/1009 -1) 3) 1) 2) 1))

but could be:

(or (>>u (<< (+ a/1009 -1) 3) 2) 1))

File attachments

@vicuna
Copy link
Author

vicuna commented Nov 17, 2012

Comment author: @xavierleroy

Well spotted. Patch applied in trunk, revision 13096. Note that the checks "n > 0" in lsr_int and asr_int are probably unnecessary, since the code generated by Plsrint and Pasrint always does an "or 1" afterwards, restoring the correct tag bit even if n = 0. But n = 0 never happens in well-written code, so we can be conservative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant