Skip to content

Commit

Permalink
Merge pull request #652 from hvdijk/missing-gather-scatter
Browse files Browse the repository at this point in the history
[vecz] Handle missing gather/scatter functions.
  • Loading branch information
hvdijk authored Jan 22, 2025
2 parents 8f542b6 + 315a70b commit 98db5ed
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/compiler/vecz/source/transform/packetizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2642,12 +2642,14 @@ ValuePacket Packetizer::Impl::packetizeMemOp(MemOp &op) {
auto *gather =
createGather(Ctx, packetVecTy, ptrPacket[i], maskPacket[i], EVL,
op.getAlignment(), name);
PACK_FAIL_IF(!gather);
gather->insertBefore(op.getInstr()->getIterator());
results.push_back(gather);
} else {
auto *scatter =
createScatter(Ctx, dataPacket[i], ptrPacket[i], maskPacket[i], EVL,
op.getAlignment(), name);
PACK_FAIL_IF(!scatter);
scatter->insertBefore(op.getInstr()->getIterator());
results.push_back(scatter);
}
Expand Down
50 changes: 50 additions & 0 deletions modules/compiler/vecz/test/lit/llvm/packetize_i48.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
; Copyright (C) Codeplay Software Limited
;
; Licensed under the Apache License, Version 2.0 (the "License") with LLVM
; Exceptions; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
; License for the specific language governing permissions and limitations
; under the License.
;
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; RUN: veczc -k test -vecz-simd-width=4 -S < %s | FileCheck %s

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "spir64-unknown-unknown"

declare i64 @__mux_get_local_id(i32)

define spir_kernel void @test(ptr %0, ptr %1) {
entry:
%lid = tail call i64 @__mux_get_local_id(i32 0)
%ptr.0 = getelementptr i32, ptr %0, i64 %lid
%ptr.1 = getelementptr i32, ptr %1, i64 %lid
%val = load i48, ptr %ptr.0
store i48 %val, ptr %ptr.1
ret void
}

; CHECK-LABEL: define spir_kernel void @test
; CHECK: load i48
; CHECK-NOT: load i48
; CHECK: store i48
; CHECK-NOT: store i48

; CHECK-LABEL: define spir_kernel void @__vecz_v4_test
; CHECK: load i48
; CHECK: load i48
; CHECK: load i48
; CHECK: load i48
; CHECK-NOT: load i48
; CHECK: store i48
; CHECK: store i48
; CHECK: store i48
; CHECK: store i48
; CHECK-NOT: store i48

0 comments on commit 98db5ed

Please sign in to comment.