Skip to content

Improve Span bounds check elimination by adding _assumeNonNegative to count #83172

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eeckstein
Copy link
Contributor

No description provided.

@eeckstein eeckstein force-pushed the span-bounds-checking branch from 02ac763 to 451290d Compare July 18, 2025 15:12
@@ -626,6 +626,9 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin,
llvm::MDNode *range = llvm::MDNode::get(ctx, rangeElems);
I->setMetadata(llvm::LLVMContext::MD_range, range);
}
} else {
auto *cmp = IGF.Builder.CreateICmpSGE(v, llvm::ConstantInt::get(v->getType(), 0));
IGF.Builder.CreateIntrinsicCall(llvm::Intrinsic::assume, cmp);
Copy link
Contributor

@stephentyrone stephentyrone Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with taking this as is, but we should talk to LLVM about whether they'd prefer we use range metadata or llvm.assume for these going forward, and then make both paths use the one they want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants