Lines Matching refs:EI
68 Instruction *InstCombiner::scalarizePHI(ExtractElementInst &EI, PHINode *PN) {
78 if (PHIUser == cast<Instruction>(&EI))
91 PHINode::Create(EI.getType(), PN->getNumIncomingValues(), ""), *PN));
96 Value *Elt = EI.getIndexOperand();
128 return ReplaceInstUsesWith(EI, scalarPHI);
131 Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
133 EI.getVectorOperand(), EI.getIndexOperand(), DL, TLI, DT, AC))
134 return ReplaceInstUsesWith(EI, V);
136 // If vector val is constant with all elements the same, replace EI with
138 if (Constant *C = dyn_cast<Constant>(EI.getOperand(0)))
140 return ReplaceInstUsesWith(EI, C->getAggregateElement(0U));
144 if (ConstantInt *IdxC = dyn_cast<ConstantInt>(EI.getOperand(1))) {
146 unsigned VectorWidth = EI.getVectorOperandType()->getNumElements();
154 if (EI.getOperand(0)->hasOneUse() && VectorWidth != 1) {
158 if (Value *V = SimplifyDemandedVectorElts(EI.getOperand(0), DemandedMask,
160 EI.setOperand(0, V);
161 return &EI;
168 if (BitCastInst *BCI = dyn_cast<BitCastInst>(EI.getOperand(0))) {
172 return new BitCastInst(Elt, EI.getType());
177 if (PHINode *PN = dyn_cast<PHINode>(EI.getOperand(0))) {
178 Instruction *scalarPHI = scalarizePHI(EI, PN);
184 if (Instruction *I = dyn_cast<Instruction>(EI.getOperand(0))) {
189 cheapToScalarize(BO, isa<ConstantInt>(EI.getOperand(1)))) {
191 Builder->CreateExtractElement(BO->getOperand(0), EI.getOperand(1),
192 EI.getName()+".lhs");
194 Builder->CreateExtractElement(BO->getOperand(1), EI.getOperand(1),
195 EI.getName()+".rhs");
200 if (IE->getOperand(2) == EI.getOperand(1))
201 return ReplaceInstUsesWith(EI, IE->getOperand(1));
204 if (isa<Constant>(IE->getOperand(2)) && isa<Constant>(EI.getOperand(1))) {
205 Worklist.AddValue(EI.getOperand(0));
206 EI.setOperand(0, IE->getOperand(0));
207 return &EI;
212 if (ConstantInt *Elt = dyn_cast<ConstantInt>(EI.getOperand(1))) {
219 return ReplaceInstUsesWith(EI, UndefValue::get(EI.getType()));
226 Type *Int32Ty = Type::getInt32Ty(EI.getContext());
237 EI.getIndexOperand());
239 return CastInst::Create(CI->getOpcode(), EE, EI.getType());
256 EI.getIndexOperand(),
262 EI.getIndexOperand(),
267 EI.getIndexOperand(),
323 } else if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)){
324 if (isa<ConstantInt>(EI->getOperand(1))) {
326 cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
330 if (EI->getOperand(0) == LHS || EI->getOperand(0) == RHS) {
335 if (EI->getOperand(0) == LHS) {
340 assert(EI->getOperand(0) == RHS);
389 EI = dyn_cast<ExtractElementInst>(ScalarOp)) {
390 if (isa<ConstantInt>(EI->getOperand(1)) && isa<ConstantInt>(IdxOp)) {
392 cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
397 if (EI->getOperand(0) == PermittedRHS || PermittedRHS == nullptr) {
398 Value *RHS = EI->getOperand(0);
421 EI->getOperand(0)->getType()->getVectorNumElements();
426 return std::make_pair(EI->getOperand(0), PermittedRHS);
431 if (EI->getOperand(0)->getType() == PermittedRHS->getType() &&
432 collectSingleShuffleElements(IEI, EI->getOperand(0), PermittedRHS,
434 return std::make_pair(EI->getOperand(0), PermittedRHS);
491 if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)) {
492 if (isa<ConstantInt>(EI->getOperand(1)) && isa<ConstantInt>(IdxOp)) {
495 EI->getOperand(0)->getType()->getVectorNumElements();
497 cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
508 if (EI->getOperand(0) == VecOp && ExtractedIdx == InsertedIdx)