[all-commits] [llvm/llvm-project] f179e9: [mlir][emitc] Fix bug in ApplyOp translation (#155...
Gil Rapaport via All-commits
all-commits at lists.llvm.org
Tue Aug 26 00:39:14 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f179e98bc645a4dd5a0c7c6e0b05ca4562018771
https://github.com/llvm/llvm-project/commit/f179e98bc645a4dd5a0c7c6e0b05ca4562018771
Author: Gil Rapaport <gil.rapaport at mobileye.com>
Date: 2025-08-26 (Tue, 26 Aug 2025)
Changed paths:
M mlir/lib/Target/Cpp/TranslateToCpp.cpp
M mlir/test/Target/Cpp/expressions.mlir
Log Message:
-----------
[mlir][emitc] Fix bug in ApplyOp translation (#155171)
The translator emits `emitc.apply` incorrectly when the op is part of an
expression, as it prints the name of the operand instead of calling
emitOperand() which takes into account the expression being emitted,
leaving out the part of the expression feeding this op, e.g.
```mlir
func.func @foo(%a: i32, %p: !emitc.ptr<i32>) -> i32 {
%c = emitc.expression : i32 {
%e = emitc.sub %p, %a : (!emitc.ptr<i32>, i32) -> !emitc.ptr<i32>
%d = emitc.apply "*"(%e) : (!emitc.ptr<i32>) -> i32
emitc.yield %d : i32
}
return %c : i32
}
```
translates to:
```C
int32_t foo(int32_t v1, int32_t* v2) {
int32_t v3 = *v4;
return v3;
}
```
instead of:
```C
int32_t foo(int32_t v1, int32_t* v2) {
int32_t v3 = *(v2 - v1);
return v3;
}
```
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list