[BranchFolding] Remove dubious assert from operator< (#71639)llvmorg-17.0.5
commit98bfdac5ce82d1679f8af9a57501471812ab68d7
authorNikita Popov <npopov@redhat.com>
Thu, 9 Nov 2023 09:23:10 +0000 (9 10:23 +0100)
committerTobias Hieta <tobias@hieta.se>
Tue, 14 Nov 2023 08:22:39 +0000 (14 09:22 +0100)
tree35c47da3874fee2de0ecb1da1a7acef08710924b
parent12c6ee8fd2046c85ae9693105288fcd749b90733
[BranchFolding] Remove dubious assert from operator< (#71639)

`MergePotentialElts::operator<` asserts that the two elements being
compared are not equal. However, sorting functions are allowed to invoke
the comparison function with equal arguments (though they usually don't
for efficiency reasons).

There is an existing special-case that disables the assert if
_GLIBCXX_DEBUG is used, which may invoke the comparator with equal args
to verify strict weak ordering. I believe libc++ also has strict weak
ordering checks under some options nowadays.

Recently, #71312 was reported, where a change to glibc's qsort_r
implementation can also result in comparison between equal elements.
From what I understood, this is an inefficiency that will be fixed on
the glibc side as well, but I think at this point we should just remove
this assertion.

Fixes https://github.com/llvm/llvm-project/issues/71312.

(cherry picked from commit 74a76a288562c486f377121855ef7db0386e0e43)
llvm/lib/CodeGen/BranchFolding.cpp