diff --git a/lib/Dialect/FIRRTL/FIRRTLOps.cpp b/lib/Dialect/FIRRTL/FIRRTLOps.cpp index b1c26d2fe06b..f421dc56bbf3 100644 --- a/lib/Dialect/FIRRTL/FIRRTLOps.cpp +++ b/lib/Dialect/FIRRTL/FIRRTLOps.cpp @@ -123,14 +123,10 @@ Flow firrtl::foldFlow(Value val, Flow accumulatedFlow) { .Case( [](auto) { return Flow::Duplex; }) .Case([&](auto inst) { - for (auto arg : llvm::enumerate(inst.getResults())) - if (arg.value() == val) { - if (inst.getPortDirection(arg.index()) == Direction::Out) - return accumulatedFlow; - else - return swap(); - } - llvm_unreachable("couldn't find result in results"); + auto resultNo = val.cast().getResultNumber(); + if (inst.getPortDirection(resultNo) == Direction::Out) + return accumulatedFlow; + return swap(); }) .Case([&](auto op) { return swap(); }) // Anything else acts like a universal source.