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

Conversation

spall
Copy link
Contributor

@spall spall commented May 19, 2025

The DXIL IsInf op only takes scalars.
Closes #140577

@llvmbot
Copy link
Member

llvmbot commented May 19, 2025

@llvm/pr-subscribers-backend-directx

Author: Sarah Spall (spall)

Changes

The DXIL IsInf op only takes scalars.
Closes #140577


Full diff: https://github.com/llvm/llvm-project/pull/140638.diff

2 Files Affected:

  • (modified) llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp (+2)
  • (modified) llvm/test/CodeGen/DirectX/isinf.ll (+20-4)
diff --git a/llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp b/llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp
index 94ebe07d3783b..e426c5249f930 100644
--- a/llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp
+++ b/llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp
@@ -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;
@@ -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:
diff --git a/llvm/test/CodeGen/DirectX/isinf.ll b/llvm/test/CodeGen/DirectX/isinf.ll
index 2bd83e94b9708..461553b533ae1 100644
--- a/llvm/test/CodeGen/DirectX/isinf.ll
+++ b/llvm/test/CodeGen/DirectX/isinf.ll
@@ -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.
 
@@ -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) {{.*}}}

@spall spall merged commit 2a1af50 into llvm:main May 20, 2025
14 checks passed
kostasalv pushed a commit to kostasalv/llvm-project that referenced this pull request May 21, 2025
The DXIL IsInf op only takes scalars.
Closes llvm#140577
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
The DXIL IsInf op only takes scalars.
Closes llvm#140577
ajaden-codes pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 6, 2025
The DXIL IsInf op only takes scalars.
Closes llvm#140577
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DirectX] The dx.isinf intrinsic is not being scalarized
4 participants