'arith.muli' op requires the same type for all operands and results
Open
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 624
- Forks
- 170
- PR merge metrics
- No merged PRs in 30d
Description
Here is a minimal reproducible code:
#include <stdint.h>
void foo(uint16_t *a, uint16_t len) {
uint16_t c = 1;
for (uint16_t i = 0; i < len; i++) {
c *= a[i];
a[i] = c;
}
}
"func.func"() ({
^bb0(%arg0: memref<?xi16>, %arg1: i16):
%0 = "arith.constant"() {value = 0 : index} : () -> index
%1 = "arith.constant"() {value = 1 : index} : () -> index
%2 = "arith.constant"() {value = 1 : i16} : () -> i16
%3 = "arith.index_cast"(%arg1) : (i16) -> index
%4 = "scf.for"(%0, %3, %1, %2) ({
^bb0(%arg2: index, %arg3: i16):
%5 = "memref.load"(%arg0, %arg2) : (memref<?xi16>, index) -> i16
%6 = "arith.extsi"(%5) : (i16) -> i32
%7 = "arith.muli"(%arg3, %6) : (i16, i32) -> i16
"memref.store"(%7, %arg0, %arg2) : (i16, memref<?xi16>, index) -> ()
"scf.yield"(%7) : (i16) -> ()
}) : (index, index, index, i16) -> i16
"func.return"() : () -> ()
}) {function_type = (memref<?xi16>, i16) -> (), llvm.linkage = #llvm.linkage<external>, sym_name = "foo"} : () -> ()
arith.extsi is unnecessary and actually triggers the error.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal C reproducer and its generated MLIR, focusing on the arith.extsi and arith.muli operations inside the scf.for body. Trace why the unnecessary extension produces mixed operand and result types, then verify that the reproducer no longer emits the invalid arith.muli operation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100