[llvm] 2671aa7 - [WebAssembly][NFC] Add test case for {u,s}itofp on SIMD types
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 3 11:13:51 PST 2023
Author: Luke Lau
Date: 2023-01-03T19:13:16Z
New Revision: 2671aa7e84367aae98cea8e37211b7afd31a20ce
URL: https://github.com/llvm/llvm-project/commit/2671aa7e84367aae98cea8e37211b7afd31a20ce
DIFF: https://github.com/llvm/llvm-project/commit/2671aa7e84367aae98cea8e37211b7afd31a20ce.diff
LOG: [WebAssembly][NFC] Add test case for {u,s}itofp on SIMD types
These test cases should be updated in a following patch once fixed
Part of https://github.com/llvm/llvm-project/issues/57182
Added:
llvm/test/CodeGen/WebAssembly/simd-extending-convert.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/WebAssembly/simd-extending-convert.ll b/llvm/test/CodeGen/WebAssembly/simd-extending-convert.ll
new file mode 100644
index 0000000000000..b42754ad65172
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/simd-extending-convert.ll
@@ -0,0 +1,245 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mattr=+simd128 | FileCheck %s
+
+; TODO: These tests should check that floating point conversions select
+; extending instructions where possible
+
+target triple = "wasm32-unknown-unknown"
+
+define <4 x float> @extend_to_float_low_i16x8_u(<8 x i16> %x) {
+; CHECK-LABEL: extend_to_float_low_i16x8_u:
+; CHECK: .functype extend_to_float_low_i16x8_u (v128) -> (v128)
+; CHECK-NEXT: # %bb.0:
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_u 0
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.splat
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_u 1
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 1
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_u 2
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 2
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_u 3
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 3
+; CHECK-NEXT: # fallthrough-return
+ %low = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %extended = uitofp <4 x i16> %low to <4 x float>
+ ret <4 x float> %extended
+}
+
+define <4 x float> @extend_to_float_high_i16x8_u(<8 x i16> %x) {
+; CHECK-LABEL: extend_to_float_high_i16x8_u:
+; CHECK: .functype extend_to_float_high_i16x8_u (v128) -> (v128)
+; CHECK-NEXT: # %bb.0:
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_u 4
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.splat
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_u 5
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 1
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_u 6
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 2
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_u 7
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 3
+; CHECK-NEXT: # fallthrough-return
+ %high = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ %extended = uitofp <4 x i16> %high to <4 x float>
+ ret <4 x float> %extended
+}
+
+define <4 x float> @extend_to_float_low_i8x16_u(<8 x i8> %x) {
+; CHECK-LABEL: extend_to_float_low_i8x16_u:
+; CHECK: .functype extend_to_float_low_i8x16_u (v128) -> (v128)
+; CHECK-NEXT: # %bb.0:
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_u 0
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.splat
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_u 1
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 1
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_u 2
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 2
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_u 3
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 3
+; CHECK-NEXT: # fallthrough-return
+ %low = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %extended = uitofp <4 x i8> %low to <4 x float>
+ ret <4 x float> %extended
+}
+
+define <4 x float> @extend_to_float_high_i8x16_u(<8 x i8> %x) {
+; CHECK-LABEL: extend_to_float_high_i8x16_u:
+; CHECK: .functype extend_to_float_high_i8x16_u (v128) -> (v128)
+; CHECK-NEXT: # %bb.0:
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_u 4
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.splat
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_u 5
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 1
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_u 6
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 2
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_u 7
+; CHECK-NEXT: f32.convert_i32_u
+; CHECK-NEXT: f32x4.replace_lane 3
+; CHECK-NEXT: # fallthrough-return
+ %high = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ %extended = uitofp <4 x i8> %high to <4 x float>
+ ret <4 x float> %extended
+}
+
+define <4 x float> @extend_to_float_low_i16x8_s(<8 x i16> %x) {
+; CHECK-LABEL: extend_to_float_low_i16x8_s:
+; CHECK: .functype extend_to_float_low_i16x8_s (v128) -> (v128)
+; CHECK-NEXT: # %bb.0:
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_s 0
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.splat
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_s 1
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 1
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_s 2
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 2
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_s 3
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 3
+; CHECK-NEXT: # fallthrough-return
+ %low = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %extended = sitofp <4 x i16> %low to <4 x float>
+ ret <4 x float> %extended
+}
+
+define <4 x float> @extend_to_float_high_i16x8_s(<8 x i16> %x) {
+; CHECK-LABEL: extend_to_float_high_i16x8_s:
+; CHECK: .functype extend_to_float_high_i16x8_s (v128) -> (v128)
+; CHECK-NEXT: # %bb.0:
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_s 4
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.splat
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_s 5
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 1
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_s 6
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 2
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_s 7
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 3
+; CHECK-NEXT: # fallthrough-return
+ %high = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ %extended = sitofp <4 x i16> %high to <4 x float>
+ ret <4 x float> %extended
+}
+
+define <4 x float> @extend_to_float_low_i8x16_s(<8 x i8> %x) {
+; CHECK-LABEL: extend_to_float_low_i8x16_s:
+; CHECK: .functype extend_to_float_low_i8x16_s (v128) -> (v128)
+; CHECK-NEXT: # %bb.0:
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_s 0
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.splat
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_s 1
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 1
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_s 2
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 2
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_s 3
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 3
+; CHECK-NEXT: # fallthrough-return
+ %low = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %extended = sitofp <4 x i8> %low to <4 x float>
+ ret <4 x float> %extended
+}
+
+define <4 x float> @extend_to_float_high_i8x16_s(<8 x i8> %x) {
+; CHECK-LABEL: extend_to_float_high_i8x16_s:
+; CHECK: .functype extend_to_float_high_i8x16_s (v128) -> (v128)
+; CHECK-NEXT: # %bb.0:
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_s 4
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.splat
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_s 5
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 1
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_s 6
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 2
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i8x16.extract_lane_s 7
+; CHECK-NEXT: f32.convert_i32_s
+; CHECK-NEXT: f32x4.replace_lane 3
+; CHECK-NEXT: # fallthrough-return
+ %high = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ %extended = sitofp <4 x i8> %high to <4 x float>
+ ret <4 x float> %extended
+}
+
+define <2 x double> @extend_to_double_low_i32x4_u(<4 x i32> %x) {
+; CHECK-LABEL: extend_to_double_low_i32x4_u:
+; CHECK: .functype extend_to_double_low_i32x4_u (v128) -> (v128)
+; CHECK-NEXT: # %bb.0:
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: f64x2.convert_low_i32x4_u
+; CHECK-NEXT: # fallthrough-return
+ %low = shufflevector <4 x i32> %x, <4 x i32> undef, <2 x i32> <i32 0, i32 1>
+ %extended = uitofp <2 x i32> %low to <2 x double>
+ ret <2 x double> %extended
+}
+
+define <2 x double> @extend_to_double_low_i16x4_u(<4 x i16> %x) {
+; CHECK-LABEL: extend_to_double_low_i16x4_u:
+; CHECK: .functype extend_to_double_low_i16x4_u (v128) -> (v128)
+; CHECK-NEXT: # %bb.0:
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_u 0
+; CHECK-NEXT: f64.convert_i32_u
+; CHECK-NEXT: f64x2.splat
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i16x8.extract_lane_u 1
+; CHECK-NEXT: f64.convert_i32_u
+; CHECK-NEXT: f64x2.replace_lane 1
+; CHECK-NEXT: # fallthrough-return
+ %low = shufflevector <4 x i16> %x, <4 x i16> undef, <2 x i32> <i32 0, i32 1>
+ %extended = uitofp <2 x i16> %low to <2 x double>
+ ret <2 x double> %extended
+}
More information about the llvm-commits
mailing list