llvm-project/llvm/test/CodeGen/DirectX/ddx_coarse-errors.ll
Alexander Johnston 76f1949cfa
[HLSL] Implement the fwidth intrinsic for DXIL and SPIR-V target (#161378)
Adds the fwidth intrinsic for HLSL.
The DXIL path only requires modification to the hlsl headers.
The SPIRV path implements the OpFwidth builtin in Clang and instruction
selection for the OpFwidth instruction in LLVM.
Also adds shader stage tests to the ddx_coarse and ddy_coarse
instructions used by fwidth.

Closes #99120

---------

Co-authored-by: Alexander Johnston <alexander.johnston@amd.com>
2025-11-20 07:38:32 -05:00

30 lines
1.2 KiB
LLVM

; RUN: not opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s 2>&1 | FileCheck --check-prefixes=CHECK-TYPE %s
; RUN: not opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-compute %s 2>&1 | FileCheck --check-prefixes=CHECK-STAGE %s
; DXIL operation ddx.coarse does not support double overload type
; CHECK-TYPE: in function ddx.coarse
; CHECK-TYPE-SAME: Cannot create DerivCoarseX operation: Invalid overload type
; Function Attrs: noinline nounwind optnone
define noundef double @ddx.coarse_double(double noundef %a) #0 {
entry:
%a.addr = alloca double, align 8
store double %a, ptr %a.addr, align 8
%0 = load double, ptr %a.addr, align 8
%dx.ddx.coarse = call double @llvm.dx.ddx.coarse.f64(double %0)
ret double %dx.ddx.coarse
}
; DXIL operation ddx.coarse does not support compute shader stage
; CHECK-STAGE: in function ddx.coarse
; CHECK-STAGE-SAME: Cannot create DerivCoarseX operation: Invalid stage
; Function Attrs: noinline nounwind optnone
define noundef float @ddx.coarse_float(float noundef %a) #0 {
entry:
%a.addr = alloca float, align 8
store float %a, ptr %a.addr, align 8
%0 = load float, ptr %a.addr, align 8
%dx.ddx.coarse = call float @llvm.dx.ddx.coarse.f32(float %0)
ret float %dx.ddx.coarse
}