diff options
| author | Hal Finkel <hfinkel@anl.gov> | 2012-06-28 05:42:26 +0000 | 
|---|---|---|
| committer | Hal Finkel <hfinkel@anl.gov> | 2012-06-28 05:42:26 +0000 | 
| commit | 74e5225c92078c5ea15ea4bc19e86dd2e36a63f4 (patch) | |
| tree | 753c2eb18617feb4c443f23c1beacb285fc1c2b7 /llvm/lib/VMCore | |
| parent | a2ccbf0f85969807df1d77a2ff0c07ea0bb6bef2 (diff) | |
| download | bcm5719-llvm-74e5225c92078c5ea15ea4bc19e86dd2e36a63f4.tar.gz bcm5719-llvm-74e5225c92078c5ea15ea4bc19e86dd2e36a63f4.zip | |
Refactor operation equivalence checking in BBVectorize by extending Instruction::isSameOperationAs.
Maintaining this kind of checking in different places is dangerous, extending
Instruction::isSameOperationAs consolidates this logic into one place. Here
I've added an optional flags parameter and two flags that are important for
vectorization: CompareIgnoringAlignment and CompareUsingScalarTypes.
llvm-svn: 159329
Diffstat (limited to 'llvm/lib/VMCore')
| -rw-r--r-- | llvm/lib/VMCore/Instruction.cpp | 21 | 
1 files changed, 16 insertions, 5 deletions
| diff --git a/llvm/lib/VMCore/Instruction.cpp b/llvm/lib/VMCore/Instruction.cpp index faa99db4fcb..66379a04931 100644 --- a/llvm/lib/VMCore/Instruction.cpp +++ b/llvm/lib/VMCore/Instruction.cpp @@ -240,27 +240,38 @@ bool Instruction::isIdenticalToWhenDefined(const Instruction *I) const {  // isSameOperationAs  // This should be kept in sync with isEquivalentOperation in  // lib/Transforms/IPO/MergeFunctions.cpp. -bool Instruction::isSameOperationAs(const Instruction *I) const { +bool Instruction::isSameOperationAs(const Instruction *I, +                                    unsigned flags) const { +  bool IgnoreAlignment = flags & CompareIgnoringAlignment; +  bool UseScalarTypes  = flags & CompareUsingScalarTypes; +    if (getOpcode() != I->getOpcode() ||        getNumOperands() != I->getNumOperands() || -      getType() != I->getType()) +      (UseScalarTypes ? +       getType()->getScalarType() != I->getType()->getScalarType() : +       getType() != I->getType()))      return false;    // We have two instructions of identical opcode and #operands.  Check to see    // if all operands are the same type    for (unsigned i = 0, e = getNumOperands(); i != e; ++i) -    if (getOperand(i)->getType() != I->getOperand(i)->getType()) +    if (UseScalarTypes ? +        getOperand(i)->getType()->getScalarType() != +          I->getOperand(i)->getType()->getScalarType() : +        getOperand(i)->getType() != I->getOperand(i)->getType())        return false;    // Check special state that is a part of some instructions.    if (const LoadInst *LI = dyn_cast<LoadInst>(this))      return LI->isVolatile() == cast<LoadInst>(I)->isVolatile() && -           LI->getAlignment() == cast<LoadInst>(I)->getAlignment() && +           (LI->getAlignment() == cast<LoadInst>(I)->getAlignment() || +            IgnoreAlignment) &&             LI->getOrdering() == cast<LoadInst>(I)->getOrdering() &&             LI->getSynchScope() == cast<LoadInst>(I)->getSynchScope();    if (const StoreInst *SI = dyn_cast<StoreInst>(this))      return SI->isVolatile() == cast<StoreInst>(I)->isVolatile() && -           SI->getAlignment() == cast<StoreInst>(I)->getAlignment() && +           (SI->getAlignment() == cast<StoreInst>(I)->getAlignment() || +            IgnoreAlignment) &&             SI->getOrdering() == cast<StoreInst>(I)->getOrdering() &&             SI->getSynchScope() == cast<StoreInst>(I)->getSynchScope();    if (const CmpInst *CI = dyn_cast<CmpInst>(this)) | 

