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 @@ -2467,6 +2467,7 @@ bool LLVMToSPIRVBase::isKnownIntrinsic(Intrinsic::ID Id) {
2467
2467
case Intrinsic::dbg_label:
2468
2468
case Intrinsic::trap:
2469
2469
case Intrinsic::arithmetic_fence:
2470
+ case Intrinsic::isnan:
2470
2471
return true ;
2471
2472
default :
2472
2473
// Unknown intrinsics' declarations should always be translated
@@ -3099,6 +3100,11 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
3099
3100
}
3100
3101
return Op;
3101
3102
}
3103
+ case Intrinsic::isnan: {
3104
+ SPIRVType *Ty = transType (II->getType ());
3105
+ SPIRVValue *Op = transValue (II->getArgOperand (0 ), BB);
3106
+ return BM->addUnaryInst (OpIsNan, Ty, Op, BB);
3107
+ }
3102
3108
default :
3103
3109
if (BM->isUnknownIntrinsicAllowed (II))
3104
3110
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