diff --git a/compiler/src/iree/compiler/Dialect/Flow/Transforms/FormDispatchRegions.cpp b/compiler/src/iree/compiler/Dialect/Flow/Transforms/FormDispatchRegions.cpp index 2ceda0d6360e..9eac12d4b56b 100644 --- a/compiler/src/iree/compiler/Dialect/Flow/Transforms/FormDispatchRegions.cpp +++ b/compiler/src/iree/compiler/Dialect/Flow/Transforms/FormDispatchRegions.cpp @@ -317,20 +317,19 @@ static bool isIdentityMapWithZeros(AffineMap map) { if (map.isEmpty()) return false; unsigned dimsSeen = 0; - for (auto result : map.getResults()) { - bool isValidExpr = TypeSwitch(result) - .Case([&dimsSeen](auto dimExpr) { - if (dimExpr.getPosition() != dimsSeen) - return false; - dimsSeen++; - return true; - }) - .Case([](auto constExpr) { - return constExpr.getValue() == 0; - }) - .Default([](AffineExpr) { return false; }); - if (!isValidExpr) + for (AffineExpr result : map.getResults()) { + if (auto dimExpr = dyn_cast(result)) { + if (dimExpr.getPosition() != dimsSeen) { + return false; + } + dimsSeen++; + } else if (auto constExpr = dyn_cast(result)) { + if (constExpr.getValue() != 0) { + return false; + } + } else { return false; + } } return dimsSeen == map.getNumDims(); }