mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-26 05:00:39 +00:00
Autoupgrade x86.sse2.loadh.pd and x86.sse2.loadl.pd.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51523 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
999dbe6bbc
commit
4797f61657
@ -148,8 +148,10 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
|||||||
VT,
|
VT,
|
||||||
(Type *)0));
|
(Type *)0));
|
||||||
return true;
|
return true;
|
||||||
} else if (Name.compare(5,16,"x86.sse2.movl.dq",16) == 0) {
|
} else if (Name.compare(5,17,"x86.sse2.loadh.pd",17) == 0 ||
|
||||||
// Calls to this intrinsic are transformed into ShuffleVector's.
|
Name.compare(5,17,"x86.sse2.loadl.pd",17) == 0 ||
|
||||||
|
Name.compare(5,16,"x86.sse2.movl.dq",16) == 0) {
|
||||||
|
// Calls to these intrinsics are transformed into ShuffleVector's.
|
||||||
NewFn = 0;
|
NewFn = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -184,23 +186,52 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
|||||||
assert(F && "CallInst has no function associated with it.");
|
assert(F && "CallInst has no function associated with it.");
|
||||||
|
|
||||||
if (!NewFn) {
|
if (!NewFn) {
|
||||||
if (strcmp(F->getNameStart(), "llvm.x86.sse2.movl.dq") == 0) {
|
bool isLoadH = false, isLoadL = false, isMovL = false;
|
||||||
std::vector<Constant*> Idxs;
|
if (strcmp(F->getNameStart(), "llvm.x86.sse2.loadh.pd") == 0)
|
||||||
Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
|
isLoadH = true;
|
||||||
Idxs.push_back(Zero);
|
else if (strcmp(F->getNameStart(), "llvm.x86.sse2.loadl.pd") == 0)
|
||||||
Idxs.push_back(Zero);
|
isLoadL = true;
|
||||||
Idxs.push_back(Zero);
|
else if (strcmp(F->getNameStart(), "llvm.x86.sse2.movl.dq") == 0)
|
||||||
Idxs.push_back(Zero);
|
isMovL = true;
|
||||||
Value *ZeroV = ConstantVector::get(Idxs);
|
|
||||||
|
|
||||||
Idxs.clear();
|
if (isLoadH || isLoadL || isMovL) {
|
||||||
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 4));
|
std::vector<Constant*> Idxs;
|
||||||
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 5));
|
Value *Op0 = CI->getOperand(1);
|
||||||
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
|
ShuffleVectorInst *SI;
|
||||||
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3));
|
if (isLoadH || isLoadL) {
|
||||||
Value *Mask = ConstantVector::get(Idxs);
|
Value *Op1 = UndefValue::get(Op0->getType());
|
||||||
ShuffleVectorInst *SI = new ShuffleVectorInst(ZeroV, CI->getOperand(1),
|
Value *Addr = new BitCastInst(CI->getOperand(2),
|
||||||
Mask, "upgraded", CI);
|
PointerType::getUnqual(Type::DoubleTy),
|
||||||
|
"upgraded.", CI);
|
||||||
|
Value *Load = new LoadInst(Addr, "upgraded.", false, 8, CI);
|
||||||
|
Value *Idx = ConstantInt::get(Type::Int32Ty, 0);
|
||||||
|
Op1 = InsertElementInst::Create(Op1, Load, Idx, "upgraded.", CI);
|
||||||
|
|
||||||
|
if (isLoadH) {
|
||||||
|
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 0));
|
||||||
|
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
|
||||||
|
} else {
|
||||||
|
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
|
||||||
|
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1));
|
||||||
|
}
|
||||||
|
Value *Mask = ConstantVector::get(Idxs);
|
||||||
|
SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);
|
||||||
|
} else {
|
||||||
|
Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
|
||||||
|
Idxs.push_back(Zero);
|
||||||
|
Idxs.push_back(Zero);
|
||||||
|
Idxs.push_back(Zero);
|
||||||
|
Idxs.push_back(Zero);
|
||||||
|
Value *ZeroV = ConstantVector::get(Idxs);
|
||||||
|
|
||||||
|
Idxs.clear();
|
||||||
|
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 4));
|
||||||
|
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 5));
|
||||||
|
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
|
||||||
|
Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3));
|
||||||
|
Value *Mask = ConstantVector::get(Idxs);
|
||||||
|
SI = new ShuffleVectorInst(ZeroV, Op0, Mask, "upgraded.", CI);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle any uses of the old CallInst.
|
// Handle any uses of the old CallInst.
|
||||||
if (!CI->use_empty())
|
if (!CI->use_empty())
|
||||||
@ -233,7 +264,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
|||||||
// Cast the second parameter to the correct type.
|
// Cast the second parameter to the correct type.
|
||||||
BitCastInst *BC = new BitCastInst(CI->getOperand(2),
|
BitCastInst *BC = new BitCastInst(CI->getOperand(2),
|
||||||
NewFn->getFunctionType()->getParamType(1),
|
NewFn->getFunctionType()->getParamType(1),
|
||||||
"upgraded", CI);
|
"upgraded.", CI);
|
||||||
Operands[1] = BC;
|
Operands[1] = BC;
|
||||||
|
|
||||||
// Construct a new CallInst
|
// Construct a new CallInst
|
||||||
|
2
test/Bitcode/sse2_loadl_pd.ll
Normal file
2
test/Bitcode/sse2_loadl_pd.ll
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
; RUN: llvm-dis < %s.bc | not grep {i32 @llvm\\.loadl.pd}
|
||||||
|
; RUN: llvm-dis < %s.bc | grep shufflevector
|
BIN
test/Bitcode/sse2_loadl_pd.ll.bc
Normal file
BIN
test/Bitcode/sse2_loadl_pd.ll.bc
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user