Skip to content

Commit

Permalink
Partially revert rust-lang#47333.
Browse files Browse the repository at this point in the history
Removed the `assume()` which we assumed is the cause of misoptimization in
issue rust-lang#48116.
  • Loading branch information
kennytm committed Feb 14, 2018
1 parent 7984c89 commit ec36e7e
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,15 +1246,18 @@ macro_rules! iterator {
{
// The addition might panic on overflow
// Use the len of the slice to hint optimizer to remove result index bounds check.
let n = make_slice!(self.ptr, self.end).len();
let _n = make_slice!(self.ptr, self.end).len();
self.try_fold(0, move |i, x| {
if predicate(x) { Err(i) }
else { Ok(i + 1) }
}).err()
.map(|i| {
unsafe { assume(i < n) };
i
})
// // FIXME(#48116/#45964):
// // This assume() causes misoptimization on LLVM 6.
// // Commented out until it is fixed again.
// .map(|i| {
// unsafe { assume(i < n) };
// i
// })
}

#[inline]
Expand All @@ -1271,10 +1274,13 @@ macro_rules! iterator {
if predicate(x) { Err(i) }
else { Ok(i) }
}).err()
.map(|i| {
unsafe { assume(i < n) };
i
})
// // FIXME(#48116/#45964):
// // This assume() causes misoptimization on LLVM 6.
// // Commented out until it is fixed again.
// .map(|i| {
// unsafe { assume(i < n) };
// i
// })
}
}

Expand Down

0 comments on commit ec36e7e

Please sign in to comment.