-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Open
Labels
Description
Consider (https://godbolt.org/z/W95n8jEvM):
func.func private @test(%arg0: i64) -> (i64) {
%c0_i64 = arith.constant 0 : i64
%2 = arith.cmpi eq, %arg0, %c0_i64 : i64
cf.cond_br %2, ^bb1, ^bb2
^bb1: // pred: ^bb0
%c1_i64 = arith.constant 1 : i64
return %c1_i64 : i64
^bb2: // pred: ^bb0
%c3_i64 = arith.constant 3 : i64
return %c3_i64 : i64
}
Running mlir-opt --remove-dead-values
results in the following error:
<source>:4:5: error: 'cf.cond_br' op expected 1 or more operands, but found 0
cf.cond_br %2, ^bb1, ^bb2
^
<source>:4:5: note: see current operation: "cf.cond_br"()[^bb1, ^bb2] <{operandSegmentSizes = array<i32: 1, 0, 0>}> : () -> ()
The input I had before reduction instead causes it to complain about a ‘null operand’, but I presume the bug is the same (https://godbolt.org/z/cM14hjqjh):
func.func private @test(%arg0: i64) {
%0 = "custom.slot"() <{alignment = 8 : i64, bytes = 8 : i64}> : () -> !llvm.ptr
"custom.store"(%0, %arg0) <{alignment = 8 : i64}> : (!llvm.ptr, i64) -> ()
%1 = "custom.load"(%0) <{alignment = 8 : i64}> : (!llvm.ptr) -> i64
%c0_i64 = arith.constant 0 : i64
%2 = arith.cmpi eq, %1, %c0_i64 : i64
cf.cond_br %2, ^bb1, ^bb2
^bb1: // pred: ^bb0
%c1_i64 = arith.constant 1 : i64
"custom.ret"(%c1_i64) : (i64) -> ()
^bb2: // pred: ^bb0
%c3_i64 = arith.constant 3 : i64
"custom.ret"(%c3_i64) : (i64) -> ()
}
Error message:
<source>:7:5: error: null operand found
cf.cond_br %2, ^bb1, ^bb2
^
<source>:7:5: note: see current operation: "cf.cond_br"(<<NULL VALUE>>)[^bb1, ^bb2] <{operandSegmentSizes = array<i32: 1, 0, 0>}> : (<<NULL TYPE>>) -> ()
In both cases, removing private
causes the error to disappear.