@@ -405,13 +405,15 @@ bool VectorCombine::isExtractExtractCheap(ExtractElementInst *Ext0,
405
405
const Instruction &I,
406
406
ExtractElementInst *&ConvertToShuffle,
407
407
unsigned PreferredExtractIndex) {
408
- auto *Ext0IndexC = dyn_cast<ConstantInt>(Ext0->getOperand ( 1 ));
409
- auto *Ext1IndexC = dyn_cast<ConstantInt>(Ext1->getOperand ( 1 ));
408
+ auto *Ext0IndexC = dyn_cast<ConstantInt>(Ext0->getIndexOperand ( ));
409
+ auto *Ext1IndexC = dyn_cast<ConstantInt>(Ext1->getIndexOperand ( ));
410
410
assert (Ext0IndexC && Ext1IndexC && " Expected constant extract indexes" );
411
411
412
412
unsigned Opcode = I.getOpcode ();
413
+ Value *Ext0Src = Ext0->getVectorOperand ();
414
+ Value *Ext1Src = Ext1->getVectorOperand ();
413
415
Type *ScalarTy = Ext0->getType ();
414
- auto *VecTy = cast<VectorType>(Ext0-> getOperand ( 0 ) ->getType ());
416
+ auto *VecTy = cast<VectorType>(Ext0Src ->getType ());
415
417
InstructionCost ScalarOpCost, VectorOpCost;
416
418
417
419
// Get cost estimates for scalar and vector versions of the operation.
@@ -452,7 +454,7 @@ bool VectorCombine::isExtractExtractCheap(ExtractElementInst *Ext0,
452
454
// Extra uses of the extracts mean that we include those costs in the
453
455
// vector total because those instructions will not be eliminated.
454
456
InstructionCost OldCost, NewCost;
455
- if (Ext0-> getOperand ( 0 ) == Ext1-> getOperand ( 0 ) && Ext0Index == Ext1Index) {
457
+ if (Ext0Src == Ext1Src && Ext0Index == Ext1Index) {
456
458
// Handle a special case. If the 2 extracts are identical, adjust the
457
459
// formulas to account for that. The extra use charge allows for either the
458
460
// CSE'd pattern or an unoptimized form with identical values:
@@ -513,12 +515,12 @@ static ExtractElementInst *translateExtract(ExtractElementInst *ExtElt,
513
515
unsigned NewIndex,
514
516
IRBuilder<> &Builder) {
515
517
// Shufflevectors can only be created for fixed-width vectors.
516
- if (!isa<FixedVectorType>(ExtElt->getOperand (0 )->getType ()))
518
+ Value *X = ExtElt->getVectorOperand ();
519
+ if (!isa<FixedVectorType>(X->getType ()))
517
520
return nullptr ;
518
521
519
522
// If the extract can be constant-folded, this code is unsimplified. Defer
520
523
// to other passes to handle that.
521
- Value *X = ExtElt->getVectorOperand ();
522
524
Value *C = ExtElt->getIndexOperand ();
523
525
assert (isa<ConstantInt>(C) && " Expected a constant index operand" );
524
526
if (isa<Constant>(X))
0 commit comments