Skip to content

[DirectX] scalarize the dx.isinf intrinsic #140638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ bool DirectXTTIImpl::isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
int OpdIdx) const {
switch (ID) {
case Intrinsic::dx_asdouble:
case Intrinsic::dx_isinf:
return OpdIdx == 0;
default:
return OpdIdx == -1;
Expand All @@ -43,6 +44,7 @@ bool DirectXTTIImpl::isTargetIntrinsicTriviallyScalarizable(
case Intrinsic::dx_firstbitshigh:
case Intrinsic::dx_firstbituhigh:
case Intrinsic::dx_frac:
case Intrinsic::dx_isinf:
case Intrinsic::dx_rsqrt:
case Intrinsic::dx_saturate:
case Intrinsic::dx_splitdouble:
Expand Down
24 changes: 20 additions & 4 deletions llvm/test/CodeGen/DirectX/isinf.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s
; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s

; Make sure dxil operation function calls for isinf are generated for float and half.

Expand All @@ -16,7 +16,23 @@ entry:
ret i1 %dx.isinf
}

; CHECK: attributes #[[#ATTR]] = {{{.*}} memory(none) {{.*}}}
define noundef <4 x i1> @isinf_half4(<4 x half> noundef %p0) {
entry:
; CHECK: call i1 @dx.op.isSpecialFloat.f16(i32 9, half
; CHECK: call i1 @dx.op.isSpecialFloat.f16(i32 9, half
; CHECK: call i1 @dx.op.isSpecialFloat.f16(i32 9, half
; CHECK: call i1 @dx.op.isSpecialFloat.f16(i32 9, half
%hlsl.isinf = call <4 x i1> @llvm.dx.isinf.v4f16(<4 x half> %p0)
ret <4 x i1> %hlsl.isinf
}

declare i1 @llvm.dx.isinf.f16(half)
declare i1 @llvm.dx.isinf.f32(float)
define noundef <3 x i1> @isinf_float3(<3 x float> noundef %p0) {
entry:
; CHECK: call i1 @dx.op.isSpecialFloat.f32(i32 9, float
; CHECK: call i1 @dx.op.isSpecialFloat.f32(i32 9, float
; CHECK: call i1 @dx.op.isSpecialFloat.f32(i32 9, float
%hlsl.isinf = call <3 x i1> @llvm.dx.isinf.v3f32(<3 x float> %p0)
ret <3 x i1> %hlsl.isinf
}

; CHECK: attributes #[[#ATTR]] = {{{.*}} memory(none) {{.*}}}