Auto merge of #48583 - dotdash:jt_assume, r=alexcrichton

Backport LLVM fixes for a JumpThreading / assume intrinsic bug

This fixes the original cause of #48116 and restores the assume intrinsic that was removed as a workaround.

r? @alexcrichton
This commit is contained in:
bors 2018-03-03 14:09:56 +00:00
commit 3b8bd530b0
2 changed files with 10 additions and 16 deletions

View File

@ -1246,18 +1246,15 @@ fn position<P>(&mut self, mut predicate: P) -> Option<usize> where
{
// 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()
// // FIXME(#48116/#45964):
// // This assume() causes misoptimization on LLVM 6.
// // Commented out until it is fixed again.
// .map(|i| {
// unsafe { assume(i < n) };
// i
// })
.map(|i| {
unsafe { assume(i < n) };
i
})
}
#[inline]
@ -1274,13 +1271,10 @@ fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where
if predicate(x) { Err(i) }
else { Ok(i) }
}).err()
// // FIXME(#48116/#45964):
// // This assume() causes misoptimization on LLVM 6.
// // Commented out until it is fixed again.
// .map(|i| {
// unsafe { assume(i < n) };
// i
// })
.map(|i| {
unsafe { assume(i < n) };
i
})
}
}

@ -1 +1 @@
Subproject commit 9f81beaf32608fbe1fe0f2a82f974e800e9d8c62
Subproject commit ba2edd794c7def715007931fcd1b4ce62aa711c8