[all-commits] [llvm/llvm-project] efdb49: [InstCombine] Combine llvm.sin/llvm.cos libcall pa...

Kito Cheng via All-commits all-commits at lists.llvm.org
Tue Apr 28 02:56:08 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: efdb493e485ceaa7a80392de338b02d00e9b67e0
      https://github.com/llvm/llvm-project/commit/efdb493e485ceaa7a80392de338b02d00e9b67e0
  Author: Kito Cheng <kito.cheng at sifive.com>
  Date:   2026-04-28 (Tue, 28 Apr 2026)

  Changed paths:
    M clang/test/CodeGenOpenCL/builtins-f16.cl
    M llvm/lib/Target/README.txt
    M llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    M llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
    M llvm/test/Transforms/InstCombine/AMDGPU/tan.ll
    M llvm/test/Transforms/InstCombine/fdiv-cos-sin.ll
    M llvm/test/Transforms/InstCombine/fdiv-sin-cos.ll
    M llvm/test/Transforms/InstCombine/may-alias-errno.ll
    A llvm/test/Transforms/InstCombine/sincos-fpmath.ll
    A llvm/test/Transforms/InstCombine/sincos.ll

  Log Message:
  -----------
  [InstCombine] Combine llvm.sin/llvm.cos libcall pairs into llvm.sincos (#184760)

Teach InstCombine to recognize pairs of `llvm.sin(x)` and `llvm.cos(x)`
intrinsic calls that share the same argument and replace them with a
single `llvm.sincos(x)` call, extracting the individual results.

The optimization works in two phases:

1. **SimplifyLibCalls**: Convert `sin`/`cos` C library calls (e.g.
   `sinf`, `cosf`, `sin`, `cos`, `sinl`, `cosl`) into `llvm.sin` /
   `llvm.cos` intrinsics when the call does not access memory (i.e. does
   not set `errno`). This normalization step brings library calls into
   the same form as compiler-generated intrinsics.

2. **InstCombineCalls**: When visiting an `llvm.sin` or `llvm.cos`
   intrinsic, scan the users of the shared argument for a matching
   counterpart. If found, emit a single `llvm.sincos` call placed right
   after the argument definition, replace both original calls, and erase
   the matched instruction.

Also remove the completed sincos TODO from Target/README.txt.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list