-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[stdlib] Mark assume as has_side_effect=False #3658
Conversation
72f50e1
to
f929462
Compare
Actually, will |
f929462
to
92f1cae
Compare
92f1cae
to
9228148
Compare
@jackos do you mind taking a look at this? This is modeled after https://en.cppreference.com/w/cpp/language/attributes/assume. |
!sync |
@JoeLoser I now think this is the wrong thing to do. fn ff(n: Int) -> Int:
llvm_intrinsic["llvm.assume", NoneType, has_side_effect=False](n == 1)
return 666 if n == 1 else 777
fn gg(n: Int) -> Int:
llvm_intrinsic["llvm.assume", NoneType](n == 1)
return 666 if n == 1 else 777 Maybe we still want to put |
9228148
to
628430f
Compare
Signed-off-by: Yiwu Chen <[email protected]>
628430f
to
4ebb977
Compare
debug_assert
generate llvm.assume
when ASSERT=none
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @soraros I've updated externally to keep the has_side_effect=False for assume as that's the right thing to do, but removed assume from debug_assert as it's always DCE'd.
✅🟣 This contribution has been merged 🟣✅ Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the nightly branch during the next Mojo nightly release, typically within the next 24-48 hours. We use Copybara to merge external contributions, click here to learn more. |
Landed in 7a05c5c! Thank you for your contribution 🎉 |
[External] [stdlib] Mark assume as has_side_effect=False To enable DCE when calling `assume` Co-authored-by: soraros <[email protected]> Closes #3658 MODULAR_ORIG_COMMIT_REV_ID: 6e6a12d09ecfa9e75c3c0bb75b383df01a205e62
Also markassume
as side-effect free.