From ff0942e6ea3111792bc2fbf3d2bbdc7c74937ce5 Mon Sep 17 00:00:00 2001 From: Ehsan Amiri Date: Fri, 18 Nov 2016 11:05:55 +0000 Subject: [PATCH] [Power9] Add patterns for vnegd, vnegw Exploit new instructions by adding patterns to .td file. https://reviews.llvm.org/D26551 llvm-svn: 287334 --- llvm/lib/Target/PowerPC/PPCInstrAltivec.td | 9 +++++++-- llvm/test/CodeGen/PowerPC/vsx-p9.ll | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/PowerPC/PPCInstrAltivec.td b/llvm/lib/Target/PowerPC/PPCInstrAltivec.td index f9a500bea173..a2787f88329b 100644 --- a/llvm/lib/Target/PowerPC/PPCInstrAltivec.td +++ b/llvm/lib/Target/PowerPC/PPCInstrAltivec.td @@ -1315,8 +1315,13 @@ let isCodeGenOnly = 1 in { } // Vector Integer Negate -def VNEGW : VX_VT5_EO5_VB5<1538, 6, "vnegw", []>; -def VNEGD : VX_VT5_EO5_VB5<1538, 7, "vnegd", []>; +def VNEGW : VX_VT5_EO5_VB5<1538, 6, "vnegw", + [(set v4i32:$vD, + (sub (v4i32 immAllZerosV), v4i32:$vB))]>; + +def VNEGD : VX_VT5_EO5_VB5<1538, 7, "vnegd", + [(set v2i64:$vD, + (sub (v2i64 (bitconvert (v4i32 immAllZerosV))), v2i64:$vB))]>; // Vector Parity Byte def VPRTYBW : VX_VT5_EO5_VB5<1538, 8, "vprtybw", [(set v4i32:$vD, diff --git a/llvm/test/CodeGen/PowerPC/vsx-p9.ll b/llvm/test/CodeGen/PowerPC/vsx-p9.ll index b0c6e8513535..e8a0a3bcf92a 100644 --- a/llvm/test/CodeGen/PowerPC/vsx-p9.ll +++ b/llvm/test/CodeGen/PowerPC/vsx-p9.ll @@ -388,4 +388,26 @@ entry: ; Function Attrs: nounwind readnone declare void @llvm.ppc.vsx.stxvll(<4 x i32>, i8*, i64) +define <4 x i32> @test0(<4 x i32> %a) local_unnamed_addr #0 { +entry: + %sub.i = sub <4 x i32> zeroinitializer, %a + ret <4 x i32> %sub.i + +; CHECK-LABEL: @test0 +; CHECK: vnegw 2, 2 +; CHECK: blr + +} + +define <2 x i64> @test1(<2 x i64> %a) local_unnamed_addr #0 { +entry: + %sub.i = sub <2 x i64> zeroinitializer, %a + ret <2 x i64> %sub.i + +; CHECK-LABEL: @test1 +; CHECK: vnegd 2, 2 +; CHECK: blr + +} + declare void @sink(...)