-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Make use of getelementptr nuw in pointer::add #137217
Comments
cc @scottmcm as this seems like something up your alley :) |
Shouldn't need a new intrinsic -- we already lower rust/compiler/rustc_codegen_ssa/src/mir/rvalue.rs Lines 958 to 971 in 3b022d8
to check whether the RHS is unsigned, and add |
Oh nice, that will make things a lot simpler. Maybe I can even implement this myself... |
If you're tempted, go for it! Should be pretty similar to https://github.com/rust-lang/rust/pull/136575/files#diff-76d7dff532dc6719661f41c02777d2b1f8888cd0b8113b9908ed0085ef49fff4 , just with less confusion along the way since you actually know the LLVM API (unlike me :P) If not I'll get to it eventually, just not sure when that'll be. I'm excited for it, since I tried doing it with assumes in #123598 but perf wasn't happy with me. |
Emit getelementptr inbounds nuw for pointer::add() Lower pointer::add (via intrinsic::offset with unsigned offset) to getelementptr inbounds nuw on LLVM versions that support it. This lets LLVM make use of the pre-condition that the offset addition does not wrap in an unsigned sense. Together with inbounds, this also implies that the offset is non-negative. Fixes rust-lang#137217.
Emit getelementptr inbounds nuw for pointer::add() Lower pointer::add (via intrinsic::offset with unsigned offset) to getelementptr inbounds nuw on LLVM versions that support it. This lets LLVM make use of the pre-condition that the offset addition does not wrap in an unsigned sense. Together with inbounds, this also implies that the offset is non-negative. Fixes rust-lang#137217.
Emit getelementptr inbounds nuw for pointer::add() Lower pointer::add (via intrinsic::offset with unsigned offset) to getelementptr inbounds nuw on LLVM versions that support it. This lets LLVM make use of the pre-condition that the offset addition does not wrap in an unsigned sense. Together with inbounds, this also implies that the offset is non-negative. Fixes rust-lang/rust#137217.
Emit getelementptr inbounds nuw for pointer::add() Lower pointer::add (via intrinsic::offset with unsigned offset) to getelementptr inbounds nuw on LLVM versions that support it. This lets LLVM make use of the pre-condition that the offset addition does not wrap in an unsigned sense. Together with inbounds, this also implies that the offset is non-negative. Fixes rust-lang/rust#137217.
Emit getelementptr inbounds nuw for pointer::add() Lower pointer::add (via intrinsic::offset with unsigned offset) to getelementptr inbounds nuw on LLVM versions that support it. This lets LLVM make use of the pre-condition that the offset addition does not wrap in an unsigned sense. Together with inbounds, this also implies that the offset is non-negative. Fixes rust-lang/rust#137217.
add()
on pointers should generategetelementptr inbounds nuw
on LLVM 20 and above, to let LLVM know that the offset cannot be negative. We'll need a new variant ofintrinsic::offset
to pass down this information.The text was updated successfully, but these errors were encountered: