Skip to content

Commit b42fa86

Browse files
authored
[DXIL] Add lowering for ceil (#87043)
Add lowering of llvm.ceil intrinsics to DXIL ops. Fixes #86984
1 parent ee3a302 commit b42fa86

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

llvm/lib/Target/DirectX/DXIL.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ def Round : DXILOpMapping<26, unary, int_roundeven,
292292
def Floor : DXILOpMapping<27, unary, int_floor,
293293
"Returns the largest integer that is less than or equal to the input.",
294294
[llvm_halforfloat_ty, LLVMMatchType<0>]>;
295+
def Ceil : DXILOpMapping<28, unary, int_ceil,
296+
"Returns the smallest integer that is greater than or equal to the input.",
297+
[llvm_halforfloat_ty, LLVMMatchType<0>]>;
295298
def Trunc : DXILOpMapping<29, unary, int_trunc,
296299
"Returns the specified value truncated to the integer component.",
297300
[llvm_halforfloat_ty, LLVMMatchType<0>]>;

llvm/test/CodeGen/DirectX/ceil.ll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: opt -S -dxil-op-lower < %s | FileCheck %s
2+
3+
; Make sure dxil operation function calls for ceil are generated for float and half.
4+
5+
define noundef float @ceil_float(float noundef %a) {
6+
entry:
7+
; CHECK:call float @dx.op.unary.f32(i32 28, float %{{.*}})
8+
%elt.ceil = call float @llvm.ceil.f32(float %a)
9+
ret float %elt.ceil
10+
}
11+
12+
define noundef half @ceil_half(half noundef %a) {
13+
entry:
14+
; CHECK:call half @dx.op.unary.f16(i32 28, half %{{.*}})
15+
%elt.ceil = call half @llvm.ceil.f16(half %a)
16+
ret half %elt.ceil
17+
}
18+
19+
declare half @llvm.ceil.f16(half)
20+
declare float @llvm.ceil.f32(float)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s
2+
3+
; DXIL operation ceil does not support double overload type
4+
; CHECK: LLVM ERROR: Invalid Overload Type
5+
6+
define noundef double @ceil_double(double noundef %a) {
7+
entry:
8+
%elt.ceil = call double @llvm.ceil.f64(double %a)
9+
ret double %elt.ceil
10+
}

0 commit comments

Comments
 (0)