mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
Introduce a helper to combine instruction metadata.
Replace the old code in GVN and BBVectorize with it. Update SimplifyCFG to use it. Patch by Björn Steinbrink! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215723 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -391,8 +391,6 @@ namespace {
|
||||
Instruction *&InsertionPt,
|
||||
Instruction *I, Instruction *J);
|
||||
|
||||
void combineMetadata(Instruction *K, const Instruction *J);
|
||||
|
||||
bool vectorizeBB(BasicBlock &BB) {
|
||||
if (skipOptnoneFunction(BB))
|
||||
return false;
|
||||
@ -2964,35 +2962,6 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
// When the first instruction in each pair is cloned, it will inherit its
|
||||
// parent's metadata. This metadata must be combined with that of the other
|
||||
// instruction in a safe way.
|
||||
void BBVectorize::combineMetadata(Instruction *K, const Instruction *J) {
|
||||
SmallVector<std::pair<unsigned, MDNode*>, 4> Metadata;
|
||||
K->getAllMetadataOtherThanDebugLoc(Metadata);
|
||||
for (unsigned i = 0, n = Metadata.size(); i < n; ++i) {
|
||||
unsigned Kind = Metadata[i].first;
|
||||
MDNode *JMD = J->getMetadata(Kind);
|
||||
MDNode *KMD = Metadata[i].second;
|
||||
|
||||
switch (Kind) {
|
||||
default:
|
||||
K->setMetadata(Kind, nullptr); // Remove unknown metadata
|
||||
break;
|
||||
case LLVMContext::MD_tbaa:
|
||||
K->setMetadata(Kind, MDNode::getMostGenericTBAA(JMD, KMD));
|
||||
break;
|
||||
case LLVMContext::MD_alias_scope:
|
||||
case LLVMContext::MD_noalias:
|
||||
K->setMetadata(Kind, MDNode::intersect(JMD, KMD));
|
||||
break;
|
||||
case LLVMContext::MD_fpmath:
|
||||
K->setMetadata(Kind, MDNode::getMostGenericFPMath(JMD, KMD));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This function fuses the chosen instruction pairs into vector instructions,
|
||||
// taking care preserve any needed scalar outputs and, then, it reorders the
|
||||
// remaining instructions as needed (users of the first member of the pair
|
||||
@ -3142,7 +3111,13 @@ namespace {
|
||||
if (!isa<StoreInst>(K))
|
||||
K->mutateType(getVecTypeForPair(L->getType(), H->getType()));
|
||||
|
||||
combineMetadata(K, H);
|
||||
unsigned KnownIDs[] = {
|
||||
LLVMContext::MD_tbaa,
|
||||
LLVMContext::MD_alias_scope,
|
||||
LLVMContext::MD_noalias,
|
||||
LLVMContext::MD_fpmath
|
||||
};
|
||||
combineMetadata(K, H, KnownIDs);
|
||||
K->intersectOptionalDataWith(H);
|
||||
|
||||
for (unsigned o = 0; o < NumOperands; ++o)
|
||||
|
Reference in New Issue
Block a user