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

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

Closed
hadronized opened this issue Feb 2, 2020 · 2 comments
Closed

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

hadronized opened this issue Feb 2, 2020 · 2 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. I-slow Issue: Problems and improvements with respect to performance of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@hadronized
Copy link

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! :)

@jonas-schievink
Copy link
Contributor

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

@jonas-schievink jonas-schievink added C-enhancement Category: An issue proposing an enhancement or a PR with one. I-slow Issue: Problems and improvements with respect to performance of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Feb 2, 2020
@kennytm
Copy link
Member

kennytm commented Feb 2, 2020

Duplicate of #47234.

@kennytm kennytm closed this as completed Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. I-slow Issue: Problems and improvements with respect to performance of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants