I’m applying --affine-loop-unroll=unroll-full to my code.
The resulting code has affine.if with empty conditions.
#set = affine_set<() : (2 == 0)>
..
%28 = affine.if #set() -> i1 {
affine.yield %true : i1
} else {
affine.yield %false : i1
}
scf.if %28 {
%31 = affine.load %arg0[%arg3 + 2, %arg4] : memref<?x258xi32>
%32 = affine.load %arg1[2, 0] : memref<?x3xi32>
%33 = arith.muli %31, %32 : i32
affine.store %33, %arg2[%arg3, %arg4] : memref<?x256xi32>
} else {
%31 = affine.load %arg0[%arg3 + 2, %arg4] : memref<?x258xi32>
%32 = affine.load %arg1[2, 0] : memref<?x3xi32>
%33 = arith.muli %31, %32 : i32
%34 = affine.load %arg2[%arg3, %arg4] : memref<?x256xi32>
%35 = arith.addi %34, %33 : i32
affine.store %35, %arg2[%arg3, %arg4] : memref<?x256xi32>
}
The --canonicalize pass fails to simplify the code.
Is there a pass that would simplify the code and replace the scf.for with just the ‘else’ branch of this scf.for since the condition is trivially false?