Skip to content

Commit 8d2e629

Browse files
committed
[mlir] fix assertion failure in remove-dead-values
1 parent 6e5ee4a commit 8d2e629

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

mlir/lib/Transforms/RemoveDeadValues.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,8 @@ static void cleanUpDeadVals(RDVFinalCleanupList &list) {
705705

706706
// 4. Operands
707707
for (auto &o : list.operands) {
708-
o.op->eraseOperands(o.nonLive);
708+
if (o.nonLive.size() > 0)
709+
o.op->eraseOperands(o.nonLive);
709710
}
710711

711712
// 5. Results

mlir/test/Transforms/remove-dead-values.mlir

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,25 @@ module {
510510
// CHECK: %[[yield:.*]] = arith.addf %{{.*}}, %{{.*}} : f32
511511
// CHECK: linalg.yield %[[yield]] : f32
512512
// CHECK-NOT: arith.subf
513+
514+
515+
// -----
516+
517+
// check that ops with zero operands are correctly handled
518+
519+
module {
520+
func.func @test_zero_operands(%I: memref<10xindex>, %I2: memref<10xf32>) {
521+
%v0 = arith.constant 0 : index
522+
%result = memref.alloca_scope -> index {
523+
%c = arith.addi %v0, %v0 : index
524+
memref.store %c, %I[%v0] : memref<10xindex>
525+
memref.alloca_scope.return %c: index
526+
}
527+
func.return
528+
}
529+
}
530+
531+
// CHECK-LABEL: func @test_zero_operands
532+
// CHECK: memref.alloca_scope
533+
// CHECK: memref.store
534+
// CHECK-NOT: memref.alloca_scope.return

0 commit comments

Comments
 (0)