Lines Matching refs:EI
123 Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
125 if (isa<UndefValue>(EI.getOperand(0)))
126 return ReplaceInstUsesWith(EI, UndefValue::get(EI.getType()));
129 if (isa<ConstantAggregateZero>(EI.getOperand(0)))
130 return ReplaceInstUsesWith(EI, Constant::getNullValue(EI.getType()));
132 if (ConstantVector *C = dyn_cast<ConstantVector>(EI.getOperand(0))) {
133 // If vector val is constant with all elements the same, replace EI with
143 return ReplaceInstUsesWith(EI, op0);
148 if (ConstantInt *IdxC = dyn_cast<ConstantInt>(EI.getOperand(1))) {
150 unsigned VectorWidth = EI.getVectorOperandType()->getNumElements();
155 return ReplaceInstUsesWith(EI, UndefValue::get(EI.getType()));
160 if (EI.getOperand(0)->hasOneUse() && VectorWidth != 1) {
164 if (Value *V = SimplifyDemandedVectorElts(EI.getOperand(0),
166 EI.setOperand(0, V);
167 return &EI;
171 if (Value *Elt = FindScalarElement(EI.getOperand(0), IndexVal))
172 return ReplaceInstUsesWith(EI, Elt);
177 if (BitCastInst *BCI = dyn_cast<BitCastInst>(EI.getOperand(0))) {
182 return new BitCastInst(Elt, EI.getType());
186 if (Instruction *I = dyn_cast<Instruction>(EI.getOperand(0))) {
191 CheapToScalarize(BO, isa<ConstantInt>(EI.getOperand(1)))) {
193 Builder->CreateExtractElement(BO->getOperand(0), EI.getOperand(1),
194 EI.getName()+".lhs");
196 Builder->CreateExtractElement(BO->getOperand(1), EI.getOperand(1),
197 EI.getName()+".rhs");
202 if (IE->getOperand(2) == EI.getOperand(1))
203 return ReplaceInstUsesWith(EI, IE->getOperand(1));
206 if (isa<Constant>(IE->getOperand(2)) && isa<Constant>(EI.getOperand(1))) {
207 Worklist.AddValue(EI.getOperand(0));
208 EI.setOperand(0, IE->getOperand(0));
209 return &EI;
214 if (ConstantInt *Elt = dyn_cast<ConstantInt>(EI.getOperand(1))) {
221 return ReplaceInstUsesWith(EI, UndefValue::get(EI.getType()));
228 Type *Int32Ty = Type::getInt32Ty(EI.getContext());
236 if (CI->hasOneUse() && EI.hasOneUse() &&
239 EI.getIndexOperand());
240 return CastInst::Create(CI->getOpcode(), EE, EI.getType());
292 } else if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)){
293 if (isa<ConstantInt>(EI->getOperand(1)) &&
294 EI->getOperand(0)->getType() == V->getType()) {
296 cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
299 if (EI->getOperand(0) == LHS || EI->getOperand(0) == RHS) {
304 if (EI->getOperand(0) == LHS) {
309 assert(EI->getOperand(0) == RHS);
347 if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)) {
348 if (isa<ConstantInt>(EI->getOperand(1)) && isa<ConstantInt>(IdxOp) &&
349 EI->getOperand(0)->getType() == V->getType()) {
351 cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
356 if (EI->getOperand(0) == RHS || RHS == 0) {
357 RHS = EI->getOperand(0);
366 Value *V = CollectShuffleElements(EI->getOperand(0), Mask, RHS);
378 if (CollectSingleShuffleElements(IEI, EI->getOperand(0), RHS, Mask))
379 return EI->getOperand(0);
402 if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)) {
403 if (isa<ConstantInt>(EI->getOperand(1)) && isa<ConstantInt>(IdxOp) &&
404 EI->getOperand(0)->getType() == IE.getType()) {
407 cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
418 if (EI->getOperand(0) == VecOp && ExtractedIdx == InsertedIdx)