Skip to content

Commit 746378e

Browse files
Add Subtarget Feature and test
1 parent a663a71 commit 746378e

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

llvm/lib/Target/AMDGPU/AMDGPU.td

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,12 @@ def FeaturePrngInst : SubtargetFeature<"prng-inst",
10941094
"Has v_prng_b32 instruction"
10951095
>;
10961096

1097+
def FeatureBVHDualInst : SubtargetFeature<"bvh-dual-inst",
1098+
"HasBVHDualInst",
1099+
"true",
1100+
"Has image_bvh_dual_intersect_ray instruction"
1101+
>;
1102+
10971103
//===------------------------------------------------------------===//
10981104
// Subtarget Features (options and debugging)
10991105
//===------------------------------------------------------------===//
@@ -1844,7 +1850,8 @@ def FeatureISAVersion12 : FeatureSet<
18441850
FeatureDPPSrc1SGPR,
18451851
FeatureMaxHardClauseLength32,
18461852
Feature1_5xVGPRs,
1847-
FeatureMemoryAtomicFAddF32DenormalSupport
1853+
FeatureMemoryAtomicFAddF32DenormalSupport,
1854+
FeatureBVHDualInst
18481855
]>;
18491856

18501857
def FeatureISAVersion12_Generic: FeatureSet<
@@ -2500,6 +2507,9 @@ def HasBitOp3Insts : Predicate<"Subtarget->hasBitOp3Insts()">,
25002507
def HasPrngInst : Predicate<"Subtarget->hasPrngInst()">,
25012508
AssemblerPredicate<(all_of FeaturePrngInst)>;
25022509

2510+
def HasBVHDualInst : Predicate<"Subtarget->hasBVHDualInst()">,
2511+
AssemblerPredicate<(all_of FeatureBVHDualInst)>;
2512+
25032513
def HasFP8ConversionScaleInsts : Predicate<"Subtarget->hasFP8ConversionScaleInsts()">,
25042514
AssemblerPredicate<(all_of FeatureFP8ConversionScaleInsts)>;
25052515

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7214,7 +7214,7 @@ bool AMDGPULegalizerInfo::legalizeBVHDualIntrinsic(MachineInstr &MI,
72147214
Register Offsets = MI.getOperand(9).getReg();
72157215
Register TDescr = MI.getOperand(10).getReg();
72167216

7217-
if (!AMDGPU::isGFX12Plus(ST)) {
7217+
if (!ST.hasBVHDualInst()) {
72187218
DiagnosticInfoUnsupported BadIntrin(B.getMF().getFunction(),
72197219
"intrinsic not supported on subtarget",
72207220
MI.getDebugLoc());

llvm/lib/Target/AMDGPU/GCNSubtarget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
228228
bool HasRestrictedSOffset = false;
229229
bool HasBitOp3Insts = false;
230230
bool HasPrngInst = false;
231+
bool HasBVHDualInst = false;
231232
bool HasPermlane16Swap = false;
232233
bool HasPermlane32Swap = false;
233234
bool HasVcmpxPermlaneHazard = false;
@@ -1364,6 +1365,8 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
13641365

13651366
bool hasPrngInst() const { return HasPrngInst; }
13661367

1368+
bool hasBVHDualInst() const { return HasBVHDualInst; }
1369+
13671370
/// Return the maximum number of waves per SIMD for kernels using \p SGPRs
13681371
/// SGPRs
13691372
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9456,7 +9456,7 @@ SDValue SITargetLowering::LowerINTRINSIC_W_CHAIN(SDValue Op,
94569456
assert(NodePtr.getValueType() == MVT::i64);
94579457
assert(RayDir.getValueType() == MVT::v3f32);
94589458

9459-
if (!AMDGPU::isGFX12Plus(*Subtarget)) {
9459+
if (!Subtarget->hasBVHDualInst()) {
94609460
emitRemovedIntrinsicError(DAG, DL, Op.getValueType());
94619461
return SDValue();
94629462
}

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.dual_intersect_ray.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: not --crash llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx1100 -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=ERR %s
3+
; RUN: not --crash llc -global-isel=1 -mtriple=amdgcn -mcpu=gfx1100 -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=ERR %s
24
; RUN: llc -global-isel=0 -march=amdgcn -mcpu=gfx1200 < %s | FileCheck -check-prefixes=GFX12-SDAG %s
35
; RUN: llc -global-isel=1 -march=amdgcn -mcpu=gfx1200 < %s | FileCheck -check-prefixes=GFX12-GISEL %s
46

57
declare {<10 x i32>, <3 x float>, <3 x float>} @llvm.amdgcn.image.bvh.dual.intersect.ray(i64, float, i8, <3 x float>, <3 x float>, <2 x i32>, <4 x i32>)
68

9+
; ERR: in function image_bvh_dual_intersect_ray{{.*}}intrinsic not supported on subtarget
710
define amdgpu_ps <10 x float> @image_bvh_dual_intersect_ray(i64 %node_ptr, float %ray_extent, float %ray_origin_x, float %ray_origin_y, float %ray_origin_z, float %ray_dir_x, float %ray_dir_y, float %ray_dir_z, <2 x i32> %offsets, <4 x i32> inreg %tdescr, ptr addrspace(1) %origin, ptr addrspace(1) %dir) {
811
; GFX12-SDAG-LABEL: image_bvh_dual_intersect_ray:
912
; GFX12-SDAG: ; %bb.0: ; %main_body

0 commit comments

Comments
 (0)