| Issue |
124086
|
| Summary |
[mlir][emitc] Missing parentheses when translate emitc._expression_
|
| Labels |
mlir,
mlir:emitc
|
| Assignees |
jacquesguan
|
| Reporter |
jacquesguan
|
In some case, translation generates wrong cpp code for `emitc._expression_`.
By example, the following case in `mlir/test/Target/Cpp/expressions.mlir`
```
func.func @parentheses_for_low_precedence(%arg0: i32, %arg1: i32, %arg2: i32) -> f32 {
%e = emitc._expression_ : f32 {
%a = emitc.add %arg0, %arg1 : (i32, i32) -> i32
%b = emitc.mul %a, %arg2 : (i32, i32) -> i32
%d = emitc.cast %b : i32 to f32
emitc.yield %d : f32
}
return %e : f32
}
```
It will be translate to
```
float parentheses_for_low_precedence(int32_t v1, int32_t v2, int32_t v3) {
return (float) (v1 + v2 * v3);
}
```
which misses the parentheses rounding the addition.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs