Skip to content

Commit

Permalink
Simplify code by using the new getAggregateElement method that got added
Browse files Browse the repository at this point in the history
recently.  This also conveniently gets clang ready for a change about to
land in mainline.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149225 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Jan 30, 2012
1 parent dc58aa7 commit 89f4283
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,8 @@ CodeGenFunction::EmitReferenceBindingToExpr(const Expr *E,
/// input field number being accessed.
unsigned CodeGenFunction::getAccessedFieldNo(unsigned Idx,
const llvm::Constant *Elts) {
if (isa<llvm::ConstantAggregateZero>(Elts))
return 0;

return cast<llvm::ConstantInt>(Elts->getOperand(Idx))->getZExtValue();
return cast<llvm::ConstantInt>(Elts->getAggregateElement(Idx))
->getZExtValue();
}

void CodeGenFunction::EmitCheck(llvm::Value *Address, unsigned Size) {
Expand Down Expand Up @@ -1779,12 +1777,8 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
llvm::Constant *BaseElts = Base.getExtVectorElts();
SmallVector<llvm::Constant *, 4> CElts;

for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
if (isa<llvm::ConstantAggregateZero>(BaseElts))
CElts.push_back(llvm::ConstantInt::get(Int32Ty, 0));
else
CElts.push_back(cast<llvm::Constant>(BaseElts->getOperand(Indices[i])));
}
for (unsigned i = 0, e = Indices.size(); i != e; ++i)
CElts.push_back(BaseElts->getAggregateElement(Indices[i]));
llvm::Constant *CV = llvm::ConstantVector::get(CElts);
return LValue::MakeExtVectorElt(Base.getExtVectorAddr(), CV, type);
}
Expand Down

0 comments on commit 89f4283

Please sign in to comment.