Lines Matching defs:EI

111 Instruction *InstCombiner::scalarizePHI(ExtractElementInst &EI, PHINode *PN) {
121 if (PHIUser == cast<Instruction>(&EI))
134 PHINode::Create(EI.getType(), PN->getNumIncomingValues(), ""), *PN));
139 Value *Elt = EI.getIndexOperand();
172 return ReplaceInstUsesWith(EI, scalarPHI);
175 Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
176 // If vector val is constant with all elements the same, replace EI with
178 if (Constant *C = dyn_cast<Constant>(EI.getOperand(0)))
180 return ReplaceInstUsesWith(EI, C->getAggregateElement(0U));
184 if (ConstantInt *IdxC = dyn_cast<ConstantInt>(EI.getOperand(1))) {
186 unsigned VectorWidth = EI.getVectorOperandType()->getNumElements();
191 return ReplaceInstUsesWith(EI, UndefValue::get(EI.getType()));
196 if (EI.getOperand(0)->hasOneUse() && VectorWidth != 1) {
200 if (Value *V = SimplifyDemandedVectorElts(EI.getOperand(0),
202 EI.setOperand(0, V);
203 return &EI;
207 if (Value *Elt = FindScalarElement(EI.getOperand(0), IndexVal))
208 return ReplaceInstUsesWith(EI, Elt);
213 if (BitCastInst *BCI = dyn_cast<BitCastInst>(EI.getOperand(0))) {
217 return new BitCastInst(Elt, EI.getType());
222 if (PHINode *PN = dyn_cast<PHINode>(EI.getOperand(0))) {
223 Instruction *scalarPHI = scalarizePHI(EI, PN);
229 if (Instruction *I = dyn_cast<Instruction>(EI.getOperand(0))) {
234 CheapToScalarize(BO, isa<ConstantInt>(EI.getOperand(1)))) {
236 Builder->CreateExtractElement(BO->getOperand(0), EI.getOperand(1),
237 EI.getName()+".lhs");
239 Builder->CreateExtractElement(BO->getOperand(1), EI.getOperand(1),
240 EI.getName()+".rhs");
245 if (IE->getOperand(2) == EI.getOperand(1))
246 return ReplaceInstUsesWith(EI, IE->getOperand(1));
249 if (isa<Constant>(IE->getOperand(2)) && isa<Constant>(EI.getOperand(1))) {
250 Worklist.AddValue(EI.getOperand(0));
251 EI.setOperand(0, IE->getOperand(0));
252 return &EI;
257 if (ConstantInt *Elt = dyn_cast<ConstantInt>(EI.getOperand(1))) {
264 return ReplaceInstUsesWith(EI, UndefValue::get(EI.getType()));
271 Type *Int32Ty = Type::getInt32Ty(EI.getContext());
281 EI.getIndexOperand());
283 return CastInst::Create(CI->getOpcode(), EE, EI.getType());
335 } else if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)){
336 if (isa<ConstantInt>(EI->getOperand(1)) &&
337 EI->getOperand(0)->getType() == V->getType()) {
339 cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
342 if (EI->getOperand(0) == LHS || EI->getOperand(0) == RHS) {
347 if (EI->getOperand(0) == LHS) {
352 assert(EI->getOperand(0) == RHS);
394 if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)) {
395 if (isa<ConstantInt>(EI->getOperand(1)) && isa<ConstantInt>(IdxOp) &&
396 EI->getOperand(0)->getType() == V->getType()) {
398 cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
403 if (EI->getOperand(0) == RHS || RHS == 0) {
404 RHS = EI->getOperand(0);
413 Value *V = CollectShuffleElements(EI->getOperand(0), Mask, RHS);
429 if (CollectSingleShuffleElements(IEI, EI->getOperand(0), RHS, Mask))
430 return EI->getOperand(0);
453 if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)) {
454 if (isa<ConstantInt>(EI->getOperand(1)) && isa<ConstantInt>(IdxOp) &&
455 EI->getOperand(0)->getType() == IE.getType()) {
458 cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
469 if (EI->getOperand(0) == VecOp && ExtractedIdx == InsertedIdx)