@@ -446,9 +446,9 @@ void llvm::computeKnownBitsFromRangeMetadata(const MDNode &Ranges,
446446}
447447
448448static bool isEphemeralValueOf (const Instruction *I, const Value *E) {
449- SmallVector<const Value *, 16 > WorkSet (1 , I);
450- SmallPtrSet<const Value *, 32 > Visited;
451- SmallPtrSet<const Value *, 16 > EphValues;
449+ SmallVector<const Instruction *, 16 > WorkSet (1 , I);
450+ SmallPtrSet<const Instruction *, 32 > Visited;
451+ SmallPtrSet<const Instruction *, 16 > EphValues;
452452
453453 // The instruction defining an assumption's condition itself is always
454454 // considered ephemeral to that assumption (even if it has other
@@ -457,23 +457,26 @@ static bool isEphemeralValueOf(const Instruction *I, const Value *E) {
457457 return true ;
458458
459459 while (!WorkSet.empty ()) {
460- const Value *V = WorkSet.pop_back_val ();
460+ const Instruction *V = WorkSet.pop_back_val ();
461461 if (!Visited.insert (V).second )
462462 continue ;
463463
464464 // If all uses of this value are ephemeral, then so is this value.
465- if (llvm:: all_of (V->users (), [&](const User *U) {
466- return EphValues.count (U );
467- })) {
465+ if (all_of (V->users (), [&](const User *U) {
466+ return EphValues.count (cast<Instruction>(U) );
467+ })) {
468468 if (V == E)
469469 return true ;
470470
471- if (V == I || (isa<Instruction>(V) &&
472- !cast<Instruction>(V)->mayHaveSideEffects () &&
473- !cast<Instruction>(V)->isTerminator ())) {
474- EphValues.insert (V);
475- if (const User *U = dyn_cast<User>(V))
476- append_range (WorkSet, U->operands ());
471+ if (V == I || (!V->mayHaveSideEffects () && !V->isTerminator ())) {
472+ EphValues.insert (V);
473+
474+ if (const User *U = dyn_cast<User>(V)) {
475+ for (const Use &U : U->operands ()) {
476+ if (const auto *I = dyn_cast<Instruction>(U.get ()))
477+ WorkSet.push_back (I);
478+ }
479+ }
477480 }
478481 }
479482 }
0 commit comments