[PATCH] D120395: [X86] Prohibit arithmatic operations on type `__bfloat16`

Phoebe Wang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 23 05:43:37 PST 2022


pengfei added a comment.

In D120395#3340041 <https://reviews.llvm.org/D120395#3340041>, @RKSimon wrote:

> but its still OK to perform arithmetic with __m128bh ? https://simd.godbolt.org/z/Ef59Ws4M3

Good point! I'd think the define of `__m128bh` is wrong direction. We should use `__m128i` like we doing with f16c intrinsics and reserve `__m128bh` for ABI type like we doing with avx512fp16.
I tried to warn for it using `deprecated` but it didn't report warning at all. Any thought?

  diff --git a/clang/lib/Headers/avx512bf16intrin.h b/clang/lib/Headers/avx512bf16intrin.h
  index 54f0cb9cfbf1..2f9cda6b32f2 100644
  --- a/clang/lib/Headers/avx512bf16intrin.h
  +++ b/clang/lib/Headers/avx512bf16intrin.h
  @@ -13,8 +13,10 @@
   #ifndef __AVX512BF16INTRIN_H
   #define __AVX512BF16INTRIN_H
  
  -typedef short __m512bh __attribute__((__vector_size__(64), __aligned__(64)));
  -typedef short __m256bh __attribute__((__vector_size__(32), __aligned__(32)));
  +typedef short __m512bh __attribute__((__vector_size__(64), __aligned__(64),
  +                                      deprecated("use __m512i instead")));
  +typedef short __m256bh __attribute__((__vector_size__(32), __aligned__(32),
  +                                      deprecated("use __m256i instead")));
  
   /// \typedef __bfloat16
   ///    A target specific type to represent the storage only brain floating-point
  diff --git a/clang/lib/Headers/avx512vlbf16intrin.h b/clang/lib/Headers/avx512vlbf16intrin.h
  index d42f8eb0f0f5..0e47a930ebd0 100644
  --- a/clang/lib/Headers/avx512vlbf16intrin.h
  +++ b/clang/lib/Headers/avx512vlbf16intrin.h
  @@ -13,7 +13,8 @@
   #ifndef __AVX512VLBF16INTRIN_H
   #define __AVX512VLBF16INTRIN_H
  
  -typedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));
  +typedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16),
  +                                      deprecated("use __m128i instead")));
  
   #define __DEFAULT_FN_ATTRS128 \
     __attribute__((__always_inline__, __nodebug__, \


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120395/new/

https://reviews.llvm.org/D120395



More information about the cfe-commits mailing list