[llvm] r342513 - [WebAssembly] v4f32.abs and v2f64.abs
Thomas Lively via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 18 14:45:12 PDT 2018
Author: tlively
Date: Tue Sep 18 14:45:12 2018
New Revision: 342513
URL: http://llvm.org/viewvc/llvm-project?rev=342513&view=rev
Log:
[WebAssembly] v4f32.abs and v2f64.abs
Summary: implement lowering of @llvm.fabs for vector types.
Reviewers: aheejin, dschuff
Subscribers:
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/trunk/test/CodeGen/WebAssembly/simd-arith.ll
llvm/trunk/test/MC/WebAssembly/simd-encodings.s
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td?rev=342513&r1=342512&r2=342513&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td Tue Sep 18 14:45:12 2018
@@ -207,6 +207,11 @@ multiclass SIMDConditionFP<string name,
defm "" : SIMDCondition<v2f64, v2i64, "f64x2", name, cond,
!add(baseInst, 1)>;
}
+multiclass SIMDAbs<ValueType vec_t, string vec, bits<32> simdop> {
+ defm ABS_#vec_t : SIMD_I<(outs V128:$dst), (ins V128:$vec), (outs), (ins),
+ [(set (vec_t V128:$dst), (vec_t (fabs V128:$vec)))],
+ vec#".abs\t$dst, $vec", vec#".abs", simdop>;
+}
let Defs = [ARGUMENTS] in {
defm "" : ConstVec<v16i8,
@@ -363,6 +368,9 @@ defm GE_S : SIMDConditionInt<"ge_s", SET
defm GE_U : SIMDConditionInt<"ge_u", SETUGE, 107, 2>;
defm GE : SIMDConditionFP<"ge", SETOGE, 112>;
+defm "" : SIMDAbs<v4f32, "f32x4", 116>;
+defm "" : SIMDAbs<v2f64, "f64x2", 117>;
+
} // Defs = [ARGUMENTS]
// Def load and store patterns from WebAssemblyInstrMemory.td for vector types
Modified: llvm/trunk/test/CodeGen/WebAssembly/simd-arith.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/simd-arith.ll?rev=342513&r1=342512&r2=342513&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/simd-arith.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/simd-arith.ll Tue Sep 18 14:45:12 2018
@@ -667,6 +667,18 @@ define <4 x float> @neg_v4f32(<4 x float
ret <4 x float> %a
}
+; CHECK-LABEL: abs_v4f32:
+; NO-SIMD128-NOT: f32x4
+; SIMD128-NEXT: .param v128{{$}}
+; SIMD128-NEXT: .result v128{{$}}
+; SIMD128-NEXT: f32x4.abs $push0=, $0{{$}}
+; SIMD128-NEXT: return $pop0{{$}}
+declare <4 x float> @llvm.fabs.v4f32(<4 x float>) nounwind readnone
+define <4 x float> @abs_v4f32(<4 x float> %x) {
+ %a = call <4 x float> @llvm.fabs.v4f32(<4 x float> %x)
+ ret <4 x float> %a
+}
+
; CHECK-LABEL: add_v4f32:
; NO-SIMD128-NOT: f32x4
; SIMD128-NEXT: .param v128, v128{{$}}
@@ -725,6 +737,19 @@ define <2 x double> @neg_v2f64(<2 x doub
ret <2 x double> %a
}
+; CHECK-LABEL: abs_v2f64:
+; NO-SIMD128-NOT: f64x2
+; SIMD128-NEXT: .param v128{{$}}
+; SIMD128-NEXT: .result v128{{$}}
+; SIMD128-NEXT: f64x2.abs $push0=, $0{{$}}
+; SIMD128-NEXT: return $pop0{{$}}
+declare <2 x double> @llvm.fabs.v2f64(<2 x double>) nounwind readnone
+define <2 x double> @abs_v2f64(<2 x double> %x) {
+ %a = call <2 x double> @llvm.fabs.v2f64(<2 x double> %x)
+ ret <2 x double> %a
+}
+
+
; CHECK-LABEL: add_v2f64:
; NO-SIMD128-NOT: f64x2
; SIMD128-VM-NOT: f62x2
Modified: llvm/trunk/test/MC/WebAssembly/simd-encodings.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/simd-encodings.s?rev=342513&r1=342512&r2=342513&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/simd-encodings.s (original)
+++ llvm/trunk/test/MC/WebAssembly/simd-encodings.s Tue Sep 18 14:45:12 2018
@@ -325,6 +325,12 @@
# CHECK: f64x2.neg # encoding: [0xfd,0x73]
f64x2.neg
+ # CHECK: f32x4.abs # encoding: [0xfd,0x74]
+ f32x4.abs
+
+ # CHECK: f64x2.abs # encoding: [0xfd,0x75]
+ f64x2.abs
+
# CHECK: f32x4.add # encoding: [0xfd,0x7a]
f32x4.add
More information about the llvm-commits
mailing list