llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.98k stars 11.95k forks source link

[AArch64][GlobalISel] Improve i128 mul generation #115512

Open davemgreen opened 2 hours ago

davemgreen commented 2 hours ago

i128 multiplies under GlobalISel could be producing more madds if it reassociated the add. https://godbolt.org/z/Wr1r5ez1G

SDAG

        umulh   x8, x0, x2
        madd    x8, x0, x3, x8
        mul     x0, x0, x2
        madd    x1, x1, x2, x8
        ret

GISel

        mul     x9, x0, x3
        mul     x8, x0, x2
        umulh   x10, x0, x2
        madd    x9, x1, x2, x9
        mov     x0, x8
        add     x1, x9, x10
        ret
llvmbot commented 2 hours ago

@llvm/issue-subscribers-backend-aarch64

Author: David Green (davemgreen)

i128 multiplies under GlobalISel could be producing more madds if it reassociated the add. https://godbolt.org/z/Wr1r5ez1G SDAG ``` umulh x8, x0, x2 madd x8, x0, x3, x8 mul x0, x0, x2 madd x1, x1, x2, x8 ret ``` GISel ``` mul x9, x0, x3 mul x8, x0, x2 umulh x10, x0, x2 madd x9, x1, x2, x9 mov x0, x8 add x1, x9, x10 ret ```
arsenm commented 2 hours ago

I think the multiply splitting needs work, I started #97194 but don't have time to get back to it