@@ -263,16 +263,17 @@ static void promoteIfBlock(AffineIfOp ifOp, bool elseBlock) {
263
263
static Operation *getOutermostInvariantForOp (AffineIfOp ifOp) {
264
264
// Walk up the parents past all for op that this conditional is invariant on.
265
265
auto ifOperands = ifOp.getOperands ();
266
- auto *res = ifOp. getOperation () ;
267
- while (!isa<func::FuncOp>( res->getParentOp ())) {
266
+ Operation *res = ifOp;
267
+ while (!res->getParentOp ()-> hasTrait <OpTrait::IsIsolatedFromAbove>( )) {
268
268
auto *parentOp = res->getParentOp ();
269
269
if (auto forOp = dyn_cast<AffineForOp>(parentOp)) {
270
270
if (llvm::is_contained (ifOperands, forOp.getInductionVar ()))
271
271
break ;
272
272
} else if (auto parallelOp = dyn_cast<AffineParallelOp>(parentOp)) {
273
- for (auto iv : parallelOp.getIVs ())
274
- if (llvm::is_contained (ifOperands, iv))
275
- break ;
273
+ if (llvm::any_of (parallelOp.getIVs (), [&](Value iv) {
274
+ return llvm::is_contained (ifOperands, iv);
275
+ }))
276
+ break ;
276
277
} else if (!isa<AffineIfOp>(parentOp)) {
277
278
// Won't walk up past anything other than affine.for/if ops.
278
279
break ;
@@ -438,11 +439,10 @@ LogicalResult mlir::affine::hoistAffineIfOp(AffineIfOp ifOp, bool *folded) {
438
439
if (folded)
439
440
*folded = false ;
440
441
441
- // The folding above should have ensured this, but the affine.if's
442
- // canonicalization is missing composition of affine.applys into it.
442
+ // The folding above should have ensured this.
443
443
assert (llvm::all_of (ifOp.getOperands (),
444
444
[](Value v) {
445
- return isTopLevelValue (v) || isAffineForInductionVar (v);
445
+ return isTopLevelValue (v) || isAffineInductionVar (v);
446
446
}) &&
447
447
" operands not composed" );
448
448
0 commit comments