-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Bounds check not omitted #46863
Comments
This looks like a pass ordering issue - GVN is needed to simplify the double load, while IndVarSimplify is needed to eliminate the bounds check, while GVN occurs only after IndVarSimplify. see e.g. http://lists.llvm.org/pipermail/llvm-dev/2013-October/067045.html |
Minimal example - I suppose the identical C code has the same problem. Nothing but GVN can optimize loads across basic blocks, and nothing but indvars (I think) can fix up bounds checks. Maybe there's another bounds check removal pass we can run later in the pipeline. #![crate_type="rlib"]
pub fn f(l: &usize) -> u64 {
let mut sum = 0;
let len_1 = *l;
let mut i = 0;
while i < len_1 {
let len_2 = *l;
assert!(i < len_2);
i += 1;
}
sum
} |
Assuming this is nightly, I believe I also ran into this regression. https://users.rust-lang.org/t/surprising-auto-vectorization-optimization-behavior/14537 |
I believe this was fixed by #47828 |
Compiles with -C opt-level=3 -C panic=abort to:
It should be possible for the bounds check to be dropped.
The text was updated successfully, but these errors were encountered: