Skip to content

2^i should be optimized to 1 << i #68773

@hadronized

Description

@hadronized

Hello,

I came across a weird situation with powers of 2. They’re not optimized away to left shifts. Here’s a Godbolt example.

If you think it should / can be addressed, I’d love to do it! :)

Activity

jonas-schievink

jonas-schievink commented on Feb 2, 2020

@jonas-schievink
Contributor

u32::pow uses hand-rolled exponentiation by squaring, which LLVM probably can't "see through"

added
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
I-slowIssue: Problems and improvements with respect to performance of generated code.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
on Feb 2, 2020
kennytm

kennytm commented on Feb 2, 2020

@kennytm
Member

Duplicate of #47234.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kennytm@hadronized@jonas-schievink

        Issue actions

          2^i should be optimized to 1 << i · Issue #68773 · rust-lang/rust