llvm / llvm-project

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

[LoongArch] Backend Optimizers too aggressive for SIMD, causing worsen codegen #100907

Open trcrsired opened 1 month ago

trcrsired commented 1 month ago

I tried to check the assembly output for loongarch for my sha512 algorithms: My GCC being here: https://github.com/trcrsired/gcc-releases/releases My LLVM builds being here. https://github.com/trcrsired/llvm-releases/releases

clang++ -S sha512.cc -I../../include -std=c++26 -o sha512_loongarch64_clang.s --target=loongarch64-linux-gnu -O3 --sysroot=$HOME/toolchains/x86_64-generic-linux-gnu/loongarch64-linux-gnu

https://github.com/cppfastio/fast_io/blob/next/benchmark/0012.isa/sha512_loongarch64_clang.s

clang++ -S sha512.cc -I../../include -std=c++26 -o sha512_loongarch64_clang.s --target=loongarch64-linux-gnu -O3 --sysroot=$HOME/toolchains/x86_64-generic-linux-gnu/loongarch64-linux-gnu -msimd=none

https://github.com/cppfastio/fast_io/blob/next/benchmark/0012.isa/sha512_loongarch64_clang_nosimd.s

The simd optimizer for the loongarch backend seems too aggressive, while this issue does not exist for aarch64 or x86_64 with APX.

trcrsired commented 1 month ago

@Ami-zhang