Commit 0ebf44c
committed
[MLIR][EmitC][cf] Bugfix: correctly inline emitc.expression op in the emitted if condition of a cf.cond_br
Running `mlir-translate -mlir-to-cpp -declare-variables-at-top input.mlir` with `input.mlir` as
```
module {
emitc.func @f(%0 : i32, %1 : i32) {
%2 = expression : i1 {
%3 = cmp lt, %0, %1 : (i32, i32) -> i1
yield %3 : i1
}
cf.cond_br %2, ^bb1, ^bb1
^bb1: // 2 preds: ^bb0, ^bb0
return
}
}
```
doesn't inline the expression %2 and generates a use of an undeclared variable in the generated if:
```
void f(int32_t v1, int32_t v2) {
if (v3) {
goto label2;
} else {
goto label2;
}
label2:
return;
}
```1 parent ff80bdc commit 0ebf44c
File tree
2 files changed
+23
-2
lines changed- mlir
- lib/Target/Cpp
- test/Target/Cpp
2 files changed
+23
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
616 | | - | |
617 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
618 | 620 | | |
619 | 621 | | |
620 | 622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
0 commit comments