Issue 60571
Summary Suboptimal code generation for 256-bit integer addition containing constant bits in arm64
Labels backend:AArch64
Assignees
Reporter aqjune
    Hello all,

It seems llc is producing suboptimal code for 256-bit int add when target is arm64.

https://godbolt.org/z/MfEMGKE8n
The command I used is `llc --mtriple=arm64-unknown-unknown -mcpu=neoverse-n1 -O3` (which is also used in the godbolt instance).

The above code evaluates [x3;x2;x1;x0] + [y3;y2;y1;0x1] and stores the results into the memory.

The generated code is
```
        adds    x8, x1, x4
 adcs    x9, x2, x5
        adc     x10, x3, x6
        adds x11, x0, #1
        adcs    x8, x8, xzr
        stp     x11, x8, [x7]
        adcs    x8, x9, xzr
        cinc    x9, x10, hs
 stp     x8, x9, [x7, #16]
        ret
```

.. which doesn't quite seem optimal.
I think it can be further reduced to:
```
adds x15, x0, #1
adcs x16, x1, x2
adcs x17, x3, x4
adc x18, x5, x6
stp x15, x16, [x30]
stp x17, x18, [x30, #16]
``` 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to