summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2023-05-23 15:50:10 -0700
committerJames Zern <jzern@google.com>2023-05-23 15:52:09 -0700
commit25f2e1ef255e89d5e7357aa2427926776327765a (patch)
treeee0db6c6b6e56a6362de8713866a89b0742cedea
parent95b56ab7df669ec5dd29c283fa5bf6d38c2df5d1 (diff)
downloadlibvpx-25f2e1ef255e89d5e7357aa2427926776327765a.tar
libvpx-25f2e1ef255e89d5e7357aa2427926776327765a.tar.gz
libvpx-25f2e1ef255e89d5e7357aa2427926776327765a.tar.bz2
libvpx-25f2e1ef255e89d5e7357aa2427926776327765a.zip
vpx_dsp_common.h,clip_pixel: work around VS2022 Arm64 issue
cl.exe targeting AArch64 with optimizations enabled produces invalid code for clip_pixel() when the return type is uint8_t. See: https://developercommunity.visualstudio.com/t/Misoptimization-for-ARM64-in-VS-2022-17/10363361 Bug: b/277255076 Bug: webm:1788 Change-Id: Ia3647698effd34f1cf196cd33fa4a8cab9fa53d6
-rw-r--r--vpx_dsp/vpx_dsp_common.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/vpx_dsp/vpx_dsp_common.h b/vpx_dsp/vpx_dsp_common.h
index 2de449546..4b946d756 100644
--- a/vpx_dsp/vpx_dsp_common.h
+++ b/vpx_dsp/vpx_dsp_common.h
@@ -45,9 +45,21 @@ typedef int16_t tran_low_t;
typedef int16_t tran_coef_t;
+// Visual Studio 2022 (cl.exe) targeting AArch64 with optimizations enabled
+// produces invalid code for clip_pixel() when the return type is uint8_t.
+// See:
+// https://developercommunity.visualstudio.com/t/Misoptimization-for-ARM64-in-VS-2022-17/10363361
+// TODO(jzern): check the compiler version after a fix for the issue is
+// released.
+#if defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__)
+static INLINE int clip_pixel(int val) {
+ return (val > 255) ? 255 : (val < 0) ? 0 : val;
+}
+#else
static INLINE uint8_t clip_pixel(int val) {
return (val > 255) ? 255 : (val < 0) ? 0 : val;
}
+#endif
static INLINE int clamp(int value, int low, int high) {
return value < low ? low : (value > high ? high : value);