diff --git a/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp b/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp index 019bad82..6e1e6980 100644 --- a/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp +++ b/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp @@ -1,6 +1,6 @@ /*========================== begin_copyright_notice ============================ -Copyright (C) 2020-2021 Intel Corporation +Copyright (C) 2020-2023 Intel Corporation SPDX-License-Identifier: MIT @@ -305,7 +305,8 @@ static Value *createScalarToVectorValue(Value *Scalar, Type *ReferenceType, Instruction *InsertBefore) { if (isa(Scalar)) return UndefValue::get(ReferenceType); - else if (isa(Scalar->getType())) { + else if (isa(Scalar->getType()) && + isa(ReferenceType)) { auto Inner = getInnerPointerVectorNesting(ReferenceType); return new BitCastInst( Scalar, getTypeWithSingleElementVector(Scalar->getType(), Inner), diff --git a/GenXIntrinsics/test/Adaptors/sev_ptr_reader.ll b/GenXIntrinsics/test/Adaptors/sev_ptr_reader.ll new file mode 100644 index 00000000..e447ade3 --- /dev/null +++ b/GenXIntrinsics/test/Adaptors/sev_ptr_reader.ll @@ -0,0 +1,32 @@ +;=========================== begin_copyright_notice ============================ +; +; Copyright (C) 2023 Intel Corporation +; +; SPDX-License-Identifier: MIT +; +;============================ end_copyright_notice ============================= + +; UNSUPPORTED: llvm17, llvm18 +; RUN: opt %pass%GenXSPIRVReaderAdaptor -S < %s | FileCheck %s + +define internal void @foo(i32** "VCSingleElementVector"="1" %v) #0 { +entry: + ; CHECK: [[SEV:[^ ]+]] = bitcast <1 x i32*>* %v to i32** + ; CHECK: %ld.v = load i32*, i32** [[SEV]], align 8 + ; CHECK: %ld.ex = load i32, i32* %ld.v, align 4 + %ld.v = load i32*, i32** %v, align 8 + %ld.ex = load i32, i32* %ld.v, align 4 + ret void +} + +define internal "VCSingleElementVector"="2" i64*** @bar(i64** "VCSingleElementVector"="2" %in, i64*** "VCSingleElementVector"="2" %out) #0 { +entry: + ; CHECK: [[SEV:[^ ]+]] = bitcast <1 x i64**>* %out to i64*** + ; CHECK: [[SEVIN:[^ ]+]] = extractelement <1 x i64**> %in, i64 0 + ; CHECK: store i64** [[SEVIN]], i64*** [[SEV]], align 8 + store i64** %in, i64*** %out, align 8 + ; CHECK: ret <1 x i64**>* %out + ret i64*** %out +} + +attributes #0 = { "VCFunction" } diff --git a/GenXIntrinsics/test/Adaptors/sev_ptr_writer.ll b/GenXIntrinsics/test/Adaptors/sev_ptr_writer.ll new file mode 100644 index 00000000..3a15276e --- /dev/null +++ b/GenXIntrinsics/test/Adaptors/sev_ptr_writer.ll @@ -0,0 +1,29 @@ +;=========================== begin_copyright_notice ============================ +; +; Copyright (C) 2023 Intel Corporation +; +; SPDX-License-Identifier: MIT +; +;============================ end_copyright_notice ============================= + +; UNSUPPORTED: llvm17, llvm18 +; RUN: opt %pass%GenXSPIRVWriterAdaptor -S < %s | FileCheck %s + +define internal void @foo(<1 x i32*>* %v) #0 { +entry: + ; CHECK: %ld.v = load i32*, i32** %v, align 8 + ; CHECK: %ld.ex = load i32, i32* %ld.v, align 4 + %ld.v = load <1 x i32*>, <1 x i32*>* %v, align 8 + %ex = extractelement <1 x i32*> %ld.v, i32 0 + %ld.ex = load i32, i32* %ex, align 4 + ret void +} + +define internal <1 x i64**>* @bar(<1 x i64**> %in, <1 x i64**>* %out) #0 { +entry: + ; CHECK: store i64** %in, i64*** %out, align 8 + store <1 x i64**> %in, <1 x i64**>* %out, align 8 + ret <1 x i64**>* %out +} + +attributes #0 = { "VCFunction" }