[PATCH] D49958: [MISC]Fix wrong usage of std::equal()
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 28 09:14:36 PDT 2018
lebedev.ri added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:2918-2920
// Min/max matching is only viable if all output VTs are the same.
- if (std::equal(ValueVTs.begin(), ValueVTs.end(), ValueVTs.begin())) {
+ if (ValueVTs.size() == 1 ||
+ std::equal(ValueVTs.begin() + 1, ValueVTs.end(), ValueVTs.begin())) {
----------------
I don't understand what this code is doing at all.
All three arguments point to the same array.
This is `(1)` in https://en.cppreference.com/w/cpp/algorithm/equal:
> 1,3) Returns true if the range [first1, last1) is equal to the range [first2, first2 + (last1 - first1)), and false otherwise
So it will equality-compare the `ValueVTs[i]` with `ValueVTs[i]` for all `i`?
But that is always `true` (well, except weird floats, etc)
Or am i completely misreading this?
Assuming the comment is the correct one, shouldn't this be
```
if (llvm::all_of(ValueVTs, [FirstVT = ValueVTs.front()](EVT VT) -> bool {
return VT == FirstVT;
})) {
```
?
https://reviews.llvm.org/D49958
More information about the llvm-commits
mailing list