diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 3f306bb52c12a..c3aea6052c178 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -332,19 +332,19 @@ struct llvm::gvn::AvailableValueInBlock { //===----------------------------------------------------------------------===// GVNPass::Expression GVNPass::ValueTable::createExpr(Instruction *I) { - Expression e; - e.type = I->getType(); - e.opcode = I->getOpcode(); + Expression E; + E.type = I->getType(); + E.opcode = I->getOpcode(); if (const GCRelocateInst *GCR = dyn_cast(I)) { // gc.relocate is 'special' call: its second and third operands are // not real values, but indices into statepoint's argument list. // Use the refered to values for purposes of identity. - e.varargs.push_back(lookupOrAdd(GCR->getOperand(0))); - e.varargs.push_back(lookupOrAdd(GCR->getBasePtr())); - e.varargs.push_back(lookupOrAdd(GCR->getDerivedPtr())); + E.varargs.push_back(lookupOrAdd(GCR->getOperand(0))); + E.varargs.push_back(lookupOrAdd(GCR->getBasePtr())); + E.varargs.push_back(lookupOrAdd(GCR->getDerivedPtr())); } else { for (Use &Op : I->operands()) - e.varargs.push_back(lookupOrAdd(Op)); + E.varargs.push_back(lookupOrAdd(Op)); } if (I->isCommutative()) { // Ensure that commutative instructions that only differ by a permutation @@ -352,78 +352,78 @@ GVNPass::Expression GVNPass::ValueTable::createExpr(Instruction *I) { // numbers. Since commutative operands are the 1st two operands it is more // efficient to sort by hand rather than using, say, std::sort. assert(I->getNumOperands() >= 2 && "Unsupported commutative instruction!"); - if (e.varargs[0] > e.varargs[1]) - std::swap(e.varargs[0], e.varargs[1]); - e.commutative = true; + if (E.varargs[0] > E.varargs[1]) + std::swap(E.varargs[0], E.varargs[1]); + E.commutative = true; } if (auto *C = dyn_cast(I)) { // Sort the operand value numbers so xx get the same value number. CmpInst::Predicate Predicate = C->getPredicate(); - if (e.varargs[0] > e.varargs[1]) { - std::swap(e.varargs[0], e.varargs[1]); + if (E.varargs[0] > E.varargs[1]) { + std::swap(E.varargs[0], E.varargs[1]); Predicate = CmpInst::getSwappedPredicate(Predicate); } - e.opcode = (C->getOpcode() << 8) | Predicate; - e.commutative = true; - } else if (auto *E = dyn_cast(I)) { - e.varargs.append(E->idx_begin(), E->idx_end()); + E.opcode = (C->getOpcode() << 8) | Predicate; + E.commutative = true; + } else if (auto *IVI = dyn_cast(I)) { + E.varargs.append(IVI->idx_begin(), IVI->idx_end()); } else if (auto *SVI = dyn_cast(I)) { ArrayRef ShuffleMask = SVI->getShuffleMask(); - e.varargs.append(ShuffleMask.begin(), ShuffleMask.end()); + E.varargs.append(ShuffleMask.begin(), ShuffleMask.end()); } else if (auto *CB = dyn_cast(I)) { - e.attrs = CB->getAttributes(); + E.attrs = CB->getAttributes(); } - return e; + return E; } GVNPass::Expression GVNPass::ValueTable::createCmpExpr( unsigned Opcode, CmpInst::Predicate Predicate, Value *LHS, Value *RHS) { assert((Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) && "Not a comparison!"); - Expression e; - e.type = CmpInst::makeCmpResultType(LHS->getType()); - e.varargs.push_back(lookupOrAdd(LHS)); - e.varargs.push_back(lookupOrAdd(RHS)); + Expression E; + E.type = CmpInst::makeCmpResultType(LHS->getType()); + E.varargs.push_back(lookupOrAdd(LHS)); + E.varargs.push_back(lookupOrAdd(RHS)); // Sort the operand value numbers so xx get the same value number. - if (e.varargs[0] > e.varargs[1]) { - std::swap(e.varargs[0], e.varargs[1]); + if (E.varargs[0] > E.varargs[1]) { + std::swap(E.varargs[0], E.varargs[1]); Predicate = CmpInst::getSwappedPredicate(Predicate); } - e.opcode = (Opcode << 8) | Predicate; - e.commutative = true; - return e; + E.opcode = (Opcode << 8) | Predicate; + E.commutative = true; + return E; } GVNPass::Expression GVNPass::ValueTable::createExtractvalueExpr(ExtractValueInst *EI) { assert(EI && "Not an ExtractValueInst?"); - Expression e; - e.type = EI->getType(); - e.opcode = 0; + Expression E; + E.type = EI->getType(); + E.opcode = 0; WithOverflowInst *WO = dyn_cast(EI->getAggregateOperand()); if (WO != nullptr && EI->getNumIndices() == 1 && *EI->idx_begin() == 0) { // EI is an extract from one of our with.overflow intrinsics. Synthesize // a semantically equivalent expression instead of an extract value // expression. - e.opcode = WO->getBinaryOp(); - e.varargs.push_back(lookupOrAdd(WO->getLHS())); - e.varargs.push_back(lookupOrAdd(WO->getRHS())); - return e; + E.opcode = WO->getBinaryOp(); + E.varargs.push_back(lookupOrAdd(WO->getLHS())); + E.varargs.push_back(lookupOrAdd(WO->getRHS())); + return E; } // Not a recognised intrinsic. Fall back to producing an extract value // expression. - e.opcode = EI->getOpcode(); + E.opcode = EI->getOpcode(); for (Use &Op : EI->operands()) - e.varargs.push_back(lookupOrAdd(Op)); + E.varargs.push_back(lookupOrAdd(Op)); - append_range(e.varargs, EI->indices()); + append_range(E.varargs, EI->indices()); - return e; + return E; } GVNPass::Expression GVNPass::ValueTable::createGEPExpr(GetElementPtrInst *GEP) {