January 08, 2019
On Tuesday, 8 January 2019 at 12:35:16 UTC, H. S. Teoh wrote:
> On Tue, Jan 08, 2019 at 09:15:09AM +0000, Patrick Schluter via Digitalmars-d-learn wrote:
>> On Monday, 7 January 2019 at 23:20:57 UTC, H. S. Teoh wrote:
> [...]
>> > [...]
>> Are you sure it's dmd looking for the pattern. Playing with the godbolt link shows that dmd doesn't generate the rol code (gdc 4.8.2 neither).
>
> I vaguely remember a bug about this. There is definitely explicit checking for this in dmd; I don't remember if it was a bug in the pattern matching code itself, or some other problem, that made it fail. You may need to specify -O for the code to actually be active. Walter could point you to the actual function that does this optimization.
>
I did use the -O flag. The code generated did not use rol.
January 08, 2019
On Tuesday, 8 January 2019 at 09:15:09 UTC, Patrick Schluter wrote:
> Are you sure it's dmd looking for the pattern. Playing with the godbolt link shows that dmd doesn't generate the rol code (gdc 4.8.2 neither).

Looking at the dmd compiler source code, it requires the value to be rotated to be of a type no larger than an int and the amount that the value is rotated by to be a constant.

Example: https://d.godbolt.org/z/m3HiPq

Interestingly, if you rotate by exactly 16 bits, it will generate less optimal code.
1 2
Next ›   Last »