https://issues.dlang.org/show_bug.cgi?id=24646

Dennis <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |performance
                 CC|                            |[email protected]
            Summary|`is` test broken for        |reading a bool generates
                   |invalid bools               |redundant masking code
           Severity|normal                      |enhancement

--- Comment #2 from Dennis <[email protected]> ---
There is no defined behavior for `is` on invalid bools, so you can't say it's
broken when dmd doesn't do a particular thing. It is true that dmd still does
redundant masking for bool from a previous safety fix, which can now be removed
since safe values for `bool` have been agreed upon and specified since, so I'll
reframe this as a performance issue.

This code:
```D
bool eq(bool a, bool b)
{
    return a is b;
}
```

Generates this code with `-O`:
```
mov     CL,SIL
and     CL,1
mov     DL,DIL
and     DL,1
cmp     CL,DL
setz    AL
pop     RBP
```

Which could have the `and` instructions removed.

--

Reply via email to