Issue |
128625
|
Summary |
Cannot match add instruction with BinaryOperator
|
Labels |
new issue
|
Assignees |
|
Reporter |
cctry
|
I am writing a simple pass to capture all add instructions.
This is the code within the BB/Inst loop.
```
auto *BinOp = dyn_cast<BinaryOperator>(Inst);
if (!BinOp) {
llvm::errs() << "Skipping non-binary instruction: " << *Inst << "\n";
llvm::errs() << "isBinaryOp: " << Inst->isBinaryOp() << "\n";
continue;
}
```
I am testing it with this function.
```
int8_t foo(int8_t a, int8_t b, int8_t c, int8_t d) {
int8_t e = c + d;
int8_t f = a + b;
return e + f;
}
```
The IR file is like
```
define dso_local noundef signext i8 @foo(i8 noundef signext %0, i8 noundef signext %1, i8 noundef signext %2, i8 noundef signext %3) local_unnamed_addr #0 {
%5 = add i8 %1, %0
%6 = add i8 %5, %2
%7 = add i8 %6, %3
ret i8 %7
}
```
However, the logging shows that no add instructions pass the filter.
```
Skipping non-binary instruction: %5 = add i8 %1, %0
isBinaryOp: 0
Skipping non-binary instruction: %6 = add i8 %5, %2
isBinaryOp: 0
Skipping non-binary instruction: %7 = add i8 %6, %3
isBinaryOp: 0
Skipping non-binary instruction: ret i8 %7
isBinaryOp: 0
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs