@@ -308,7 +308,7 @@ InstCombinerImpl::foldPHIArgInsertValueInstructionIntoPHI(PHINode &PN) {
308308 // and all have a single use.
309309 for (unsigned i = 1 ; i != PN .getNumIncomingValues (); ++i) {
310310 auto *I = dyn_cast<InsertValueInst>(PN .getIncomingValue (i));
311- if (!I || !I->hasOneUse () || I->getIndices () != FirstIVI->getIndices ())
311+ if (!I || !I->hasOneUser () || I->getIndices () != FirstIVI->getIndices ())
312312 return nullptr ;
313313 }
314314
@@ -348,7 +348,7 @@ InstCombinerImpl::foldPHIArgExtractValueInstructionIntoPHI(PHINode &PN) {
348348 // and all have a single use.
349349 for (unsigned i = 1 ; i != PN .getNumIncomingValues (); ++i) {
350350 auto *I = dyn_cast<ExtractValueInst>(PN .getIncomingValue (i));
351- if (!I || !I->hasOneUse () || I->getIndices () != FirstEVI->getIndices () ||
351+ if (!I || !I->hasOneUser () || I->getIndices () != FirstEVI->getIndices () ||
352352 I->getAggregateOperand ()->getType () !=
353353 FirstEVI->getAggregateOperand ()->getType ())
354354 return nullptr ;
@@ -376,7 +376,7 @@ InstCombinerImpl::foldPHIArgExtractValueInstructionIntoPHI(PHINode &PN) {
376376}
377377
378378// / If we have something like phi [add (a,b), add(a,c)] and if a/b/c and the
379- // / adds all have a single use , turn this into a phi and a single binop.
379+ // / adds all have a single user , turn this into a phi and a single binop.
380380Instruction *InstCombinerImpl::foldPHIArgBinOpIntoPHI (PHINode &PN ) {
381381 Instruction *FirstInst = cast<Instruction>(PN .getIncomingValue (0 ));
382382 assert (isa<BinaryOperator>(FirstInst) || isa<CmpInst>(FirstInst));
@@ -387,10 +387,10 @@ Instruction *InstCombinerImpl::foldPHIArgBinOpIntoPHI(PHINode &PN) {
387387 Type *LHSType = LHSVal->getType ();
388388 Type *RHSType = RHSVal->getType ();
389389
390- // Scan to see if all operands are the same opcode, and all have one use .
390+ // Scan to see if all operands are the same opcode, and all have one user .
391391 for (unsigned i = 1 ; i != PN .getNumIncomingValues (); ++i) {
392392 Instruction *I = dyn_cast<Instruction>(PN .getIncomingValue (i));
393- if (!I || I->getOpcode () != Opc || !I->hasOneUse () ||
393+ if (!I || I->getOpcode () != Opc || !I->hasOneUser () ||
394394 // Verify type of the LHS matches so we don't fold cmp's of different
395395 // types.
396396 I->getOperand (0 )->getType () != LHSType ||
@@ -486,11 +486,12 @@ Instruction *InstCombinerImpl::foldPHIArgGEPIntoPHI(PHINode &PN) {
486486
487487 bool AllInBounds = true ;
488488
489- // Scan to see if all operands are the same opcode, and all have one use .
489+ // Scan to see if all operands are the same opcode, and all have one user .
490490 for (unsigned i = 1 ; i != PN .getNumIncomingValues (); ++i) {
491- GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(PN .getIncomingValue (i));
492- if (!GEP || !GEP ->hasOneUse () || GEP ->getType () != FirstInst->getType () ||
493- GEP ->getNumOperands () != FirstInst->getNumOperands ())
491+ GetElementPtrInst *GEP =
492+ dyn_cast<GetElementPtrInst>(PN .getIncomingValue (i));
493+ if (!GEP || !GEP ->hasOneUser () || GEP ->getType () != FirstInst->getType () ||
494+ GEP ->getNumOperands () != FirstInst->getNumOperands ())
494495 return nullptr ;
495496
496497 AllInBounds &= GEP ->isInBounds ();
@@ -657,7 +658,7 @@ Instruction *InstCombinerImpl::foldPHIArgLoadIntoPHI(PHINode &PN) {
657658 // Check to see if all arguments are the same operation.
658659 for (unsigned i = 1 , e = PN .getNumIncomingValues (); i != e; ++i) {
659660 LoadInst *LI = dyn_cast<LoadInst>(PN .getIncomingValue (i));
660- if (!LI || !LI ->hasOneUse ())
661+ if (!LI || !LI ->hasOneUser ())
661662 return nullptr ;
662663
663664 // We can't sink the load if the loaded value could be modified between
@@ -770,8 +771,8 @@ Instruction *InstCombinerImpl::foldPHIArgZextsIntoPHI(PHINode &Phi) {
770771 unsigned NumConsts = 0 ;
771772 for (Value *V : Phi.incoming_values ()) {
772773 if (auto *Zext = dyn_cast<ZExtInst>(V)) {
773- // All zexts must be identical and have one use .
774- if (Zext->getSrcTy () != NarrowType || !Zext->hasOneUse ())
774+ // All zexts must be identical and have one user .
775+ if (Zext->getSrcTy () != NarrowType || !Zext->hasOneUser ())
775776 return nullptr ;
776777 NewIncoming.push_back (Zext->getOperand (0 ));
777778 NumZexts++;
@@ -859,7 +860,7 @@ Instruction *InstCombinerImpl::foldPHIArgOpIntoPHI(PHINode &PN) {
859860 // Check to see if all arguments are the same operation.
860861 for (unsigned i = 1 , e = PN .getNumIncomingValues (); i != e; ++i) {
861862 Instruction *I = dyn_cast<Instruction>(PN .getIncomingValue (i));
862- if (!I || !I->hasOneUse () || !I->isSameOperationAs (FirstInst))
863+ if (!I || !I->hasOneUser () || !I->isSameOperationAs (FirstInst))
863864 return nullptr ;
864865 if (CastSrcTy) {
865866 if (I->getOperand (0 )->getType () != CastSrcTy)
@@ -1303,10 +1304,8 @@ Instruction *InstCombinerImpl::visitPHINode(PHINode &PN) {
13031304 if (isa<Instruction>(PN .getIncomingValue (0 )) &&
13041305 isa<Instruction>(PN .getIncomingValue (1 )) &&
13051306 cast<Instruction>(PN .getIncomingValue (0 ))->getOpcode () ==
1306- cast<Instruction>(PN .getIncomingValue (1 ))->getOpcode () &&
1307- // FIXME: The hasOneUse check will fail for PHIs that use the value more
1308- // than themselves more than once.
1309- PN .getIncomingValue (0 )->hasOneUse ())
1307+ cast<Instruction>(PN .getIncomingValue (1 ))->getOpcode () &&
1308+ PN .getIncomingValue (0 )->hasOneUser ())
13101309 if (Instruction *Result = foldPHIArgOpIntoPHI (PN ))
13111310 return Result;
13121311
0 commit comments