Short-circuit CHECK() in reinterpret_span<>().

Allows the optimizer to remove some 'int3/ud2' traps in release
builds when the source and dest have same alignment. Most of the
time, though, the dest alignment is 1, and the optimizer is already
removing the traps as anything % 1 == 0.

Change-Id: I82a912a3de827216bb58c1e0d6839f4cc5bcaeeb
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/121970
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@google.com>
diff --git a/core/fxcrt/span_util.h b/core/fxcrt/span_util.h
index 448f41d..f1ab143 100644
--- a/core/fxcrt/span_util.h
+++ b/core/fxcrt/span_util.h
@@ -153,7 +153,8 @@
           typename = typename std::enable_if_t<std::is_const_v<T> ||
                                                !std::is_const_v<U>>>
 inline pdfium::span<T> reinterpret_span(pdfium::span<U> s) noexcept {
-  CHECK_EQ(reinterpret_cast<uintptr_t>(s.data()) % alignof(T), 0u);
+  CHECK(alignof(T) == alignof(U) ||
+        reinterpret_cast<uintptr_t>(s.data()) % alignof(T) == 0u);
   // SAFETY: relies on correct conversion of size_bytes() result.
   return UNSAFE_BUFFERS(pdfium::make_span(reinterpret_cast<T*>(s.data()),
                                           s.size_bytes() / sizeof(T)));