From ec36e7e972e8036fe7bd428458462a2aacd40927 Mon Sep 17 00:00:00 2001 From: kennytm Date: Wed, 14 Feb 2018 23:18:18 +0800 Subject: [PATCH] Partially revert #47333. Removed the `assume()` which we assumed is the cause of misoptimization in issue #48116. --- src/libcore/slice/mod.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index aacbbd5058e..ac390313a67 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -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] @@ -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 + // }) } }