[Mlir-commits] [mlir] [mlir][UB] Erase ops that precede `ub.unreachable` (PR #179104)
Jakub Kuderski
llvmlistbot at llvm.org
Mon Feb 2 06:08:12 PST 2026
================
@@ -9,3 +9,28 @@ func.func @merge_poison() -> (i32, i32) {
%1 = ub.poison : i32
return %0, %1 : i32, i32
}
+
+// -----
+
+// CHECK-LABEL: func @drop_ops_before_unreachable(
+// CHECK-NEXT: arith.constant
+// CHECK-NEXT: arith.constant
+// CHECK-NEXT: arith.constant
+// CHECK-NEXT: vector.print
+// CHECK-NEXT: scf.for {{.*}} {
+// CHECK-NEXT: vector.print
+// CHECK-NEXT: }
+// CHECK-NEXT: ub.unreachable
+func.func @drop_ops_before_unreachable(%arg0: i32) {
+ %lb = arith.constant 3 : index
+ %ub = arith.constant 4 : index
+ %step = arith.constant 0 : index
+ vector.print %arg0 : i32
+ // Infinite loop that may not progress. Such ops (and everything before)
+ // is not erased.
+ scf.for %iv = %lb to %ub step %step {
+ vector.print %arg0 : i32
+ } {mustProgress = false}
+ vector.print %arg0 : i32
+ ub.unreachable
----------------
kuhar wrote:
Maybe add a couple of more ops to be erased before unreachable to it obvious that the backwards iteration is fully exercised?
https://github.com/llvm/llvm-project/pull/179104
More information about the Mlir-commits
mailing list