[PATCH] D49958: [MISC]Fix wrong usage of std::equal()

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 29 01:40:34 PDT 2018


shchenz added a comment.

Thanks all for your comments.



================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:2919
   // Min/max matching is only viable if all output VTs are the same.
-  if (std::equal(ValueVTs.begin(), ValueVTs.end(), ValueVTs.begin())) {
     EVT VT = ValueVTs[0];
----------------
inouehrs wrote:
> ikulagin wrote:
> > lebedev.ri wrote:
> > > This seems to originate from @jmolloy from rL237423.
> > maybe it was supposed like this:
> > 
> > ```
> > if (std::equal(ValueVTs.begin(), ValueVTs.end(), ValueVTs.rbegin())) { 
> > ```
> > iterate from both ends
> Comparing from both side may return true for sequences like 1, 2, 1 or 1, 2, 2, 1, although they are not all the same. 
Yes, iterating from both ends can only get a palindrome pattern like {1,2,3,4,5,4,3,2,1}. Here we need to check all values in container are the same I think.


https://reviews.llvm.org/D49958





More information about the llvm-commits mailing list