Skip to content

Add new intrinsic is_constant and optimize pow#114390

Closed
Centri3 wants to merge 11 commits intorust-lang:masterfrom
Centri3:llvm-is-constant
Closed

Add new intrinsic is_constant and optimize pow#114390
Centri3 wants to merge 11 commits intorust-lang:masterfrom
Centri3:llvm-is-constant

Conversation

@Centri3
Copy link
Copy Markdown
Member

@Centri3 Centri3 commented Aug 2, 2023

This was suggested in #114254. This basically lets LLVM know that it can evaluate the next few statements at compile-time, and thus can completely remove them. This allows us to select a path at compile-time, and with optimizations on, the other will be entirely removed. This will likely be a bit slower in debug mode but this should be ok.

I've done this for the integer's pow methods as was done in #114254 and it works great!

We should probably restrict the types that can be passed to it, though, llvm.is.constant can be passed any type but some ICE. (So far, I know that all ZSTs cause an ICE)

cc @rust-lang/lang; I highly doubt this shouldn't be insta-const, but I think discussion should be warranted anyway.

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.