[DXIL] Add lowering for ceil (#87043)
Add lowering of llvm.ceil intrinsics to DXIL ops. Fixes #86984
This commit is contained in:
parent
ee3a302aba
commit
b42fa8645c
@ -292,6 +292,9 @@ def Round : DXILOpMapping<26, unary, int_roundeven,
|
||||
def Floor : DXILOpMapping<27, unary, int_floor,
|
||||
"Returns the largest integer that is less than or equal to the input.",
|
||||
[llvm_halforfloat_ty, LLVMMatchType<0>]>;
|
||||
def Ceil : DXILOpMapping<28, unary, int_ceil,
|
||||
"Returns the smallest integer that is greater than or equal to the input.",
|
||||
[llvm_halforfloat_ty, LLVMMatchType<0>]>;
|
||||
def Trunc : DXILOpMapping<29, unary, int_trunc,
|
||||
"Returns the specified value truncated to the integer component.",
|
||||
[llvm_halforfloat_ty, LLVMMatchType<0>]>;
|
||||
|
||||
20
llvm/test/CodeGen/DirectX/ceil.ll
Normal file
20
llvm/test/CodeGen/DirectX/ceil.ll
Normal file
@ -0,0 +1,20 @@
|
||||
; RUN: opt -S -dxil-op-lower < %s | FileCheck %s
|
||||
|
||||
; Make sure dxil operation function calls for ceil are generated for float and half.
|
||||
|
||||
define noundef float @ceil_float(float noundef %a) {
|
||||
entry:
|
||||
; CHECK:call float @dx.op.unary.f32(i32 28, float %{{.*}})
|
||||
%elt.ceil = call float @llvm.ceil.f32(float %a)
|
||||
ret float %elt.ceil
|
||||
}
|
||||
|
||||
define noundef half @ceil_half(half noundef %a) {
|
||||
entry:
|
||||
; CHECK:call half @dx.op.unary.f16(i32 28, half %{{.*}})
|
||||
%elt.ceil = call half @llvm.ceil.f16(half %a)
|
||||
ret half %elt.ceil
|
||||
}
|
||||
|
||||
declare half @llvm.ceil.f16(half)
|
||||
declare float @llvm.ceil.f32(float)
|
||||
10
llvm/test/CodeGen/DirectX/ceil_error.ll
Normal file
10
llvm/test/CodeGen/DirectX/ceil_error.ll
Normal file
@ -0,0 +1,10 @@
|
||||
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s
|
||||
|
||||
; DXIL operation ceil does not support double overload type
|
||||
; CHECK: LLVM ERROR: Invalid Overload Type
|
||||
|
||||
define noundef double @ceil_double(double noundef %a) {
|
||||
entry:
|
||||
%elt.ceil = call double @llvm.ceil.f64(double %a)
|
||||
ret double %elt.ceil
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user