@@ -5000,31 +5000,24 @@ bool InstCombinerImpl::run() {
5000
5000
BasicBlock *UserParent = nullptr ;
5001
5001
unsigned NumUsers = 0 ;
5002
5002
5003
- for (auto *U : I->users ()) {
5004
- if (U->isDroppable ())
5003
+ for (Use &U : I->uses ()) {
5004
+ User *User = U.getUser ();
5005
+ if (User->isDroppable ())
5005
5006
continue ;
5006
5007
if (NumUsers > MaxSinkNumUsers)
5007
5008
return std::nullopt;
5008
5009
5009
- Instruction *UserInst = cast<Instruction>(U );
5010
+ Instruction *UserInst = cast<Instruction>(User );
5010
5011
// Special handling for Phi nodes - get the block the use occurs in.
5011
- if (PHINode *PN = dyn_cast<PHINode>(UserInst)) {
5012
- for (unsigned i = 0 ; i < PN->getNumIncomingValues (); i++) {
5013
- if (PN->getIncomingValue (i) == I) {
5014
- // Bail out if we have uses in different blocks. We don't do any
5015
- // sophisticated analysis (i.e finding NearestCommonDominator of
5016
- // these use blocks).
5017
- if (UserParent && UserParent != PN->getIncomingBlock (i))
5018
- return std::nullopt;
5019
- UserParent = PN->getIncomingBlock (i);
5020
- }
5021
- }
5022
- assert (UserParent && " expected to find user block!" );
5023
- } else {
5024
- if (UserParent && UserParent != UserInst->getParent ())
5025
- return std::nullopt;
5026
- UserParent = UserInst->getParent ();
5027
- }
5012
+ BasicBlock *UserBB = UserInst->getParent ();
5013
+ if (PHINode *PN = dyn_cast<PHINode>(UserInst))
5014
+ UserBB = PN->getIncomingBlock (U);
5015
+ // Bail out if we have uses in different blocks. We don't do any
5016
+ // sophisticated analysis (i.e finding NearestCommonDominator of these
5017
+ // use blocks).
5018
+ if (UserParent && UserParent != UserBB)
5019
+ return std::nullopt;
5020
+ UserParent = UserBB;
5028
5021
5029
5022
// Make sure these checks are done only once, naturally we do the checks
5030
5023
// the first time we get the userparent, this will save compile time.
0 commit comments