File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -2484,6 +2484,7 @@ bool LLVMToSPIRVBase::isKnownIntrinsic(Intrinsic::ID Id) {
2484
2484
case Intrinsic::dbg_label:
2485
2485
case Intrinsic::trap:
2486
2486
case Intrinsic::arithmetic_fence:
2487
+ case Intrinsic::isnan:
2487
2488
return true ;
2488
2489
default :
2489
2490
// Unknown intrinsics' declarations should always be translated
@@ -3118,6 +3119,11 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
3118
3119
}
3119
3120
return Op;
3120
3121
}
3122
+ case Intrinsic::isnan: {
3123
+ SPIRVType *Ty = transType (II->getType ());
3124
+ SPIRVValue *Op = transValue (II->getArgOperand (0 ), BB);
3125
+ return BM->addUnaryInst (OpIsNan, Ty, Op, BB);
3126
+ }
3121
3127
default :
3122
3128
if (BM->isUnknownIntrinsicAllowed (II))
3123
3129
return BM->addCallInst (
Original file line number Diff line number Diff line change
1
+ ; RUN: llvm-as %s -o %t.bc
2
+ ; RUN: llvm-spirv %t.bc -o %t.spv
3
+ ; RUN: llvm-spirv %t.spv --to-text -o %t.spt
4
+ ; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
5
+
6
+ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
7
+ ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-OCL
8
+ ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc --spirv-target-env=SPV-IR
9
+ ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-SPV
10
+
11
+ ; CHECK-SPIRV: IsNan
12
+ ; CHECK-LLVM-OCL: call spir_func i32 @_Z5isnanf(float 1.200000e+01)
13
+ ; CHECK-LLVM-SPV: call spir_func i32 @_Z13__spirv_IsNanf(float 1.200000e+01)
14
+
15
+ ; ModuleID = 'test.bc'
16
+ source_filename = "test.cpp"
17
+ target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
18
+ target triple = "spir64-unknown-unknown-unknown"
19
+
20
+ define spir_kernel void @test () {
21
+ entry:
22
+ %call = call i1 @llvm.isnan.f32 (float 1 .200000e+01 )
23
+ ret void
24
+ }
25
+
26
+ declare i1 @llvm.isnan.f32 (float )
27
+
28
+ !llvm.module.flags = !{!0 , !1 }
29
+ !opencl.spir.version = !{!2 }
30
+ !spirv.Source = !{!3 }
31
+
32
+ !0 = !{i32 1 , !"wchar_size" , i32 4 }
33
+ !1 = !{i32 7 , !"frame-pointer" , i32 2 }
34
+ !2 = !{i32 1 , i32 2 }
35
+ !3 = !{i32 4 , i32 100000 }
You can’t perform that action at this time.
0 commit comments