Skip to content

Commit 558826a

Browse files
committed
Work around DevCom-10606350
1 parent 8b081e2 commit 558826a

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Diff for: stl/inc/algorithm

+20-6
Original file line numberDiff line numberDiff line change
@@ -3851,10 +3851,17 @@ _CONSTEXPR20 _OutIt replace_copy(_InIt _First, _InIt _Last, _OutIt _Dest, const
38513851
const auto _ULast = _STD _Get_unwrapped(_Last);
38523852
auto _UDest = _STD _Get_unwrapped_n(_Dest, _STD _Idl_distance<_InIt>(_UFirst, _ULast));
38533853
for (; _UFirst != _ULast; ++_UFirst, (void) ++_UDest) {
3854-
if (*_UFirst == _Oldval) {
3855-
*_UDest = _Newval;
3854+
if constexpr (is_integral_v<_Ty> && is_integral_v<iter_value_t<_InIt>>
3855+
|| is_pointer_v<_Ty> && is_pointer_v<iter_value_t<_InIt>>) {
3856+
// TRANSITION, DevCom-10606350: help the compiler auto-vectorizing for simple types
3857+
// by making transformation that can be done for simple types
3858+
*_UDest = (*_UFirst == _Oldval) ? _Newval : *_UFirst;
38563859
} else {
3857-
*_UDest = *_UFirst;
3860+
if (*_UFirst == _Oldval) {
3861+
*_UDest = _Newval;
3862+
} else {
3863+
*_UDest = *_UFirst;
3864+
}
38583865
}
38593866
}
38603867

@@ -3921,10 +3928,17 @@ namespace ranges {
39213928
_STL_INTERNAL_STATIC_ASSERT(indirect_binary_predicate<equal_to, projected<_It, _Pj>, const _Ty1*>);
39223929

39233930
for (; _First != _Last; ++_First, (void) ++_Result) {
3924-
if (_STD invoke(_Proj, *_First) == _Oldval) {
3925-
*_Result = _Newval;
3931+
if constexpr (is_integral_v<_Ty2> && is_integral_v<iter_value_t<_It>>
3932+
|| is_pointer_v<_Ty2> && is_pointer_v<iter_value_t<_It>>) {
3933+
// TRANSITION, DevCom-10606350: help the compiler auto-vectorizing for simple types
3934+
// by making transformation that can be done for simple types
3935+
*_Result = _STD invoke(_Proj, *_First) == _Oldval ? _Newval : *_First;
39263936
} else {
3927-
*_Result = *_First;
3937+
if (_STD invoke(_Proj, *_First) == _Oldval) {
3938+
*_Result = _Newval;
3939+
} else {
3940+
*_Result = *_First;
3941+
}
39283942
}
39293943
}
39303944

0 commit comments

Comments
 (0)