-
Notifications
You must be signed in to change notification settings - Fork 170
Hello, I was looking at the generated code from Polygeist and I stumble upon this code pattern that is created for every function.
This code is generated by the MLIRScanner Ctor as well as the IfScope Ctor:
%true = arith.constant true
%11 = memref.alloca() : memref<i1>
memref.store %true, %11[] : memref<i1>
%13 = memref.load %11[] : memref<i1>
scf.if %13 {
scf.execute_region {
%16 = memref.load %11[] : memref<i1>
scf.if %16 {
scf.execute_region {
... do stuff until yield
I'm not getting the importance of this "branching" code. Since it's generated on hard-coded constant value true.
Why not just have the ... do stuff inside the function region instead of creating subregions?
All reactions
Replies: 1 comment
This pattern is generated to correctly handle return, break and continue.
For example, the register is set to false after a return has been seen to ensure no code after a return statement is run. This is necessary as MLIR does not support a return statement from a nested region.
This code should be simplified when run with mem2reg and canonicalize
All reactions
-
👍 1