[PATCH] D71628: [WebAssembly] Implement SIMD {i8x16,i16x8}.avgr_u instructions
Thomas Lively via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 17 15:06:28 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1b351e14a91: [WebAssembly] Implement SIMD {i8x16,i16x8}.avgr_u instructions (authored by tlively).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71628/new/
https://reviews.llvm.org/D71628
Files:
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-arith.ll
llvm/test/MC/WebAssembly/simd-encodings.s
Index: llvm/test/MC/WebAssembly/simd-encodings.s
===================================================================
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -571,7 +571,13 @@
# CHECK: v128.andnot # encoding: [0xfd,0xd8,0x01]
v128.andnot
- # CHECK: i32x4.dot_i16x8_s # encoding: [0xfd,0xd9,0x01]
+ # CHECK: i8x16.avgr_u # encoding: [0xfd,0xd9,0x01]
+ i8x16.avgr_u
+
+ # CHECK: i16x8.avgr_u # encoding: [0xfd,0xda,0x01]
+ i16x8.avgr_u
+
+ # CHECK: i32x4.dot_i16x8_s # encoding: [0xfd,0xdb,0x01]
i32x4.dot_i16x8_s
end_function
Index: llvm/test/CodeGen/WebAssembly/simd-arith.ll
===================================================================
--- llvm/test/CodeGen/WebAssembly/simd-arith.ll
+++ llvm/test/CodeGen/WebAssembly/simd-arith.ll
@@ -91,6 +91,20 @@
ret <16 x i8> %a
}
+; CHECK-LABEL: avgr_u_v16i8:
+; NO-SIMD128-NOT: i8x16
+; SIMD128-NEXT: .functype avgr_u_v16i8 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i8x16.avgr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+define <16 x i8> @avgr_u_v16i8(<16 x i8> %x, <16 x i8> %y) {
+ %a = add <16 x i8> %x, %y
+ %b = add <16 x i8> %a, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1,
+ i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
+ %c = udiv <16 x i8> %b, <i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2,
+ i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2>
+ ret <16 x i8> %c
+}
+
; CHECK-LABEL: neg_v16i8:
; NO-SIMD128-NOT: i8x16
; SIMD128-NEXT: .functype neg_v16i8 (v128) -> (v128){{$}}
@@ -381,6 +395,18 @@
ret <8 x i16> %a
}
+; CHECK-LABEL: avgr_u_v8i16:
+; NO-SIMD128-NOT: i16x8
+; SIMD128-NEXT: .functype avgr_u_v8i16 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i16x8.avgr_u $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+define <8 x i16> @avgr_u_v8i16(<8 x i16> %x, <8 x i16> %y) {
+ %a = add <8 x i16> %x, %y
+ %b = add <8 x i16> %a, <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
+ %c = udiv <8 x i16> %b, <i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>
+ ret <8 x i16> %c
+}
+
; CHECK-LABEL: neg_v8i16:
; NO-SIMD128-NOT: i16x8
; SIMD128-NEXT: .functype neg_v8i16 (v128) -> (v128){{$}}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -738,12 +738,31 @@
defm MAX_U : SIMDBinaryIntNoI64x2<umax, "max_u", 97>;
} // isCommutable = 1
+// Integer unsigned rounding average: avgr_u
+def avgr_u_v16i8 :
+ PatFrag<(ops node:$lhs, node:$rhs),
+ (srl
+ (add (add node:$lhs, node:$rhs), (splat16 (i32 1))),
+ (v16i8 (splat16 (i32 1)))
+ )>;
+def avgr_u_v8i16 :
+ PatFrag<(ops node:$lhs, node:$rhs),
+ (srl
+ (add (add node:$lhs, node:$rhs), (splat8 (i32 1))),
+ (v8i16 (splat8 (i32 1)))
+ )>;
+
+let isCommutable = 1, Predicates = [HasUnimplementedSIMD128] in {
+defm AVGR_U : SIMDBinary<v16i8, "i8x16", avgr_u_v16i8, "avgr_u", 217>;
+defm AVGR_U : SIMDBinary<v8i16, "i16x8", avgr_u_v8i16, "avgr_u", 218>;
+}
+
// Widening dot product: i32x4.dot_i16x8_s
let isCommutable = 1 in
defm DOT : SIMD_I<(outs V128:$dst), (ins V128:$lhs, V128:$rhs), (outs), (ins),
[(set V128:$dst, (int_wasm_dot V128:$lhs, V128:$rhs))],
"i32x4.dot_i16x8_s\t$dst, $lhs, $rhs", "i32x4.dot_i16x8_s",
- 217>;
+ 219>;
//===----------------------------------------------------------------------===//
// Floating-point unary arithmetic
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71628.234400.patch
Type: text/x-patch
Size: 3763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191217/592cb271/attachment.bin>
More information about the llvm-commits
mailing list