Skip to content
Open
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
3 changes: 2 additions & 1 deletion lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,8 @@ SPIRVValue *LLVMToSPIRVBase::transUnaryInst(UnaryInstruction *U,
} else {
BOC = OpCrossWorkgroupCastToPtrINTEL;
}
} else if (isa<ConstantPointerNull>(Cast->getPointerOperand())) {
} else if (isa<ConstantPointerNull>(Cast->getPointerOperand()) &&
SrcAddrSpace != SPIRAS_Generic) {
SPIRVType *TransTy = transScavengedType(U);
return BM->addNullConstant(bcast<SPIRVTypePointer>(TransTy));
} else {
Expand Down
4 changes: 2 additions & 2 deletions test/SpecConstants/keep-tracked-const.ll
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ target triple = "spir64-unknown-unknown"
; CHECK: Constant [[#Int8]] [[#]] 1
; CHECK: Constant [[#Int8]] [[#]] 0

; CHECK: Constant [[#Int32]] [[#]] 0
; CHECK: Constant [[#Int32]] [[#]] 1
; CHECK-DAG: Constant [[#Int32]] [[#]] 1
; CHECK-DAG: Constant [[#Int32]] [[#]] 0

; CHECK-LLVM: %conv17.i = sext i8 1 to i64

Expand Down
18 changes: 18 additions & 0 deletions test/addrspacecast_generic_null.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; RUN: llvm-spirv %s -o %t.spv
; RUN: spirv-dis %t.spv | FileCheck %s

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
target triple = "spir64-unknown-unknown"

; Test that addrspacecast of generic null pointer generates GenericCastToPtr
; instruction in SPIR-V.

; CHECK: %_ptr_Workgroup_uchar = OpTypePointer Workgroup %uchar
; CHECK: %[[NULL:[0-9]+]] = OpConstantNull %_ptr_Generic_uchar
; CHECK: %[[CAST:[0-9]+]] = OpGenericCastToPtr %_ptr_Workgroup_uchar %[[NULL]]
; CHECK: OpPtrEqual %bool %[[CAST]]

define spir_kernel void @bar_generic_null(ptr addrspace(3) %arg) {
%expr = icmp eq ptr addrspace(3) addrspacecast (ptr addrspace(4) null to ptr addrspace(3)), %arg
ret void
}
Loading