[clang] [llvm] [InstCombine] Combine llvm.sin/llvm.cos libcall pairs into llvm.sincos (PR #184760)

via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 27 21:46:28 PDT 2026


Andarwinux wrote:

I tested this PR, and for libmvec and AMDLIBM, sin and cos are indeed combined into sincos, missing the opportunity to vectorize them into vector sin and vector cos.

```
$ ./clang -S -O3 -march=znver3 -fno-math-errno -fveclib=AMDLIBM test.c
$ cat test.s|grep sin
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
$ clang -S -O3 -march=znver3 -fno-math-errno -fveclib=AMDLIBM test.c
$ cat test.s|grep sin
        callq   amd_vrs8_sinf at PLT
        callq   sincosf at PLT
        .addrsig_sym amd_vrs4_sinf
        .addrsig_sym amd_vrs8_sinf
        .addrsig_sym amd_vrs16_sinf
$ ./clang -S -O3 -march=znver3 -fno-math-errno -fveclib=libmvec test.c
$ cat test.s|grep sin
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
        callq   sincosf at PLT
$ clang -S -O3 -march=znver3 -fno-math-errno -fveclib=libmvec test.c
$ cat test.s|grep sin
        callq   _ZGVdN8v_sinf at PLT
        callq   sincosf at PLT
        .addrsig_sym _ZGVbN4v_sinf
        .addrsig_sym _ZGVdN8v_sinf
```

https://github.com/llvm/llvm-project/pull/184760


More information about the cfe-commits mailing list