From a085c4b589b0ee730f0a33cb93592ab72f66923d Mon Sep 17 00:00:00 2001 From: Nicolas Vasilache Date: Thu, 11 Nov 2021 12:05:23 +0000 Subject: [PATCH] [mlir][Vector] Silence recently introduced warnings --- .../mlir/Dialect/X86Vector/Transforms.h | 18 +++++++++--------- .../X86Vector/Transforms/AVXTranspose.cpp | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mlir/include/mlir/Dialect/X86Vector/Transforms.h b/mlir/include/mlir/Dialect/X86Vector/Transforms.h index ebdc2f67e72d..66749d55d594 100644 --- a/mlir/include/mlir/Dialect/X86Vector/Transforms.h +++ b/mlir/include/mlir/Dialect/X86Vector/Transforms.h @@ -26,16 +26,16 @@ struct MaskHelper { /// b01 captures the lower 2 bits, b67 captures the higher 2 bits. /// Meant to be used with instructions such as mm256ShufflePs. template - static char shuffle() { + static int8_t shuffle() { static_assert(b01 <= 0x03, "overflow"); static_assert(b23 <= 0x03, "overflow"); static_assert(b45 <= 0x03, "overflow"); static_assert(b67 <= 0x03, "overflow"); - return (b67 << 6) + (b45 << 4) + (b23 << 2) + b01; + return static_cast((b67 << 6) | (b45 << 4) | (b23 << 2) | b01); } /// b01 captures the lower 2 bits, b67 captures the higher 2 bits. - static void extractShuffle(char mask, char &b01, char &b23, char &b45, - char &b67) { + static void extractShuffle(int8_t mask, int8_t &b01, int8_t &b23, int8_t &b45, + int8_t &b67) { b67 = (mask & (0x03 << 6)) >> 6; b45 = (mask & (0x03 << 4)) >> 4; b23 = (mask & (0x03 << 2)) >> 2; @@ -44,13 +44,13 @@ struct MaskHelper { /// b03 captures the lower 4 bits, b47 captures the higher 4 bits. /// Meant to be used with instructions such as mm256Permute2f128Ps. template - static char permute() { + static int8_t permute() { static_assert(b03 <= 0x0f, "overflow"); static_assert(b47 <= 0x0f, "overflow"); - return (b47 << 4) + b03; + return static_cast((b47 << 4) + b03); } /// b03 captures the lower 4 bits, b47 captures the higher 4 bits. - static void extractPermute(char mask, char &b03, char &b47) { + static void extractPermute(int8_t mask, int8_t &b03, int8_t &b47) { b47 = (mask & (0x0f << 4)) >> 4; b03 = mask & 0x0f; } @@ -80,7 +80,7 @@ Value mm256UnpackHiPs(ImplicitLocOpBuilder &b, Value v1, Value v2); /// Take an 8 bit mask, 2 bit for each position of a[0, 3) **and** b[0, 4): /// 0:127 | 128:255 /// b01 b23 C8 D8 | b01+4 b23+4 C8+4 D8+4 -Value mm256ShufflePs(ImplicitLocOpBuilder &b, Value v1, Value v2, char mask); +Value mm256ShufflePs(ImplicitLocOpBuilder &b, Value v1, Value v2, int8_t mask); // imm[0:1] out of imm[0:3] is: // 0 1 2 3 @@ -89,7 +89,7 @@ Value mm256ShufflePs(ImplicitLocOpBuilder &b, Value v1, Value v2, char mask); // 0 1 2 3 // imm[0:1] out of imm[4:7]. Value mm256Permute2f128Ps(ImplicitLocOpBuilder &b, Value v1, Value v2, - char mask); + int8_t mask); /// 4x8xf32-specific AVX2 transpose lowering. void transpose4x8xf32(ImplicitLocOpBuilder &ib, MutableArrayRef vs); diff --git a/mlir/lib/Dialect/X86Vector/Transforms/AVXTranspose.cpp b/mlir/lib/Dialect/X86Vector/Transforms/AVXTranspose.cpp index 783939583ae3..50c2df3aba77 100644 --- a/mlir/lib/Dialect/X86Vector/Transforms/AVXTranspose.cpp +++ b/mlir/lib/Dialect/X86Vector/Transforms/AVXTranspose.cpp @@ -38,8 +38,8 @@ Value mlir::x86vector::avx2::mm256UnpackHiPs(ImplicitLocOpBuilder &b, Value v1, /// 0:127 | 128:255 /// b01 b23 C8 D8 | b01+4 b23+4 C8+4 D8+4 Value mlir::x86vector::avx2::mm256ShufflePs(ImplicitLocOpBuilder &b, Value v1, - Value v2, char mask) { - char b01, b23, b45, b67; + Value v2, int8_t mask) { + int8_t b01, b23, b45, b67; MaskHelper::extractShuffle(mask, b01, b23, b45, b67); SmallVector shuffleMask{b01, b23, b45 + 8, b67 + 8, b01 + 4, b23 + 4, b45 + 8 + 4, b67 + 8 + 4}; @@ -54,9 +54,9 @@ Value mlir::x86vector::avx2::mm256ShufflePs(ImplicitLocOpBuilder &b, Value v1, // imm[0:1] out of imm[4:7]. Value mlir::x86vector::avx2::mm256Permute2f128Ps(ImplicitLocOpBuilder &b, Value v1, Value v2, - char mask) { + int8_t mask) { SmallVector shuffleMask; - auto appendToMask = [&](char control) { + auto appendToMask = [&](int8_t control) { if (control == 0) llvm::append_range(shuffleMask, ArrayRef{0, 1, 2, 3}); else if (control == 1) @@ -68,7 +68,7 @@ Value mlir::x86vector::avx2::mm256Permute2f128Ps(ImplicitLocOpBuilder &b, else llvm_unreachable("control > 3 : overflow"); }; - char b03, b47; + int8_t b03, b47; MaskHelper::extractPermute(mask, b03, b47); appendToMask(b03); appendToMask(b47);