@@ -44,7 +44,6 @@ class _MinmaxElementLessFunc {
4444template <class _Iter , class _Sent , class _Proj , class _Comp >
4545_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter>
4646__minmax_element_loop (_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
47- __builtin_printf (" Debug: __minmax_element_impl called, %d\n " , __LINE__); // 不需要 iostream
4847 auto __less = _MinmaxElementLessFunc<_Comp, _Proj>(__comp, __proj);
4948
5049 pair<_Iter, _Iter> __result (__first, __first);
@@ -154,11 +153,11 @@ __minmax_element_vectorized(_Iter __first, _Iter __last) {
154153 } else if (__epilogue_min_element < __min_element) {
155154 __min_element = __epilogue_min_element;
156155 __min_block_start = __first;
157- __min_block_end = __last;
156+ __min_block_end = __first; // this is global min_element
158157 } else {
159158 __max_element = __epilogue_max_element;
160159 __max_block_start = __first;
161- __max_block_end = __last;
160+ __max_block_end = __first; // this is global max_element
162161 }
163162 }
164163
@@ -168,6 +167,7 @@ __minmax_element_vectorized(_Iter __first, _Iter __last) {
168167 break ;
169168 }
170169
170+ // locate max
171171 for (; __max_block_start != __max_block_end; ++__max_block_start) {
172172 if (*__max_block_start == __max_element)
173173 break ;
0 commit comments