From a31593901de573813d1d8e7884a152011641a713 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Sat, 24 May 2008 02:56:30 +0000 Subject: [PATCH] Eliminate x86.sse2.punpckh.qdq and x86.sse2.punpckl.qdq. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51533 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IntrinsicsX86.td | 11 ----------- lib/Target/X86/X86InstrSSE.td | 10 ---------- lib/VMCore/AutoUpgrade.cpp | 16 ++++++++++++---- test/Bitcode/sse2_punpck_qdq.ll | 3 +++ test/Bitcode/sse2_punpck_qdq.ll.bc | Bin 0 -> 576 bytes 5 files changed, 15 insertions(+), 25 deletions(-) create mode 100644 test/Bitcode/sse2_punpck_qdq.ll create mode 100644 test/Bitcode/sse2_punpck_qdq.ll.bc diff --git a/include/llvm/IntrinsicsX86.td b/include/llvm/IntrinsicsX86.td index 47c8e197170..372f7211df6 100644 --- a/include/llvm/IntrinsicsX86.td +++ b/include/llvm/IntrinsicsX86.td @@ -501,17 +501,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_void_ty], [IntrWriteMem]>; } -// Shuffles. -// FIXME: Temporary workarounds since 2-wide shuffle is broken. -let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". - def int_x86_sse2_punpckh_qdq : GCCBuiltin<"__builtin_ia32_punpckhqdq128">, - Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, - llvm_v2i64_ty], [IntrNoMem]>; - def int_x86_sse2_punpckl_qdq : GCCBuiltin<"__builtin_ia32_punpcklqdq128">, - Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, - llvm_v2i64_ty], [IntrNoMem]>; -} - //===----------------------------------------------------------------------===// // SSE3 diff --git a/lib/Target/X86/X86InstrSSE.td b/lib/Target/X86/X86InstrSSE.td index 8e6d9df3827..e995807f312 100644 --- a/lib/Target/X86/X86InstrSSE.td +++ b/lib/Target/X86/X86InstrSSE.td @@ -3050,16 +3050,6 @@ def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc, VR128:$src, def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))), (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>; -// FIXME: Temporary workaround since 2-wide shuffle is broken. -def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2), - (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>; -def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (memop addr:$src2)), - (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>; -def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2), - (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>; -def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (memop addr:$src2)), - (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; - // Some special case pandn patterns. def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))), VR128:$src2)), diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp index 0d6ae43d0f0..2f1e07c2112 100644 --- a/lib/VMCore/AutoUpgrade.cpp +++ b/lib/VMCore/AutoUpgrade.cpp @@ -154,7 +154,9 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { Name.compare(5,15,"x86.sse2.movs.d",15) == 0 || Name.compare(5,16,"x86.sse2.shuf.pd",16) == 0 || Name.compare(5,18,"x86.sse2.unpckh.pd",18) == 0 || - Name.compare(5,18,"x86.sse2.unpckl.pd",18) == 0 ) { + Name.compare(5,18,"x86.sse2.unpckl.pd",18) == 0 || + Name.compare(5,20,"x86.sse2.punpckh.qdq",20) == 0 || + Name.compare(5,20,"x86.sse2.punpckl.qdq",20) == 0) { // Calls to these intrinsics are transformed into ShuffleVector's. NewFn = 0; return true; @@ -193,6 +195,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { bool isLoadH = false, isLoadL = false, isMovL = false; bool isMovSD = false, isShufPD = false; bool isUnpckhPD = false, isUnpcklPD = false; + bool isPunpckhQPD = false, isPunpcklQPD = false; if (strcmp(F->getNameStart(), "llvm.x86.sse2.loadh.pd") == 0) isLoadH = true; else if (strcmp(F->getNameStart(), "llvm.x86.sse2.loadl.pd") == 0) @@ -207,9 +210,13 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { isUnpckhPD = true; else if (strcmp(F->getNameStart(), "llvm.x86.sse2.unpckl.pd") == 0) isUnpcklPD = true; + else if (strcmp(F->getNameStart(), "llvm.x86.sse2.punpckh.qdq") == 0) + isPunpckhQPD = true; + else if (strcmp(F->getNameStart(), "llvm.x86.sse2.punpckl.qdq") == 0) + isPunpcklQPD = true; if (isLoadH || isLoadL || isMovL || isMovSD || isShufPD || - isUnpckhPD || isUnpcklPD) { + isUnpckhPD || isUnpcklPD || isPunpckhQPD || isPunpcklQPD) { std::vector Idxs; Value *Op0 = CI->getOperand(1); ShuffleVectorInst *SI = NULL; @@ -246,12 +253,13 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3)); Value *Mask = ConstantVector::get(Idxs); SI = new ShuffleVectorInst(ZeroV, Op0, Mask, "upgraded.", CI); - } else if (isMovSD || isUnpckhPD || isUnpcklPD) { + } else if (isMovSD || + isUnpckhPD || isUnpcklPD || isPunpckhQPD || isPunpcklQPD) { Value *Op1 = CI->getOperand(2); if (isMovSD) { Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2)); Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1)); - } else if (isUnpckhPD) { + } else if (isUnpckhPD || isPunpckhQPD) { Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1)); Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3)); } else { diff --git a/test/Bitcode/sse2_punpck_qdq.ll b/test/Bitcode/sse2_punpck_qdq.ll new file mode 100644 index 00000000000..b9d711c1084 --- /dev/null +++ b/test/Bitcode/sse2_punpck_qdq.ll @@ -0,0 +1,3 @@ +; RUN: llvm-dis < %s.bc | not grep {i32 @llvm\\.punpckh.qdq} +; RUN: llvm-dis < %s.bc | not grep {i32 @llvm\\.punpckl.qdq} +; RUN: llvm-dis < %s.bc | grep shufflevector diff --git a/test/Bitcode/sse2_punpck_qdq.ll.bc b/test/Bitcode/sse2_punpck_qdq.ll.bc new file mode 100644 index 0000000000000000000000000000000000000000..7c1b7ed0ca6b7bda4c1d1726188dda0248581cab GIT binary patch literal 576 zcmZ>AK5$Qwhk>D&fq{WhfPn#s7}y(?Cpw;B@njP)vYf=&!lTN{At}ewozx)U%H%YO z+o?ssNW_9e!jsF$Ma6?_f}*lZQA3Y_VjEW%R|=0j1B0go0|PVA9Bvi{9x)CE2}U40 zPyxsX(nd-goC>K;EevWd9;}>dF2`7%oYXibB(f;ZP-b9dvRdUdgQ16E3P=ls@RE`l z%r+aE%{bUA8raJ;+RYT&3nsKzd$5fgQxS!1hvry{Z9( zawqUrEMNyAuwdB&_QC}ADgpK~AQw$b0(%L>1R&!A+cQ+zXQ;B@z}zwi_A0RAZvyN^ zKny~?&;ayVf`=0%sChiu6c|_-7#b8$GO&PT1lX7u zfYHGq%yKZIRe-0}P{L7$wcw!x8&E7vAR|p6$4$Vc%)#f(VtEHgli(I`Kmp|v6&R58 zaS*Mq5U7tAs9$Y@uJ_R&;_H7;a=G!(*|dLwj-82v8M>ehP>@Z*XDchmWRNBx007a- Bkc$8S literal 0 HcmV?d00001