Skip to content

Commit

Permalink
Auto merge of #48583 - dotdash:jt_assume, r=alexcrichton
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Mar 2, 2018
2 parents 9cb18a9 + 93cfb2a commit 6bf7d58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
24 changes: 9 additions & 15 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,18 +1246,15 @@ 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()
// // 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]
Expand All @@ -1274,13 +1271,10 @@ macro_rules! iterator {
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
})
}
}

Expand Down

0 comments on commit 6bf7d58

Please sign in to comment.