[all-commits] [llvm/llvm-project] 06f7cd: [HLSL][DirectX] Implement HLSL `mul` function and ...

Deric C. via All-commits all-commits at lists.llvm.org
Fri Mar 6 13:32:31 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 06f7cd439c9114b64cd134f3c42639dfb94ae4df
      https://github.com/llvm/llvm-project/commit/06f7cd439c9114b64cd134f3c42639dfb94ae4df
  Author: Deric C. <cheung.deric at gmail.com>
  Date:   2026-03-06 (Fri, 06 Mar 2026)

  Changed paths:
    M clang/include/clang/Basic/Builtins.td
    M clang/lib/CodeGen/CGHLSLBuiltins.cpp
    M clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
    M clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
    M clang/lib/Headers/hlsl/hlsl_intrinsics.h
    M clang/lib/Sema/SemaHLSL.cpp
    A clang/test/CodeGenHLSL/builtins/mul.hlsl
    A clang/test/SemaHLSL/BuiltIns/mul-errors.hlsl
    M llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
    A llvm/test/CodeGen/DirectX/matrix-multiply.ll

  Log Message:
  -----------
  [HLSL][DirectX] Implement HLSL `mul` function and DXIL lowering of `llvm.matrix.multiply` (#184882)

Fixes #99138

- Defines a `__builtin_hlsl_mul` clang builtin in `Builtins.td`.
- Links the `__builtin_hlsl_mul` clang builtin with
`hlsl_alias_intrinsics.h` under the name `mul` for matrix cases
- Implement scalar and vector elementwise multiplication cases of the
`mul` function in `hlsl_intrinsics.h` and `hlsl_intrinsic_helpers.h`
- Adds sema for `__builtin_hlsl_mul` to `CheckBuiltinFunctionCall` in
`SemaHLSL.cpp`
- Adds codegen for `__builtin_hlsl_mul` to `EmitHLSLBuiltinExpr` in
`CGHLSLBuiltins.cpp`
- Vector-vector cases lower to `dot` (except double vectors, which
expands to scalar multiply-adds).
- Matrix-matrix, matrix-vector, and vector-matrix multiplication lower
to the `llvm.matrix.multiply` intrinsic
- Adds codegen tests to `clang/test/CodeGenHLSL/builtins/mul.hlsl`
- Adds sema tests to `clang/test/SemaHLSL/BuiltIns/mul-errors.hlsl`
- Implements lowering of the `llvm.matrix.multiply` intrinsic to DXIL in
`DXILIntrinsicExpansion.cpp`

Note: Currently the SPIRV backend does not support row-major matrix
memory layouts when lowering matrix multiply, and just assumes
column-major layout. Therefore this PR also makes the DirectX backend
only assume column-major layout. Implementing support for row-major
order shall be done in a separate PR. (Tracked by
https://github.com/llvm/llvm-project/issues/184906)

This PR locally passes the `mul` offload tests in both DirectX 12 and
Vulkan: https://github.com/llvm/offload-test-suite/pull/941

Assisted-by: claude-opus-4.6



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