Please consider the following example:
func.func @foo() {
%lb = arith.constant 0: i32
%ub = arith.constant 0x80000001: i32
%step = arith.constant 1: i32
scf.for %iter = %lb to %ub step %step : i32 {
"op.op"() : () -> ()
}
return
}
After canonicalization, the entire loop disappears. This is because scf.for
strictly uses signed comparison for the bound calculation. See example here: Compiler Explorer
I’m wondering if there is a way to express this loop without using wider integer types or index types? In other words, should scf.for
support unsigned comparison? The syntax can be something like
scf.for unsigned %iter = %lb to %ub step %step : i32 {
"op.op"() : () -> ()
}