[llvm] [BranchFolding] Remove dubious assert from operator< (PR #71639)
Alexander Monakov via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 8 10:26:21 PST 2023
================
@@ -485,13 +485,7 @@ BranchFolder::MergePotentialsElt::operator<(const MergePotentialsElt &o) const {
return true;
if (getBlock()->getNumber() > o.getBlock()->getNumber())
return false;
- // _GLIBCXX_DEBUG checks strict weak ordering, which involves comparing
- // an object with itself.
-#ifndef _GLIBCXX_DEBUG
- llvm_unreachable("Predecessor appears twice");
-#else
return false;
-#endif
----------------
amonakov wrote:
I think the point is to ensure that the array being sorted does not contain a pair of elements that compare equal, in which case it's more efficient to verify that by inspecting the sorted array:
```c++
for (MPIterator i = MergePotentials.begin(), n = std::next(i);
n != MergePotentials.end();
i = n, n++)
assert(*i < *n);
```
https://github.com/llvm/llvm-project/pull/71639
More information about the llvm-commits
mailing list