Skip to content

Godbolt suggests MSVC compilers are not unrolling compile-time loops #806

Description

@TysonRayJones

As can be seen here, when switching to MSVC, the funcA<3> definition (which should be optimised) is instead identical to the funcA<-1> definition (which cannot be optimised).

In contrast, a GNU compiler replaces funcA<3> entirely with

"int funcA<3>(int)":
        mov     eax, 3
        ret

This suggests MSVC is not unrolling the various bitwise.hpp loops when the loop length is known at compile-time - and explains why Windows execution (with native MSVC) is noticeably slower in my ad hoc tests. Oh Microsoft! If no solution can be found (which doesn't involve enshittifying the entire codebase with manual unrolls), add doc to encourage accursed Windows users away from MSVC.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions