<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/128625>128625</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Cannot match add instruction with BinaryOperator
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cctry
</td>
</tr>
</table>
<pre>
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
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVc2O2zYQfprRZbAGPZQs-aCD7Y3RPQVoczcoibLY0KRAUuvu2xfkyllH2U3TFjAgkvPN3zc_Ft6rs5GyhmIPxWMmpjBYV7dtcC9ZY7uX-gnFBa9OBWXOKNCry6gljsJ7DBZbMYbJSRRao-g6VMYHN7VBWeNXwHZfBuVReQyDxNZ2Eq8qDMqk-34PdHwyPqC2doxo2LD5x3ZiChaBdntlPo8I_BG7F3NqhQ_AD3tlhHv5PEongnXAPwFV0RLQFvge2E71CFQBrZM60BahjO-IWj9fgO-A76RzPoG2CPwA_IBA9MdXNY4xVWPNQ5Pc3CcFfBdRbwq7lMCbPhQHEz_8l7wpf8skGr63HM0-AP90h1gqL1y11gRlJvl6h_JxQWgqZJA-FVKFVAkMsT79ZFJyyxIoE6pTwN5aoGq-CKADzufm7tzenbt7vuc3mUrYItAeu1vINwdJJpKsucmcDJMzUY_22H-U1JdB4tPv2CstY5tp9VUuEJ3slZHYeXvSthUajZ1MJ3tMjf9XQFUh5GxOsvpBDFSwlNu7ovXHIvpYxCNBKZrTZIy4yO4kus4hEGffiAMqildi4lxV37ylgGbAZgEoZgDdAOUCsJkB_Mbx_F6-y-5v9iqfpYs6cWC1PZ9j8_jBXuNIi4DG_jD2824YZKxKkG7ZVb8wYf-Y_GJu_o3Zn1H2P8z-jOj_avb78rxj5Z7WrKt5t-Vbkcl6XeYsL8q8KrOhLrfUr9fFpis7STljG0Zl36yrgtZ5wRjLVE2MCkZUsJzyvFxteLPtG8Fztm5YUVWQM3kRSq_iNltZd86U95Os11RtqMi0aKT26R-EyMgrJmlaUI-Zq6PSQzOdPeRMKx_8m5mggpb1QRhjA15EaIdlN71uqe_XfTY5XQ8hjD5uVjoCHc8qDFOzau0F6Jh27uvnYXT2T9kGoGMKygMd56ifa_o7AAD__6U2D7w">