diff options
| author | Daniel Berlin <dberlin@dberlin.org> | 2017-01-31 22:31:58 +0000 | 
|---|---|---|
| committer | Daniel Berlin <dberlin@dberlin.org> | 2017-01-31 22:31:58 +0000 | 
| commit | c22aafe5b3ce4550c77a7cc702121d00582e3a67 (patch) | |
| tree | a99a7797a5be022ab95019a5a7781bc3ac900c4e /llvm/lib/Transforms/Scalar | |
| parent | 808e3ff8a26354644378cf417005fc3b3a293eb9 (diff) | |
| download | bcm5719-llvm-c22aafe5b3ce4550c77a7cc702121d00582e3a67.tar.gz bcm5719-llvm-c22aafe5b3ce4550c77a7cc702121d00582e3a67.zip  | |
NewGVN: Add basic support for symbolic comparison evaluation
llvm-svn: 293706
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/NewGVN.cpp | 23 | 
1 files changed, 20 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp index 37c09fa5605..7a0e076abfc 100644 --- a/llvm/lib/Transforms/Scalar/NewGVN.cpp +++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp @@ -347,6 +347,8 @@ private:                                                   const BasicBlock *);    const Expression *performSymbolicAggrValueEvaluation(Instruction *,                                                         const BasicBlock *); +  const Expression *performSymbolicCmpEvaluation(Instruction *, +                                                 const BasicBlock *);    // Congruence finding.    Value *lookupOperandLeader(Value *) const; @@ -1002,6 +1004,20 @@ NewGVN::performSymbolicAggrValueEvaluation(Instruction *I,    return createAggregateValueExpression(I, B);  } +const Expression *NewGVN::performSymbolicCmpEvaluation(Instruction *I, +                                                       const BasicBlock *B) { +  CmpInst *CI = dyn_cast<CmpInst>(I); +  // See if our operands are equal and that implies something. +  auto Op0 = lookupOperandLeader(CI->getOperand(0)); +  auto Op1 = lookupOperandLeader(CI->getOperand(1)); +  if (Op0 == Op1) { +    if (CI->isTrueWhenEqual()) +      return createConstantExpression(ConstantInt::getTrue(CI->getType())); +    else if (CI->isFalseWhenEqual()) +      return createConstantExpression(ConstantInt::getFalse(CI->getType())); +  } +  return createExpression(I, B); +}  // Substitute and symbolize the value before value numbering.  const Expression *NewGVN::performSymbolicEvaluation(Value *V, @@ -1036,7 +1052,10 @@ const Expression *NewGVN::performSymbolicEvaluation(Value *V,      case Instruction::BitCast: {        E = createExpression(I, B);      } break; - +    case Instruction::ICmp: +    case Instruction::FCmp: { +      E = performSymbolicCmpEvaluation(I, B); +    } break;      case Instruction::Add:      case Instruction::FAdd:      case Instruction::Sub: @@ -1055,8 +1074,6 @@ const Expression *NewGVN::performSymbolicEvaluation(Value *V,      case Instruction::And:      case Instruction::Or:      case Instruction::Xor: -    case Instruction::ICmp: -    case Instruction::FCmp:      case Instruction::Trunc:      case Instruction::ZExt:      case Instruction::SExt:  | 

