[llvm] r292019 - [X86][XOP] Added support for VPMACSWW/VPMACSDD 'lossy' IFMA patterns
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 14 09:13:52 PST 2017
Author: rksimon
Date: Sat Jan 14 11:13:52 2017
New Revision: 292019
URL: http://llvm.org/viewvc/llvm-project?rev=292019&view=rev
Log:
[X86][XOP] Added support for VPMACSWW/VPMACSDD 'lossy' IFMA patterns
VPMACSWW/VPMACSDD act as add( mul( x, y ), z ) - ignoring any upper bits from both the multiply and add stages
Modified:
llvm/trunk/lib/Target/X86/X86InstrXOP.td
llvm/trunk/test/CodeGen/X86/xop-ifma.ll
Modified: llvm/trunk/lib/Target/X86/X86InstrXOP.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrXOP.td?rev=292019&r1=292018&r2=292019&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrXOP.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrXOP.td Sat Jan 14 11:13:52 2017
@@ -183,6 +183,17 @@ let ExeDomain = SSEPackedInt in {
defm VPMACSDD : xop4opm2<0x9E, "vpmacsdd", int_x86_xop_vpmacsdd>;
}
+// IFMA patterns - for cases where we can safely ignore the overflow bits from
+// the multiply.
+let Predicates = [HasXOP] in {
+ def : Pat<(v8i16 (add (mul (v8i16 VR128:$src1), (v8i16 VR128:$src2)),
+ (v8i16 VR128:$src3))),
+ (VPMACSWWrr VR128:$src1, VR128:$src2, VR128:$src3)>;
+ def : Pat<(v4i32 (add (mul (v4i32 VR128:$src1), (v4i32 VR128:$src2)),
+ (v4i32 VR128:$src3))),
+ (VPMACSDDrr VR128:$src1, VR128:$src2, VR128:$src3)>;
+}
+
// Instruction where second source can be memory, third must be imm8
multiclass xopvpcom<bits<8> opc, string Suffix, SDNode OpNode, ValueType vt128> {
let isCommutable = 1 in
Modified: llvm/trunk/test/CodeGen/X86/xop-ifma.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/xop-ifma.ll?rev=292019&r1=292018&r2=292019&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/xop-ifma.ll (original)
+++ llvm/trunk/test/CodeGen/X86/xop-ifma.ll Sat Jan 14 11:13:52 2017
@@ -5,8 +5,7 @@
define <8 x i16> @test_mul_v8i16_add_v8i16(<8 x i16> %a0, <8 x i16> %a1, <8 x i16> %a2) {
; XOP-LABEL: test_mul_v8i16_add_v8i16:
; XOP: # BB#0:
-; XOP-NEXT: vpmullw %xmm1, %xmm0, %xmm0
-; XOP-NEXT: vpaddw %xmm2, %xmm0, %xmm0
+; XOP-NEXT: vpmacsww %xmm2, %xmm1, %xmm0, %xmm0
; XOP-NEXT: retq
%1 = mul <8 x i16> %a0, %a1
%2 = add <8 x i16> %1, %a2
@@ -16,14 +15,12 @@ define <8 x i16> @test_mul_v8i16_add_v8i
define <16 x i16> @test_mul_v16i16_add_v16i16(<16 x i16> %a0, <16 x i16> %a1, <16 x i16> %a2) {
; XOP-AVX1-LABEL: test_mul_v16i16_add_v16i16:
; XOP-AVX1: # BB#0:
-; XOP-AVX1-NEXT: vpmullw %xmm1, %xmm0, %xmm3
-; XOP-AVX1-NEXT: vextractf128 $1, %ymm1, %xmm1
-; XOP-AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
-; XOP-AVX1-NEXT: vpmullw %xmm1, %xmm0, %xmm0
-; XOP-AVX1-NEXT: vextractf128 $1, %ymm2, %xmm1
-; XOP-AVX1-NEXT: vpaddw %xmm0, %xmm1, %xmm0
-; XOP-AVX1-NEXT: vpaddw %xmm3, %xmm2, %xmm1
-; XOP-AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm1, %ymm0
+; XOP-AVX1-NEXT: vextractf128 $1, %ymm1, %xmm3
+; XOP-AVX1-NEXT: vextractf128 $1, %ymm0, %xmm4
+; XOP-AVX1-NEXT: vextractf128 $1, %ymm2, %xmm5
+; XOP-AVX1-NEXT: vpmacsww %xmm5, %xmm3, %xmm4, %xmm3
+; XOP-AVX1-NEXT: vpmacsww %xmm2, %xmm1, %xmm0, %xmm0
+; XOP-AVX1-NEXT: vinsertf128 $1, %xmm3, %ymm0, %ymm0
; XOP-AVX1-NEXT: retq
;
; XOP-AVX2-LABEL: test_mul_v16i16_add_v16i16:
@@ -39,8 +36,7 @@ define <16 x i16> @test_mul_v16i16_add_v
define <4 x i32> @test_mul_v4i32_add_v4i32(<4 x i32> %a0, <4 x i32> %a1, <4 x i32> %a2) {
; XOP-LABEL: test_mul_v4i32_add_v4i32:
; XOP: # BB#0:
-; XOP-NEXT: vpmulld %xmm1, %xmm0, %xmm0
-; XOP-NEXT: vpaddd %xmm2, %xmm0, %xmm0
+; XOP-NEXT: vpmacsdd %xmm2, %xmm1, %xmm0, %xmm0
; XOP-NEXT: retq
%1 = mul <4 x i32> %a0, %a1
%2 = add <4 x i32> %1, %a2
@@ -50,14 +46,12 @@ define <4 x i32> @test_mul_v4i32_add_v4i
define <8 x i32> @test_mul_v8i32_add_v8i32(<8 x i32> %a0, <8 x i32> %a1, <8 x i32> %a2) {
; XOP-AVX1-LABEL: test_mul_v8i32_add_v8i32:
; XOP-AVX1: # BB#0:
-; XOP-AVX1-NEXT: vpmulld %xmm1, %xmm0, %xmm3
-; XOP-AVX1-NEXT: vextractf128 $1, %ymm1, %xmm1
-; XOP-AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
-; XOP-AVX1-NEXT: vpmulld %xmm1, %xmm0, %xmm0
-; XOP-AVX1-NEXT: vextractf128 $1, %ymm2, %xmm1
-; XOP-AVX1-NEXT: vpaddd %xmm0, %xmm1, %xmm0
-; XOP-AVX1-NEXT: vpaddd %xmm3, %xmm2, %xmm1
-; XOP-AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm1, %ymm0
+; XOP-AVX1-NEXT: vextractf128 $1, %ymm1, %xmm3
+; XOP-AVX1-NEXT: vextractf128 $1, %ymm0, %xmm4
+; XOP-AVX1-NEXT: vextractf128 $1, %ymm2, %xmm5
+; XOP-AVX1-NEXT: vpmacsdd %xmm5, %xmm3, %xmm4, %xmm3
+; XOP-AVX1-NEXT: vpmacsdd %xmm2, %xmm1, %xmm0, %xmm0
+; XOP-AVX1-NEXT: vinsertf128 $1, %xmm3, %ymm0, %ymm0
; XOP-AVX1-NEXT: retq
;
; XOP-AVX2-LABEL: test_mul_v8i32_add_v8i32:
More information about the llvm-commits
mailing list