vporpo 0f6c18e8c6
[SandboxVec] Replace hard-coded context save() with transaction-save pass (#127690)
This patch implements a small region pass that saves the context's
state. The patch is now used in the default pipeline to save the context
state instead of the hard-coded call to Context::save().

The concept behind this is that the passes themselves should not have to
do the actual saving/restoring of the IR state, because that would make
it challenging to reorder them in the pipeline. Having separate
save/restore passes makes the transformation passes more composable as
parts of arbitrary pipelines.
2025-02-18 13:34:51 -08:00

33 lines
1.3 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -passes=sandbox-vectorizer -sbvec-vec-reg-bits=1024 -sbvec-allow-non-pow2 -sbvec-passes="seed-collection<tr-save,bottom-up-vec,tr-accept>" %s -S | FileCheck %s
declare void @foo()
define void @slice_seeds(ptr %ptr, float %val) {
; CHECK-LABEL: define void @slice_seeds(
; CHECK-SAME: ptr [[PTR:%.*]], float [[VAL:%.*]]) {
; CHECK-NEXT: [[PTR0:%.*]] = getelementptr float, ptr [[PTR]], i32 0
; CHECK-NEXT: [[PTR2:%.*]] = getelementptr float, ptr [[PTR]], i32 2
; CHECK-NEXT: [[LD2:%.*]] = load float, ptr [[PTR2]], align 4
; CHECK-NEXT: store float [[LD2]], ptr [[PTR2]], align 4
; CHECK-NEXT: call void @foo()
; CHECK-NEXT: [[VECL:%.*]] = load <2 x float>, ptr [[PTR0]], align 4
; CHECK-NEXT: store <2 x float> [[VECL]], ptr [[PTR0]], align 4
; CHECK-NEXT: ret void
;
%ptr0 = getelementptr float, ptr %ptr, i32 0
%ptr1 = getelementptr float, ptr %ptr, i32 1
%ptr2 = getelementptr float, ptr %ptr, i32 2
%ld2 = load float, ptr %ptr2
store float %ld2, ptr %ptr2
; This call blocks scheduling of all 3 stores.
call void @foo()
%ld0 = load float, ptr %ptr0
%ld1 = load float, ptr %ptr1
store float %ld0, ptr %ptr0
store float %ld1, ptr %ptr1
ret void
}