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

fix Issue 14105 - strideImpl fails for 0xFF #2951

Merged
merged 1 commit into from Feb 2, 2015

Conversation

MartinNowak
Copy link
Member

  • bsr(0) returns an undefined result

Issue 14105 – strideImpl fails for 0xFF

- bsr(0) returns an undefined result
@@ -187,7 +187,7 @@ body
{
import core.bitop : bsr;
immutable msbs = 7 - bsr(~c);
if (msbs < 2 || msbs > 4)
if (!~c || msbs < 2 || msbs > 4)
Copy link
Member

Choose a reason for hiding this comment

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

correct me if I'm wrong: isn't !~c equal to c == 0. you comment sort of also implies that.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's equivalent to ~c == 0.

@schveiguy
Copy link
Member

Auto-merge toggled on

schveiguy added a commit that referenced this pull request Feb 2, 2015
fix Issue 14105 - strideImpl fails for 0xFF
@schveiguy schveiguy merged commit e65a331 into dlang:master Feb 2, 2015
@andralex
Copy link
Member

andralex commented Feb 2, 2015

fwiw dmd generates better code for c == 0xff: http://goo.gl/yy3Vdd

@MartinNowak MartinNowak deleted the fix14105 branch February 2, 2015 20:44
@MartinNowak
Copy link
Member Author

That's what LDC sez ;).

bool bug2.fun(char):
    movzbl %dil,%eax
    cmp    $0xff,%eax
    sete   %al
    retq   

bool bug2.gun(char):
    movzbl %dil,%eax
    cmp    $0xff,%eax
    sete   %al
    retq 

And GDC's opinion.

bool bug2.fun(char):
    cmp    $0xff,%dil
    sete   %al
    retq   

bool bug2.gun(char):
    cmp    $0xff,%dil
    sete   %al
    retq 

It's a pity for the endless hours we're wasting to optimize for dmd's backend.

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