forked from OSchip/llvm-project
[X86][IR] Move the autoupgrading of store intrinsics out of the main nested if/else chain. This should buy a little more time against the MSVC limit mentioned in PR31034.
The handlers for stores all return at the end of their block so they can be picked off early. llvm-svn: 289339
This commit is contained in:
parent
5391c98341
commit
a4744d170e
|
@ -745,6 +745,108 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
|||
if (IsX86)
|
||||
Name = Name.substr(4);
|
||||
|
||||
if (IsX86 && Name.startswith("sse4a.movnt.")) {
|
||||
Module *M = F->getParent();
|
||||
SmallVector<Metadata *, 1> Elts;
|
||||
Elts.push_back(
|
||||
ConstantAsMetadata::get(ConstantInt::get(Type::getInt32Ty(C), 1)));
|
||||
MDNode *Node = MDNode::get(C, Elts);
|
||||
|
||||
Value *Arg0 = CI->getArgOperand(0);
|
||||
Value *Arg1 = CI->getArgOperand(1);
|
||||
|
||||
// Nontemporal (unaligned) store of the 0'th element of the float/double
|
||||
// vector.
|
||||
Type *SrcEltTy = cast<VectorType>(Arg1->getType())->getElementType();
|
||||
PointerType *EltPtrTy = PointerType::getUnqual(SrcEltTy);
|
||||
Value *Addr = Builder.CreateBitCast(Arg0, EltPtrTy, "cast");
|
||||
Value *Extract =
|
||||
Builder.CreateExtractElement(Arg1, (uint64_t)0, "extractelement");
|
||||
|
||||
StoreInst *SI = Builder.CreateAlignedStore(Extract, Addr, 1);
|
||||
SI->setMetadata(M->getMDKindID("nontemporal"), Node);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsX86 && (Name.startswith("avx.movnt.") ||
|
||||
Name.startswith("avx512.storent."))) {
|
||||
Module *M = F->getParent();
|
||||
SmallVector<Metadata *, 1> Elts;
|
||||
Elts.push_back(
|
||||
ConstantAsMetadata::get(ConstantInt::get(Type::getInt32Ty(C), 1)));
|
||||
MDNode *Node = MDNode::get(C, Elts);
|
||||
|
||||
Value *Arg0 = CI->getArgOperand(0);
|
||||
Value *Arg1 = CI->getArgOperand(1);
|
||||
|
||||
// Convert the type of the pointer to a pointer to the stored type.
|
||||
Value *BC = Builder.CreateBitCast(Arg0,
|
||||
PointerType::getUnqual(Arg1->getType()),
|
||||
"cast");
|
||||
VectorType *VTy = cast<VectorType>(Arg1->getType());
|
||||
StoreInst *SI = Builder.CreateAlignedStore(Arg1, BC,
|
||||
VTy->getBitWidth() / 8);
|
||||
SI->setMetadata(M->getMDKindID("nontemporal"), Node);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsX86 && Name == "sse2.storel.dq") {
|
||||
Value *Arg0 = CI->getArgOperand(0);
|
||||
Value *Arg1 = CI->getArgOperand(1);
|
||||
|
||||
Type *NewVecTy = VectorType::get(Type::getInt64Ty(C), 2);
|
||||
Value *BC0 = Builder.CreateBitCast(Arg1, NewVecTy, "cast");
|
||||
Value *Elt = Builder.CreateExtractElement(BC0, (uint64_t)0);
|
||||
Value *BC = Builder.CreateBitCast(Arg0,
|
||||
PointerType::getUnqual(Elt->getType()),
|
||||
"cast");
|
||||
Builder.CreateAlignedStore(Elt, BC, 1);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsX86 && (Name.startswith("sse.storeu.") ||
|
||||
Name.startswith("sse2.storeu.") ||
|
||||
Name.startswith("avx.storeu."))) {
|
||||
Value *Arg0 = CI->getArgOperand(0);
|
||||
Value *Arg1 = CI->getArgOperand(1);
|
||||
|
||||
Arg0 = Builder.CreateBitCast(Arg0,
|
||||
PointerType::getUnqual(Arg1->getType()),
|
||||
"cast");
|
||||
Builder.CreateAlignedStore(Arg1, Arg0, 1);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsX86 && (Name.startswith("avx512.mask.storeu."))) {
|
||||
UpgradeMaskedStore(Builder, CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2), /*Aligned*/false);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsX86 && (Name.startswith("avx512.mask.store."))) {
|
||||
UpgradeMaskedStore(Builder, CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2), /*Aligned*/true);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
}
|
||||
|
||||
Value *Rep;
|
||||
// Upgrade packed integer vector compare intrinsics to compare instructions.
|
||||
if (IsX86 && (Name.startswith("sse2.pcmpeq.") ||
|
||||
|
@ -854,96 +956,6 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
|||
if (CI->getNumArgOperands() == 3)
|
||||
Rep = EmitX86Select(Builder, CI->getArgOperand(2), Rep,
|
||||
CI->getArgOperand(1));
|
||||
} else if (IsX86 && Name.startswith("sse4a.movnt.")) {
|
||||
Module *M = F->getParent();
|
||||
SmallVector<Metadata *, 1> Elts;
|
||||
Elts.push_back(
|
||||
ConstantAsMetadata::get(ConstantInt::get(Type::getInt32Ty(C), 1)));
|
||||
MDNode *Node = MDNode::get(C, Elts);
|
||||
|
||||
Value *Arg0 = CI->getArgOperand(0);
|
||||
Value *Arg1 = CI->getArgOperand(1);
|
||||
|
||||
// Nontemporal (unaligned) store of the 0'th element of the float/double
|
||||
// vector.
|
||||
Type *SrcEltTy = cast<VectorType>(Arg1->getType())->getElementType();
|
||||
PointerType *EltPtrTy = PointerType::getUnqual(SrcEltTy);
|
||||
Value *Addr = Builder.CreateBitCast(Arg0, EltPtrTy, "cast");
|
||||
Value *Extract =
|
||||
Builder.CreateExtractElement(Arg1, (uint64_t)0, "extractelement");
|
||||
|
||||
StoreInst *SI = Builder.CreateAlignedStore(Extract, Addr, 1);
|
||||
SI->setMetadata(M->getMDKindID("nontemporal"), Node);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
} else if (IsX86 && (Name.startswith("avx.movnt.") ||
|
||||
Name.startswith("avx512.storent."))) {
|
||||
Module *M = F->getParent();
|
||||
SmallVector<Metadata *, 1> Elts;
|
||||
Elts.push_back(
|
||||
ConstantAsMetadata::get(ConstantInt::get(Type::getInt32Ty(C), 1)));
|
||||
MDNode *Node = MDNode::get(C, Elts);
|
||||
|
||||
Value *Arg0 = CI->getArgOperand(0);
|
||||
Value *Arg1 = CI->getArgOperand(1);
|
||||
|
||||
// Convert the type of the pointer to a pointer to the stored type.
|
||||
Value *BC = Builder.CreateBitCast(Arg0,
|
||||
PointerType::getUnqual(Arg1->getType()),
|
||||
"cast");
|
||||
VectorType *VTy = cast<VectorType>(Arg1->getType());
|
||||
StoreInst *SI = Builder.CreateAlignedStore(Arg1, BC,
|
||||
VTy->getBitWidth() / 8);
|
||||
SI->setMetadata(M->getMDKindID("nontemporal"), Node);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
} else if (IsX86 && Name == "sse2.storel.dq") {
|
||||
Value *Arg0 = CI->getArgOperand(0);
|
||||
Value *Arg1 = CI->getArgOperand(1);
|
||||
|
||||
Type *NewVecTy = VectorType::get(Type::getInt64Ty(C), 2);
|
||||
Value *BC0 = Builder.CreateBitCast(Arg1, NewVecTy, "cast");
|
||||
Value *Elt = Builder.CreateExtractElement(BC0, (uint64_t)0);
|
||||
Value *BC = Builder.CreateBitCast(Arg0,
|
||||
PointerType::getUnqual(Elt->getType()),
|
||||
"cast");
|
||||
Builder.CreateAlignedStore(Elt, BC, 1);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
} else if (IsX86 && (Name.startswith("sse.storeu.") ||
|
||||
Name.startswith("sse2.storeu.") ||
|
||||
Name.startswith("avx.storeu."))) {
|
||||
Value *Arg0 = CI->getArgOperand(0);
|
||||
Value *Arg1 = CI->getArgOperand(1);
|
||||
|
||||
Arg0 = Builder.CreateBitCast(Arg0,
|
||||
PointerType::getUnqual(Arg1->getType()),
|
||||
"cast");
|
||||
Builder.CreateAlignedStore(Arg1, Arg0, 1);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
} else if (IsX86 && (Name.startswith("avx512.mask.storeu."))) {
|
||||
UpgradeMaskedStore(Builder, CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2), /*Aligned*/false);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
} else if (IsX86 && (Name.startswith("avx512.mask.store."))) {
|
||||
UpgradeMaskedStore(Builder, CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2), /*Aligned*/true);
|
||||
|
||||
// Remove intrinsic.
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
} else if (IsX86 && (Name.startswith("avx512.mask.loadu."))) {
|
||||
Rep = UpgradeMaskedLoad(Builder, CI->getArgOperand(0),
|
||||
CI->getArgOperand(1), CI->getArgOperand(2),
|
||||
|
|
Loading…
Reference in New Issue