From: 
Subject: Debian changes

The Debian packaging of numpy-minmax is maintained in git, using a workflow
similar to the one described in dgit-maint-merge(7).
The Debian delta is represented by this one combined patch; there isn't a
patch queue that can be represented as a quilt series.

A detailed breakdown of the changes is available from their canonical
representation -- git commits in the packaging repository.
For example, to see the changes made by the Debian maintainer in the first
upload of upstream version 1.2.3, you could use:

    % git clone https://git.dgit.debian.org/numpy-minmax
    % cd numpy-minmax
    % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian'

(If you have dgit, use `dgit clone numpy-minmax`, rather than plain `git clone`.)

We don't use debian/source/options single-debian-patch because it has bugs.
Therefore, NMUs etc. may nevertheless have made additional patches.

---

diff --git a/numpy_minmax/__init__.py b/numpy_minmax/__init__.py
index 529745b..28c97fe 100644
--- a/numpy_minmax/__init__.py
+++ b/numpy_minmax/__init__.py
@@ -13,6 +13,8 @@ except ImportError:
 def minmax(a: NDArray) -> Tuple:
     if 0 in a.shape:
         raise ValueError("Cannot find min/max value in empty array")
+    if not a.flags["ALIGNED"]:
+        return np.amin(a), np.amax(a)
     if a.dtype == np.dtype("float32"):
         if a.flags["C_CONTIGUOUS"] or a.flags["F_CONTIGUOUS"]:
             result = _numpy_minmax.lib.minmax_contiguous_float32(
diff --git a/numpy_minmax/_minmax.c b/numpy_minmax/_minmax.c
index 5c2aa93..ccb329c 100644
--- a/numpy_minmax/_minmax.c
+++ b/numpy_minmax/_minmax.c
@@ -153,7 +153,7 @@ minmax_result_float32 minmax_avx_float32(const float *a, size_t length) {
     return reduce_result_from_mm256_float32(min_vals, max_vals, result);
 }
 
-static inline minmax_result_float32 reduce_result_from_mm512_float32(__m512 min_vals, __m512 max_vals, minmax_result_float32 result) {
+__attribute__((target("avx512f"))) static inline minmax_result_float32 reduce_result_from_mm512_float32(__m512 min_vals, __m512 max_vals, minmax_result_float32 result) {
     float temp_min[16], temp_max[16];
     _mm512_storeu_ps(temp_min, min_vals);
     _mm512_storeu_ps(temp_max, max_vals);
@@ -164,7 +164,7 @@ static inline minmax_result_float32 reduce_result_from_mm512_float32(__m512 min_
     return result;
 }
 
-minmax_result_float32 minmax_avx512_float32(const float *a, size_t length) {
+__attribute__((target("avx512f"))) minmax_result_float32 minmax_avx512_float32(const float *a, size_t length) {
     minmax_result_float32 result = { .min_val = FLT_MAX, .max_val = -FLT_MAX };
 
     __m512 min_vals = _mm512_loadu_ps(a);
diff --git a/numpy_minmax/_minmax_cffi.py b/numpy_minmax/_minmax_cffi.py
index 419edb6..0090c49 100644
--- a/numpy_minmax/_minmax_cffi.py
+++ b/numpy_minmax/_minmax_cffi.py
@@ -31,8 +31,7 @@ if os.name == "posix":
 
 # Detect architecture and set appropriate SIMD-related compile args
 if platform.machine().lower() in ["x86_64", "amd64", "i386", "i686"]:
-    extra_compile_args.append("-mavx")
-    extra_compile_args.append("-mavx512f")
+    extra_compile_args.append("-mavx2")
 
 ffibuilder.set_source("_numpy_minmax", c_code, extra_compile_args=extra_compile_args)
 
diff --git a/tests/test_minmax.py b/tests/test_minmax.py
index de2336d..5d4c2e6 100644
--- a/tests/test_minmax.py
+++ b/tests/test_minmax.py
@@ -199,6 +199,16 @@ def test_minmax_unaligned():
     assert max_val == np.amax(arr)
 
 
+def test_minmax_unaligned_int16():
+    buf = np.arange(203, dtype=np.uint8)
+    arr = np.frombuffer(buf.data, offset=1, count=100, dtype=np.int16)
+    assert arr.flags["ALIGNED"] == False
+
+    min_val, max_val = numpy_minmax.minmax(arr)
+    assert min_val == np.amin(arr)
+    assert max_val == np.amax(arr)
+
+
 @pytest.mark.parametrize("dtype", [np.float32, np.int16])
 def test_minmax_3d_shape(dtype):
     arr = np.random.uniform(low=-6.0, high=3.0, size=(2, 2, 16)).astype(dtype)
