[llvm-commits] [llvm] r51531 - in /llvm/trunk: include/llvm/IntrinsicsX86.td lib/Target/X86/X86InstrSSE.td lib/VMCore/AutoUpgrade.cpp test/Bitcode/sse2_movs_d.ll test/Bitcode/sse2_movs_d.ll.bc test/Bitcode/sse2_shuf_pd.ll test/Bitcode/sse2_shuf_pd.ll.bc test/Bitcode/sse2_unpck_pd.ll test/Bitcode/sse2_unpck_pd.ll.bc
Evan Cheng
evan.cheng at apple.com
Fri May 23 19:14:05 PDT 2008
Author: evancheng
Date: Fri May 23 21:14:05 2008
New Revision: 51531
URL: http://llvm.org/viewvc/llvm-project?rev=51531&view=rev
Log:
Eliminate x86.sse2.movs.d, x86.sse2.shuf.pd, x86.sse2.unpckh.pd, and x86.sse2.unpckl.pd intrinsics. These will be lowered into shuffles.
Added:
llvm/trunk/test/Bitcode/sse2_movs_d.ll
llvm/trunk/test/Bitcode/sse2_movs_d.ll.bc (with props)
llvm/trunk/test/Bitcode/sse2_shuf_pd.ll
llvm/trunk/test/Bitcode/sse2_shuf_pd.ll.bc (with props)
llvm/trunk/test/Bitcode/sse2_unpck_pd.ll
llvm/trunk/test/Bitcode/sse2_unpck_pd.ll.bc (with props)
Modified:
llvm/trunk/include/llvm/IntrinsicsX86.td
llvm/trunk/lib/Target/X86/X86InstrSSE.td
llvm/trunk/lib/VMCore/AutoUpgrade.cpp
Modified: llvm/trunk/include/llvm/IntrinsicsX86.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=51531&r1=51530&r2=51531&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IntrinsicsX86.td (original)
+++ llvm/trunk/include/llvm/IntrinsicsX86.td Fri May 23 21:14:05 2008
@@ -504,18 +504,6 @@
// Shuffles.
// FIXME: Temporary workarounds since 2-wide shuffle is broken.
let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
- def int_x86_sse2_movs_d : GCCBuiltin<"__builtin_ia32_movsd">,
- Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
- llvm_v2f64_ty], [IntrNoMem]>;
- def int_x86_sse2_shuf_pd : GCCBuiltin<"__builtin_ia32_shufpd">,
- Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
- llvm_v2f64_ty, llvm_i32_ty], [IntrNoMem]>;
- def int_x86_sse2_unpckh_pd : GCCBuiltin<"__builtin_ia32_unpckhpd">,
- Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
- llvm_v2f64_ty], [IntrNoMem]>;
- def int_x86_sse2_unpckl_pd : GCCBuiltin<"__builtin_ia32_unpcklpd">,
- Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
- llvm_v2f64_ty], [IntrNoMem]>;
def int_x86_sse2_punpckh_qdq : GCCBuiltin<"__builtin_ia32_punpckhqdq128">,
Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty,
llvm_v2i64_ty], [IntrNoMem]>;
Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=51531&r1=51530&r2=51531&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Fri May 23 21:14:05 2008
@@ -3051,22 +3051,6 @@
(MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
// FIXME: Temporary workaround since 2-wide shuffle is broken.
-def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
- (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
-def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
- (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
- Requires<[HasSSE2]>;
-def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (memop addr:$src2),imm:$src3),
- (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
- Requires<[HasSSE2]>;
-def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
- (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
-def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (memop addr:$src2)),
- (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
-def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
- (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
-def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (memop addr:$src2)),
- (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
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)),
Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=51531&r1=51530&r2=51531&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original)
+++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Fri May 23 21:14:05 2008
@@ -150,7 +150,11 @@
return true;
} else if (Name.compare(5,17,"x86.sse2.loadh.pd",17) == 0 ||
Name.compare(5,17,"x86.sse2.loadl.pd",17) == 0 ||
- Name.compare(5,16,"x86.sse2.movl.dq",16) == 0) {
+ Name.compare(5,16,"x86.sse2.movl.dq",16) == 0 ||
+ 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 ) {
// Calls to these intrinsics are transformed into ShuffleVector's.
NewFn = 0;
return true;
@@ -187,17 +191,28 @@
if (!NewFn) {
bool isLoadH = false, isLoadL = false, isMovL = false;
+ bool isMovSD = false, isShufPD = false;
+ bool isUnpckhPD = false, isUnpcklPD = false;
if (strcmp(F->getNameStart(), "llvm.x86.sse2.loadh.pd") == 0)
isLoadH = true;
else if (strcmp(F->getNameStart(), "llvm.x86.sse2.loadl.pd") == 0)
isLoadL = true;
else if (strcmp(F->getNameStart(), "llvm.x86.sse2.movl.dq") == 0)
isMovL = true;
+ else if (strcmp(F->getNameStart(), "llvm.x86.sse2.movs.d") == 0)
+ isMovSD = true;
+ else if (strcmp(F->getNameStart(), "llvm.x86.sse2.shuf.pd") == 0)
+ isShufPD = true;
+ else if (strcmp(F->getNameStart(), "llvm.x86.sse2.unpckh.pd") == 0)
+ isUnpckhPD = true;
+ else if (strcmp(F->getNameStart(), "llvm.x86.sse2.unpckl.pd") == 0)
+ isUnpcklPD = true;
- if (isLoadH || isLoadL || isMovL) {
+ if (isLoadH || isLoadL || isMovL || isMovSD || isShufPD ||
+ isUnpckhPD || isUnpcklPD) {
std::vector<Constant*> Idxs;
Value *Op0 = CI->getOperand(1);
- ShuffleVectorInst *SI;
+ ShuffleVectorInst *SI = NULL;
if (isLoadH || isLoadL) {
Value *Op1 = UndefValue::get(Op0->getType());
Value *Addr = new BitCastInst(CI->getOperand(2),
@@ -216,7 +231,7 @@
}
Value *Mask = ConstantVector::get(Idxs);
SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);
- } else {
+ } else if (isMovL) {
Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
Idxs.push_back(Zero);
Idxs.push_back(Zero);
@@ -231,8 +246,31 @@
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) {
+ 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) {
+ Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1));
+ Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3));
+ } else {
+ Idxs.push_back(ConstantInt::get(Type::Int32Ty, 0));
+ Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
+ }
+ Value *Mask = ConstantVector::get(Idxs);
+ SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);
+ } else if (isShufPD) {
+ Value *Op1 = CI->getOperand(2);
+ unsigned MaskVal = cast<ConstantInt>(CI->getOperand(3))->getZExtValue();
+ Idxs.push_back(ConstantInt::get(Type::Int32Ty, MaskVal & 1));
+ Idxs.push_back(ConstantInt::get(Type::Int32Ty, ((MaskVal >> 1) & 1)+2));
+ Value *Mask = ConstantVector::get(Idxs);
+ SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);
}
+ assert(SI && "Unexpected!");
+
// Handle any uses of the old CallInst.
if (!CI->use_empty())
// Replace all uses of the old call with the new cast which has the
Added: llvm/trunk/test/Bitcode/sse2_movs_d.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/sse2_movs_d.ll?rev=51531&view=auto
==============================================================================
--- llvm/trunk/test/Bitcode/sse2_movs_d.ll (added)
+++ llvm/trunk/test/Bitcode/sse2_movs_d.ll Fri May 23 21:14:05 2008
@@ -0,0 +1,2 @@
+; RUN: llvm-dis < %s.bc | not grep {i32 @llvm\\.movs.d}
+; RUN: llvm-dis < %s.bc | grep shufflevector
Added: llvm/trunk/test/Bitcode/sse2_movs_d.ll.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/sse2_movs_d.ll.bc?rev=51531&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/Bitcode/sse2_movs_d.ll.bc
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: llvm/trunk/test/Bitcode/sse2_shuf_pd.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/sse2_shuf_pd.ll?rev=51531&view=auto
==============================================================================
--- llvm/trunk/test/Bitcode/sse2_shuf_pd.ll (added)
+++ llvm/trunk/test/Bitcode/sse2_shuf_pd.ll Fri May 23 21:14:05 2008
@@ -0,0 +1,2 @@
+; RUN: llvm-dis < %s.bc | not grep {i32 @llvm\\.shuf.pd}
+; RUN: llvm-dis < %s.bc | grep shufflevector
Added: llvm/trunk/test/Bitcode/sse2_shuf_pd.ll.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/sse2_shuf_pd.ll.bc?rev=51531&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/Bitcode/sse2_shuf_pd.ll.bc
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: llvm/trunk/test/Bitcode/sse2_unpck_pd.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/sse2_unpck_pd.ll?rev=51531&view=auto
==============================================================================
--- llvm/trunk/test/Bitcode/sse2_unpck_pd.ll (added)
+++ llvm/trunk/test/Bitcode/sse2_unpck_pd.ll Fri May 23 21:14:05 2008
@@ -0,0 +1,3 @@
+; RUN: llvm-dis < %s.bc | not grep {i32 @llvm\\.unpckh.pd}
+; RUN: llvm-dis < %s.bc | not grep {i32 @llvm\\.unpckl.pd}
+; RUN: llvm-dis < %s.bc | grep shufflevector
Added: llvm/trunk/test/Bitcode/sse2_unpck_pd.ll.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/sse2_unpck_pd.ll.bc?rev=51531&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/Bitcode/sse2_unpck_pd.ll.bc
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
More information about the llvm-commits
mailing list