**File:** modules/core/src/minmax.cpp
**Change Type:** modified
**Context:** PR #15488: Vectorize minMaxIdx functions - Vectorize minMaxIdx functions. minMaxIdx_8u & minMaxIdx_8s - 11.1x improvement on VSX and 8.6x speedup on x...

**Code Changes:**
```diff
@@ -71,33 +71,759 @@ minMaxIdx_( const T* src, const uchar* mask, WT* _minVal, WT* _maxVal,
     *_maxVal = maxVal;
 }
 
+#if CV_SIMD128
+template<typename T, typename WT> CV_ALWAYS_INLINE void
+minMaxIdx_init( const T* src, const uchar* mask, WT* minval, WT* maxval,
+                size_t* minidx, size_t* maxidx, WT &minVal, WT &maxVal,
+                size_t &minIdx, size_t &maxIdx, const WT minInit, const WT maxInit,
+                const int nlanes, int len, size_t startidx, int &j, int &len0 )
```

Review comment:
<details> <summary>Performance for SSE2 baseline</summary> | Performance test | Reference time | PR time | Speedup | |------------------|----------------|----------|---------| |minMaxLoc::Size_MatType::(127x61, 8UC1)|0.008|0.001|7.71| |minMaxLoc::Size_MatType::(127x61, 8SC1)|0.008|0.001|7.37| |minMaxLoc::Size_MatType::(127x61, 16UC1)|0.008|0.002|4.08| |minMaxLoc::Size_MatType::(127x61, 16SC1)|0.006|0.001|4.23| |minMaxLoc::Size_MatType::(127x61, 32SC1)|0.008|0.003|2.44| |minMaxLoc::Size_MatType::(127x61, 32FC1)|0.008|0.003|2.63| |minMaxLoc::Size_MatType::(127x61, 64FC1)|0.008|0.006|1.29| |minMaxLoc::Size_MatType::(640x480, 8UC1)|0.298|0.035|8.50| |minMaxLoc::Size_MatType::(640x480, 8SC1)|0.284|0.036|7.84| |minMaxLoc::Size_MatType::(640x480, 16UC1)|0.318|0.072|4.41| |minMaxLoc::Size_MatType::(640x480, 16SC1)|0.219|0.053|4.09| |minMaxLoc::Size_MatType::(640x480, 32SC1)|0.289|0.122|2.37| |minMaxLoc::Size_MatType::(640x480, 32FC1)|0.289|0.115|2.52| |minMaxLoc::Size_MatType::(640x480, 64FC1)|0.292|0.235|1.24| |minMaxLoc::Size_MatType::(1280x720, 8UC1)|0.842|0.102|8.22| |minMaxLoc::Size_MatType::(1280x720, 8SC1)|0.850|0.106|8.04| |minMaxLoc::Size_MatType::(1280x720, 16UC1)|0.965|0.214|4.50| |minMaxLoc::Size_MatType::(1280x720, 16SC1)|0.647|0.156|4.14| |minMaxLoc::Size_MatType::(1280x720, 32SC1)|0.881|0.360|2.45| |minMaxLoc::Size_MatType::(1280x720, 32FC1)|0.903|0.330|2.73| |minMaxLoc::Size_MatType::(1280x720, 64FC1)|0.912|0.707|1.29| |minMaxLoc::Size_MatType::(1920x1080, 8UC1)|1.996|0.231|8.64| |minMaxLoc::Size_MatType::(1920x1080, 8SC1)|1.987|0.238|8.34| |minMaxLoc::Size_MatType::(1920x1080, 16UC1)|2.048|0.480|4.26| |minMaxLoc::Size_MatType::(1920x1080, 16SC1)|1.585|0.350|4.53| |minMaxLoc::Size_MatType::(1920x1080, 32SC1)|1.999|0.836|2.39| |minMaxLoc::Size_MatType::(1920x1080, 32FC1)|2.038|0.766|2.66| |minMaxLoc::Size_MatType::(1920x1080, 64FC1)|2.245|1.807|1.24| </details> <details> <summary>Performance for SSE3 baseline</summary> | Performance test | Reference time | PR time | Speedup | |------------------|----------------|----------|---------| |minMaxLoc::Size_MatType::(127x61, 8UC1)|0.006|0.001|5.77| |minMaxLoc::Size_MatType::(127x61, 8SC1)|0.006|0.001|5.73| |minMaxLoc::Size_MatType::(127x61, 16UC1)|0.006|0.002|3.10| |minMaxLoc::Size_MatType::(127x61, 16SC1)|0.008|0.001|5.51| |minMaxLoc::Size_MatType::(127x61, 32SC1)|0.008|0.003|2.42| |minMaxLoc::Size_MatType::(127x61, 32FC1)|0.008|0.003|2.61| |minMaxLoc::Size_MatType::(127x61, 64FC1)|0.008|0.006|1.28| |minMaxLoc::Size_MatType::(640x480, 8UC1)|0.220|0.035|6.36| |minMaxLoc::Size_MatType::(640x480, 8SC1)|0.217|0.036|5.99| |minMaxLoc::Size_MatType::(640x480, 16UC1)|0.220|0.072|3.03| |minMaxLoc::Size_MatType::(640x480, 16SC1)|0.315|0.053|5.96| |minMaxLoc::Size_MatType::(640x480, 32SC1)|0.288|0.121|2.38| |minMaxLoc::Size_MatType::(640x480, 32FC1)|0.290|0.115|2.52| |minMaxLoc::Size_MatType::(640x480, 64FC1)|0.304|0.232|1.31| |minMaxLoc::Size_MatType::(1280x720, 8UC1)|0.689|0.103|6.71| |minMaxLoc::Size_MatType::(1280x720, 8SC1)|0.677|0.107|6.36| |minMaxLoc::Size_MatType::(1280x720, 16UC1)|0.683|0.215|3.17| |minMaxLoc::Size_MatType::(1280x720, 16SC1)|0.886|0.156|5.70| |minMaxLoc::Size_MatType::(1280x720, 32SC1)|0.884|0.360|2.46| |minMaxLoc::Size_MatType::(1280x720, 32FC1)|0.902|0.327|2.76| |minMaxLoc::Size_MatType::(1280x720, 64FC1)|0.913|0.699|1.31| |minMaxLoc::Size_MatType::(1920x1080, 8UC1)|1.577|0.230|6.84| |minMaxLoc::Size_MatType::(1920x1080, 8SC1)|1.614|0.238|6.77| |minMaxLoc::Size_MatType::(1920x1080, 16UC1)|1.558|0.480|3.25| |minMaxLoc::Size_MatType::(1920x1080, 16SC1)|1.913|0.348|5.49| |minMaxLoc::Size_MatType::(1920x1080, 32SC1)|1.902|0.826|2.30| |minMaxLoc::Size_MatType::(1920x1080, 32FC1)|1.944|0.759|2.56| |minMaxLoc::Size_MatType::(1920x1080, 64FC1)|2.155|1.823|1.18| </details> <details> <summary>Performance for SSE4_2 baseline</summary> | Performance test | Reference time | PR time | Speedup | |------------------|----------------|----------|---------| |minMaxLoc::Size_MatType::(127x61, 8UC1)|0.008|0.001|8.72| |minMaxLoc::Size_MatType::(127x61, 8SC1)|0.008|0.001|10.69| |minMaxLoc::Size_MatType::(127x61, 16UC1)|0.009|0.001|6.12| |minMaxLoc::Size_MatType::(127x61, 16SC1)|0.006|0.001|4.86| |minMaxLoc::Size_MatType::(127x61, 32SC1)|0.008|0.002|4.27| |minMaxLoc::Size_MatType::(127x61, 32FC1)|0.008|0.003|2.84| |minMaxLoc::Size_MatType::(127x61, 64FC1)|0.008|0.006|1.29| |minMaxLoc::Size_MatType::(640x480, 8UC1)|0.298|0.029|10.12| |minMaxLoc::Size_MatType::(640x480, 8SC1)|0.297|0.023|12.68| |minMaxLoc::Size_MatType::(640x480, 16UC1)|0.348|0.053|6.54| |minMaxLoc::Size_MatType::(640x480, 16SC1)|0.229|0.044|5.20| |minMaxLoc::Size_MatType::(640x480, 32SC1)|0.298|0.068|4.35| |minMaxLoc::Size_MatType::(640x480, 32FC1)|0.305|0.103|2.95| |minMaxLoc::Size_MatType::(640x480, 64FC1)|0.309|0.230|1.35| |minMaxLoc::Size_MatType::(1280x720, 8UC1)|0.893|0.088|10.20| |minMaxLoc::Size_MatType::(1280x720, 8SC1)|0.883|0.070|12.59| |minMaxLoc::Size_MatType::(1280x720, 16UC1)|1.028|0.159|6.46| |minMaxLoc::Size_MatType::(1280x720, 16SC1)|0.678|0.130|5.22| |minMaxLoc::Size_MatType::(1280x720, 32SC1)|0.916|0.203|4.50| |minMaxLoc::Size_MatType::(1280x720, 32FC1)|0.925|0.306|3.03| |minMaxLoc::Size_MatType::(1280x720, 64FC1)|0.936|0.662|1.41| |minMaxLoc::Size_MatType::(1920x1080, 8UC1)|1.988|0.188|10.60| |minMaxLoc::Size_MatType::(1920x1080, 8SC1)|1.987|0.150|13.22| |minMaxLoc::Size_MatType::(1920x1080, 16UC1)|2.068|0.339|6.10| |minMaxLoc::Size_MatType::(1920x1080, 16SC1)|1.522|0.277|5.49| |minMaxLoc::Size_MatType::(1920x1080, 32SC1)|1.996|0.478|4.17| |minMaxLoc::Size_MatType::(1920x1080, 32FC1)|1.951|0.698|2.80| |minMaxLoc::Size_MatType::(1920x1080, 64FC1)|2.158|1.736|1.24| </details> <details> <summary>Performance for AVX2 baseline</summary> | Performance test | Reference time | PR time | Speedup | |------------------|----------------|----------|---------| |minMaxLoc::Size_MatType::(127x61, 8UC1)|0.006|0.001|6.56| |minMaxLoc::Size_MatType::(127x61, 8SC1)|0.006|0.001|8.59| |minMaxLoc::Size_MatType::(127x61, 16UC1)|0.008|0.002|5.01| |minMaxLoc::Size_MatType::(127x61, 16SC1)|0.008|0.001|5.81| |minMaxLoc::Size_MatType::(127x61, 32SC1)|0.010|0.002|4.84| |minMaxLoc::Size_MatType::(127x61, 32FC1)|0.008|0.003|3.20| |minMaxLoc::Size_MatType::(127x61, 64FC1)|0.008|0.005|1.56| |minMaxLoc::Size_MatType::(640x480, 8UC1)|0.229|0.030|7.56| |minMaxLoc::Size_MatType::(640x480, 8SC1)|0.218|0.022|9.92| |minMaxLoc::Size_MatType::(640x480, 16UC1)|0.309|0.058|5.34| |minMaxLoc::Size_MatType::(640x480, 16SC1)|0.296|0.049|6.06| |minMaxLoc::Size_MatType::(640x480, 32SC1)|0.362|0.074|4.92| |minMaxLoc::Size_MatType::(640x480, 32FC1)|0.292|0.091|3.21| |minMaxLoc::Size_MatType::(640x480, 64FC1)|0.290|0.190|1.53| |minMaxLoc::Size_MatType::(1280x720, 8UC1)|0.661|0.090|7.35| |minMaxLoc::Size_MatType::(1280x720, 8SC1)|0.654|0.063|10.36| |minMaxLoc::Size_MatType::(1280x720, 16UC1)|0.896|0.164|5.45| |minMaxLoc::Size_MatType::(1280x720, 16SC1)|0.885|0.138|6.42| |minMaxLoc::Size_MatType::(1280x720, 32SC1)|1.061|0.218|4.87| |minMaxLoc::Size_MatType::(1280x720, 32FC1)|0.904|0.273|3.32| |minMaxLoc::Size_MatType::(1280x720, 64FC1)|0.911|0.583|1.56| |minMaxLoc::Size_MatType::(1920x1080, 8UC1)|1.530|0.201|7.63| |minMaxLoc::Size_MatType::(1920x1080, 8SC1)|1.522|0.142|10.73| |minMaxLoc::Size_MatType::(1920x1080, 16UC1)|2.007|0.366|5.49| |minMaxLoc::Size_MatType::(1920x1080, 16SC1)|1.987|0.304|6.53| |minMaxLoc::Size_MatType::(1920x1080, 32SC1)|2.347|0.520|4.51| |minMaxLoc::Size_MatType::(1920x1080, 32FC1)|2.038|0.627|3.25| |minMaxLoc::Size_MatType::(1920x1080, 64FC1)|2.244|1.637|1.37| </details>