| Issue |
84152
|
| Summary |
[AArch64] there is redundant neg instruction for mull with complex type
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
vfdff
|
* **test**: https://gcc.godbolt.org/z/enYjsjGfE
```
define ptr @_ZNSt7complexIiEmLIiEERS0_RKS_IT_E(ptr noundef nonnull align 4 dereferenceable(8) %a,
ptr noundef nonnull align 4 dereferenceable(8) %b) align 2 {
entry:
%0 = load i32, ptr %a, align 4
%1 = load i32, ptr %b, align 4
%mul = mul nsw i32 %1, %0
%_M_imag = getelementptr inbounds i8, ptr %a, i64 4
%2 = load i32, ptr %_M_imag, align 4
%_M_imag.i = getelementptr inbounds i8, ptr %b, i64 4
%3 = load i32, ptr %_M_imag.i, align 4
%mul3 = mul nsw i32 %3, %2
%sub = sub nsw i32 %mul, %mul3
%mul6 = mul nsw i32 %3, %0
%mul9 = mul nsw i32 %2, %1
%add = add nsw i32 %mul6, %mul9
store i32 %add, ptr %_M_imag, align 4
store i32 %sub, ptr %a, align 4
ret ptr %a
}
```
* **llvm**: transform the madd into fmls, then the **neg instruction** is redundant
```
std::complex<int>& std::complex<int>::operator*=<int>(std::complex<int> const&): // @std::complex<int>& std::complex<int>::operator*=<int>(std::complex<int> const&)
ldp w11, w8, [x0]
ldp w10, w9, [x1]
mul w12, w9, w8
mul w8, w8, w10
madd w8, w9, w11, w8
neg w13, w12
madd w9, w10, w11, w13 ; w9 = w10 * w11 + w13 = w9 = w10 * w11 - w12 = w10 * w11 - w9 * w8 = fmls w10 * w11, w9, 28
stp w9, w8, [x0]
ret
```
* the IR is simlplied from https://gcc.godbolt.org/z/fPnnxGhb3
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs