https://github.com/lukel97 updated https://github.com/llvm/llvm-project/pull/241183
>From aa921bf73bebe494f66eb923700eba9aeb427836 Mon Sep 17 00:00:00 2001 From: Luke Lau <[email protected]> Date: Wed, 11 Nov 2026 16:48:58 +0800 Subject: [PATCH 1/2] [llubi] Add support for vp.load and vp.store These follow the semantics of llvm.masked.load/llvm.masked.store, just with a EVL-specific mask, so it reuses their code. The tests mostly follow the same format too. The one extra-bit of immediate UB is that EVL > num vector elements is immediate UB, so that's handled explicitly. --- llvm/test/tools/llubi/intr_vp_load.ll | 39 ++++++++++++ llvm/test/tools/llubi/intr_vp_load_ub.ll | 74 +++++++++++++++++++++++ llvm/test/tools/llubi/intr_vp_store.ll | 31 ++++++++++ llvm/test/tools/llubi/intr_vp_store_ub.ll | 62 +++++++++++++++++++ llvm/tools/llubi/lib/Interpreter.cpp | 48 ++++++++++++++- 5 files changed, 251 insertions(+), 3 deletions(-) create mode 100644 llvm/test/tools/llubi/intr_vp_load.ll create mode 100644 llvm/test/tools/llubi/intr_vp_load_ub.ll create mode 100644 llvm/test/tools/llubi/intr_vp_store.ll create mode 100644 llvm/test/tools/llubi/intr_vp_store_ub.ll diff --git a/llvm/test/tools/llubi/intr_vp_load.ll b/llvm/test/tools/llubi/intr_vp_load.ll new file mode 100644 index 0000000000000..bca4f759fce63 --- /dev/null +++ b/llvm/test/tools/llubi/intr_vp_load.ll @@ -0,0 +1,39 @@ +; NOTE: Assertions have been autogenerated by utils/update_llubi_test_checks.py UTC_ARGS: --version 6 +; RUN: llubi --verbose --vscale=2 < %s 2>&1 | FileCheck %s + +@a = global [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16 + +define void @main() { + %load_all = call <4 x i32> @llvm.vp.load(ptr @a, <4 x i1> splat (i1 true), i32 4) + %load_evl = call <4 x i32> @llvm.vp.load(ptr @a, <4 x i1> splat (i1 true), i32 2) + %load_mask = call <4 x i32> @llvm.vp.load(ptr @a, <4 x i1> <i1 true, i1 false, i1 true, i1 true>, i32 3) + %load_none = call <4 x i32> @llvm.vp.load(ptr poison, <4 x i1> splat (i1 true), i32 0) + + ; Lanes at or past %evl are disabled even if their mask lane is poison, as + ; for a mask computed from the result of an earlier vp.load. + %load_poison_tail = call <4 x i32> @llvm.vp.load(ptr @a, <4 x i1> <i1 true, i1 true, i1 poison, i1 poison>, i32 2) + + ; Only enabled lanes need to be in bounds. %tail isn't aligned to the ABI + ; alignment of <4 x i32>, so it needs an explicit align. + %tail = getelementptr i32, ptr @a, i64 2 + %load_tail = call <4 x i32> @llvm.vp.load(ptr align 4 %tail, <4 x i1> splat (i1 true), i32 2) + + ; Without an align attribute the pointer must have the ABI alignment of + ; <4 x i32>, but only if a lane is enabled. + %load_none_misaligned = call <4 x i32> @llvm.vp.load(ptr %tail, <4 x i1> splat (i1 true), i32 0) + + %load_scalable = call <vscale x 2 x i32> @llvm.vp.load(ptr @a, <vscale x 2 x i1> splat (i1 true), i32 3) + ret void +} +; CHECK: Entering function: main +; CHECK-NEXT: %load_all = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr @a, <4 x i1> splat (i1 true), i32 4) => { i32 0, i32 1, i32 2, i32 3 } +; CHECK-NEXT: %load_evl = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr @a, <4 x i1> splat (i1 true), i32 2) => { i32 0, i32 1, poison, poison } +; CHECK-NEXT: %load_mask = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr @a, <4 x i1> <i1 true, i1 false, i1 true, i1 true>, i32 3) => { i32 0, poison, i32 2, poison } +; CHECK-NEXT: %load_none = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr poison, <4 x i1> splat (i1 true), i32 0) => { poison, poison, poison, poison } +; CHECK-NEXT: %load_poison_tail = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr @a, <4 x i1> <i1 true, i1 true, i1 poison, i1 poison>, i32 2) => { i32 0, i32 1, poison, poison } +; CHECK-NEXT: %tail = getelementptr i32, ptr @a, i64 2 => ptr 0x18 [@a + 8] +; CHECK-NEXT: %load_tail = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr align 4 %tail, <4 x i1> splat (i1 true), i32 2) => { i32 2, i32 3, poison, poison } +; CHECK-NEXT: %load_none_misaligned = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr %tail, <4 x i1> splat (i1 true), i32 0) => { poison, poison, poison, poison } +; CHECK-NEXT: %load_scalable = call <vscale x 2 x i32> @llvm.vp.load.nxv2i32.p0(ptr @a, <vscale x 2 x i1> splat (i1 true), i32 3) => { i32 0, i32 1, i32 2, poison } +; CHECK-NEXT: ret void +; CHECK-NEXT: Exiting function: main diff --git a/llvm/test/tools/llubi/intr_vp_load_ub.ll b/llvm/test/tools/llubi/intr_vp_load_ub.ll new file mode 100644 index 0000000000000..49d1bdadb4a4e --- /dev/null +++ b/llvm/test/tools/llubi/intr_vp_load_ub.ll @@ -0,0 +1,74 @@ +; RUN: not llubi --verbose --entry-function=evl_too_large < %s 2>&1 | FileCheck %s --check-prefix=EVL +; RUN: not llubi --verbose --vscale=2 --entry-function=evl_too_large_scalable < %s 2>&1 | FileCheck %s --check-prefix=EVL-SCALABLE +; RUN: not llubi --verbose --entry-function=poison_evl < %s 2>&1 | FileCheck %s --check-prefix=POISON-EVL +; RUN: not llubi --verbose --entry-function=poison_mask_lane < %s 2>&1 | FileCheck %s --check-prefix=POISON-MASK-LANE +; RUN: not llubi --verbose --entry-function=out_of_bounds < %s 2>&1 | FileCheck %s --check-prefix=OOB +; RUN: not llubi --verbose --entry-function=misaligned < %s 2>&1 | FileCheck %s --check-prefix=MISALIGNED + +@a = global [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16 + +define void @evl_too_large() { +; EVL: Entering function: evl_too_large +; EVL-NEXT: Stacktrace: +; EVL-NEXT: #0 %r = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr @a, <4 x i1> splat (i1 true), i32 5) at @evl_too_large <stdin>:{{[0-9]+}} +; EVL-NEXT: Immediate UB detected: llvm.vp.load with explicit vector length 5 greater than the number of elements 4. +; EVL-NEXT: error: Execution of function 'evl_too_large' failed. + %r = call <4 x i32> @llvm.vp.load(ptr @a, <4 x i1> splat (i1 true), i32 5) + ret void +} + +define void @evl_too_large_scalable() { +; EVL-SCALABLE: Entering function: evl_too_large_scalable +; EVL-SCALABLE-NEXT: Stacktrace: +; EVL-SCALABLE-NEXT: #0 %r = call <vscale x 2 x i32> @llvm.vp.load.nxv2i32.p0(ptr @a, <vscale x 2 x i1> splat (i1 true), i32 5) at @evl_too_large_scalable <stdin>:{{[0-9]+}} +; EVL-SCALABLE-NEXT: Immediate UB detected: llvm.vp.load with explicit vector length 5 greater than the number of elements 4. +; EVL-SCALABLE-NEXT: error: Execution of function 'evl_too_large_scalable' failed. + %r = call <vscale x 2 x i32> @llvm.vp.load(ptr @a, <vscale x 2 x i1> splat (i1 true), i32 5) + ret void +} + +define void @poison_evl() { +; POISON-EVL: Entering function: poison_evl +; POISON-EVL-NEXT: Stacktrace: +; POISON-EVL-NEXT: #0 %r = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr @a, <4 x i1> splat (i1 true), i32 poison) at @poison_evl <stdin>:{{[0-9]+}} +; POISON-EVL-NEXT: Immediate UB detected: llvm.vp.load with poison explicit vector length. +; POISON-EVL-NEXT: error: Execution of function 'poison_evl' failed. + %r = call <4 x i32> @llvm.vp.load(ptr @a, <4 x i1> splat (i1 true), i32 poison) + ret void +} + +define void @poison_mask_lane() { +; POISON-MASK-LANE: Entering function: poison_mask_lane +; POISON-MASK-LANE-NEXT: Stacktrace: +; POISON-MASK-LANE-NEXT: #0 %r = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr @a, <4 x i1> <i1 true, i1 poison, i1 false, i1 false>, i32 2) at @poison_mask_lane <stdin>:{{[0-9]+}} +; POISON-MASK-LANE-NEXT: Immediate UB detected: Poison mask lane in llvm.vp.load. +; POISON-MASK-LANE-NEXT: error: Execution of function 'poison_mask_lane' failed. + %r = call <4 x i32> @llvm.vp.load(ptr @a, <4 x i1> <i1 true, i1 poison, i1 false, i1 false>, i32 2) + ret void +} + +define void @out_of_bounds() { +; OOB: Entering function: out_of_bounds +; OOB-NEXT: %tail = getelementptr i32, ptr @a, i64 2 => ptr 0x18 [@a + 8] +; OOB-NEXT: Stacktrace: +; OOB-NEXT: #0 %r = call <4 x i32> @llvm.vp.load.v4i32.p0(ptr align 4 %tail, <4 x i1> splat (i1 true), i32 3) at @out_of_bounds <stdin>:{{[0-9]+}} +; OOB-NEXT: Immediate UB detected: Memory access is out of bounds. Accessed size: 4, Address: 0x20, Object base: 0x10, Object size: 16. +; OOB-NEXT: error: Execution of function 'out_of_bounds' failed. + %tail = getelementptr i32, ptr @a, i64 2 + %r = call <4 x i32> @llvm.vp.load(ptr align 4 %tail, <4 x i1> splat (i1 true), i32 3) + ret void +} + +; Without an align attribute the pointer must have the ABI alignment of +; <2 x i32>, so the misaligned pointer is poison. +define void @misaligned() { +; MISALIGNED: Entering function: misaligned +; MISALIGNED-NEXT: %p = getelementptr i32, ptr @a, i64 1 => ptr 0x14 [@a + 4] +; MISALIGNED-NEXT: Stacktrace: +; MISALIGNED-NEXT: #0 %r = call <2 x i32> @llvm.vp.load.v2i32.p0(ptr %p, <2 x i1> splat (i1 true), i32 1) at @misaligned <stdin>:{{[0-9]+}} +; MISALIGNED-NEXT: Immediate UB detected: Invalid memory access with a poison pointer. +; MISALIGNED-NEXT: error: Execution of function 'misaligned' failed. + %p = getelementptr i32, ptr @a, i64 1 + %r = call <2 x i32> @llvm.vp.load(ptr %p, <2 x i1> splat (i1 true), i32 1) + ret void +} diff --git a/llvm/test/tools/llubi/intr_vp_store.ll b/llvm/test/tools/llubi/intr_vp_store.ll new file mode 100644 index 0000000000000..6edd00a904049 --- /dev/null +++ b/llvm/test/tools/llubi/intr_vp_store.ll @@ -0,0 +1,31 @@ +; NOTE: Assertions have been autogenerated by utils/update_llubi_test_checks.py UTC_ARGS: --version 6 +; RUN: llubi --verbose --vscale=2 < %s 2>&1 | FileCheck %s + +@a = global [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16 +@c = constant [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16 + +define void @main() { + call void @llvm.vp.store(<4 x i32> <i32 10, i32 11, i32 12, i32 13>, ptr @a, <4 x i1> <i1 true, i1 false, i1 true, i1 true>, i32 3) + %after_partial = load <4 x i32>, ptr @a + + ; Lanes at or past %evl are disabled even if their mask lane is poison. + call void @llvm.vp.store(<4 x i32> splat (i32 20), ptr @a, <4 x i1> <i1 true, i1 poison, i1 poison, i1 poison>, i32 1) + %after_poison_tail = load <4 x i32>, ptr @a + + ; Disabled lanes are not accessed, so constant memory is fine. + call void @llvm.vp.store(<4 x i32> poison, ptr @c, <4 x i1> splat (i1 true), i32 0) + + call void @llvm.vp.store(<vscale x 2 x i32> splat (i32 30), ptr @a, <vscale x 2 x i1> splat (i1 true), i32 3) + %after_scalable = load <4 x i32>, ptr @a + ret void +} +; CHECK: Entering function: main +; CHECK-NEXT: call void @llvm.vp.store.v4i32.p0(<4 x i32> <i32 10, i32 11, i32 12, i32 13>, ptr @a, <4 x i1> <i1 true, i1 false, i1 true, i1 true>, i32 3) +; CHECK-NEXT: %after_partial = load <4 x i32>, ptr @a, align 16 => { i32 10, i32 1, i32 12, i32 3 } +; CHECK-NEXT: call void @llvm.vp.store.v4i32.p0(<4 x i32> splat (i32 20), ptr @a, <4 x i1> <i1 true, i1 poison, i1 poison, i1 poison>, i32 1) +; CHECK-NEXT: %after_poison_tail = load <4 x i32>, ptr @a, align 16 => { i32 20, i32 1, i32 12, i32 3 } +; CHECK-NEXT: call void @llvm.vp.store.v4i32.p0(<4 x i32> poison, ptr @c, <4 x i1> splat (i1 true), i32 0) +; CHECK-NEXT: call void @llvm.vp.store.nxv2i32.p0(<vscale x 2 x i32> splat (i32 30), ptr @a, <vscale x 2 x i1> splat (i1 true), i32 3) +; CHECK-NEXT: %after_scalable = load <4 x i32>, ptr @a, align 16 => { i32 30, i32 30, i32 30, i32 3 } +; CHECK-NEXT: ret void +; CHECK-NEXT: Exiting function: main diff --git a/llvm/test/tools/llubi/intr_vp_store_ub.ll b/llvm/test/tools/llubi/intr_vp_store_ub.ll new file mode 100644 index 0000000000000..29d16984d9bcf --- /dev/null +++ b/llvm/test/tools/llubi/intr_vp_store_ub.ll @@ -0,0 +1,62 @@ +; RUN: not llubi --verbose --entry-function=evl_too_large < %s 2>&1 | FileCheck %s --check-prefix=EVL +; RUN: not llubi --verbose --entry-function=poison_evl < %s 2>&1 | FileCheck %s --check-prefix=POISON-EVL +; RUN: not llubi --verbose --entry-function=poison_mask_lane < %s 2>&1 | FileCheck %s --check-prefix=POISON-MASK-LANE +; RUN: not llubi --verbose --entry-function=constant_mem < %s 2>&1 | FileCheck %s --check-prefix=CONSTANT-MEM +; RUN: not llubi --verbose --entry-function=misaligned < %s 2>&1 | FileCheck %s --check-prefix=MISALIGNED + +@a = global [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16 +@c = constant [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16 + +define void @evl_too_large() { +; EVL: Entering function: evl_too_large +; EVL-NEXT: Stacktrace: +; EVL-NEXT: #0 call void @llvm.vp.store.v4i32.p0(<4 x i32> zeroinitializer, ptr @a, <4 x i1> splat (i1 true), i32 5) at @evl_too_large <stdin>:{{[0-9]+}} +; EVL-NEXT: Immediate UB detected: llvm.vp.store with explicit vector length 5 greater than the number of elements 4. +; EVL-NEXT: error: Execution of function 'evl_too_large' failed. + call void @llvm.vp.store(<4 x i32> zeroinitializer, ptr @a, <4 x i1> splat (i1 true), i32 5) + ret void +} + +define void @poison_evl() { +; POISON-EVL: Entering function: poison_evl +; POISON-EVL-NEXT: Stacktrace: +; POISON-EVL-NEXT: #0 call void @llvm.vp.store.v4i32.p0(<4 x i32> zeroinitializer, ptr @a, <4 x i1> splat (i1 true), i32 poison) at @poison_evl <stdin>:{{[0-9]+}} +; POISON-EVL-NEXT: Immediate UB detected: llvm.vp.store with poison explicit vector length. +; POISON-EVL-NEXT: error: Execution of function 'poison_evl' failed. + call void @llvm.vp.store(<4 x i32> zeroinitializer, ptr @a, <4 x i1> splat (i1 true), i32 poison) + ret void +} + +define void @poison_mask_lane() { +; POISON-MASK-LANE: Entering function: poison_mask_lane +; POISON-MASK-LANE-NEXT: Stacktrace: +; POISON-MASK-LANE-NEXT: #0 call void @llvm.vp.store.v4i32.p0(<4 x i32> zeroinitializer, ptr @a, <4 x i1> <i1 true, i1 poison, i1 false, i1 false>, i32 2) at @poison_mask_lane <stdin>:{{[0-9]+}} +; POISON-MASK-LANE-NEXT: Immediate UB detected: Poison mask lane in llvm.vp.store. +; POISON-MASK-LANE-NEXT: error: Execution of function 'poison_mask_lane' failed. + call void @llvm.vp.store(<4 x i32> zeroinitializer, ptr @a, <4 x i1> <i1 true, i1 poison, i1 false, i1 false>, i32 2) + ret void +} + +define void @constant_mem() { +; CONSTANT-MEM: Entering function: constant_mem +; CONSTANT-MEM-NEXT: Stacktrace: +; CONSTANT-MEM-NEXT: #0 call void @llvm.vp.store.v4i32.p0(<4 x i32> zeroinitializer, ptr @c, <4 x i1> splat (i1 true), i32 1) at @constant_mem <stdin>:{{[0-9]+}} +; CONSTANT-MEM-NEXT: Immediate UB detected: Try to write to a constant memory object: ptr 0x30 [@c]. +; CONSTANT-MEM-NEXT: error: Execution of function 'constant_mem' failed. + call void @llvm.vp.store(<4 x i32> zeroinitializer, ptr @c, <4 x i1> splat (i1 true), i32 1) + ret void +} + +; Without an align attribute the pointer must have the ABI alignment of +; <2 x i32>, so the misaligned pointer is poison. +define void @misaligned() { +; MISALIGNED: Entering function: misaligned +; MISALIGNED-NEXT: %p = getelementptr i32, ptr @a, i64 1 => ptr 0x14 [@a + 4] +; MISALIGNED-NEXT: Stacktrace: +; MISALIGNED-NEXT: #0 call void @llvm.vp.store.v2i32.p0(<2 x i32> zeroinitializer, ptr %p, <2 x i1> splat (i1 true), i32 1) at @misaligned <stdin>:{{[0-9]+}} +; MISALIGNED-NEXT: Immediate UB detected: Invalid memory access with a poison pointer. +; MISALIGNED-NEXT: error: Execution of function 'misaligned' failed. + %p = getelementptr i32, ptr @a, i64 1 + call void @llvm.vp.store(<2 x i32> zeroinitializer, ptr %p, <2 x i1> splat (i1 true), i32 1) + ret void +} diff --git a/llvm/tools/llubi/lib/Interpreter.cpp b/llvm/tools/llubi/lib/Interpreter.cpp index 3d350821c1226..e22b91e00468a 100644 --- a/llvm/tools/llubi/lib/Interpreter.cpp +++ b/llvm/tools/llubi/lib/Interpreter.cpp @@ -987,9 +987,11 @@ class InstExecutor : public InstVisitor<InstExecutor, void>, AnyValue callMaskedLoadStoreIntrinsic(CallBase &CB, const AnyValue &Ptr, const AnyValue &Mask, AnyValue Data, MaskedAddrMode Mode) { - const bool IsStore = CB.getIntrinsicID() == Intrinsic::masked_store || - CB.getIntrinsicID() == Intrinsic::masked_scatter || - CB.getIntrinsicID() == Intrinsic::masked_compressstore; + const bool IsStore = + CB.getIntrinsicID() == Intrinsic::masked_store || + CB.getIntrinsicID() == Intrinsic::masked_scatter || + CB.getIntrinsicID() == Intrinsic::masked_compressstore || + CB.getIntrinsicID() == Intrinsic::vp_store; StringRef IntrinsicName = Intrinsic::getBaseName(CB.getIntrinsicID()); Type *ElemTy = (IsStore ? CB.getArgOperand(0)->getType() : CB.getType()) ->getScalarType(); @@ -1043,6 +1045,41 @@ class InstExecutor : public InstVisitor<InstExecutor, void>, return IsStore ? AnyValue() : Data; } + /// Implements llvm.vp.load and llvm.vp.store as the corresponding masked + /// intrinsic. Lanes at or past \p EVL are disabled even if their \p Mask lane + /// is poison, and without an align attribute the base pointer must have the + /// ABI alignment of the vector type. + AnyValue callVPLoadStoreIntrinsic(CallBase &CB, AnyValue Ptr, + const AnyValue &Mask, const AnyValue &EVL, + AnyValue Data) { + StringRef IntrinsicName = Intrinsic::getBaseName(CB.getIntrinsicID()); + if (EVL.isPoison()) { + reportImmediateUB() << IntrinsicName + << " with poison explicit vector length."; + return AnyValue(); + } + std::vector<AnyValue> EnabledMask(Mask.asAggregate()); + const APInt &EVLInt = EVL.asInteger(); + if (EVLInt.ugt(EnabledMask.size())) { + reportImmediateUB() << IntrinsicName << " with explicit vector length " + << EVLInt.getZExtValue() + << " greater than the number of elements " + << EnabledMask.size() << '.'; + return AnyValue(); + } + for (uint64_t I = EVLInt.getZExtValue(); I != EnabledMask.size(); ++I) + EnabledMask[I] = AnyValue::boolean(false); + + const bool IsStore = CB.getIntrinsicID() == Intrinsic::vp_store; + if (!CB.getParamAlign(IsStore ? 1 : 0)) { + Type *VecTy = IsStore ? CB.getArgOperand(0)->getType() : CB.getType(); + applyAlignAttr(Ptr, DL.getABITypeAlign(VecTy)); + } + return callMaskedLoadStoreIntrinsic(CB, Ptr, std::move(EnabledMask), + std::move(Data), + MaskedAddrMode::Consecutive); + } + /// Implements llvm.matrix.column.major.store. Column C of \p Data is stored /// as a <Rows x ElemTy> vector at an inbounds nuw GEP of C * \p Stride /// elements from \p Ptr. @@ -2030,6 +2067,11 @@ class InstExecutor : public InstVisitor<InstExecutor, void>, case Intrinsic::masked_compressstore: return callMaskedLoadStoreIntrinsic(CB, Args[1], Args[2], Args[0], MaskedAddrMode::Compressed); + case Intrinsic::vp_load: + return callVPLoadStoreIntrinsic(CB, Args[0], Args[1], Args[2], + AnyValue::getPoisonValue(Ctx, RetTy)); + case Intrinsic::vp_store: + return callVPLoadStoreIntrinsic(CB, Args[1], Args[2], Args[3], Args[0]); case Intrinsic::matrix_transpose: { const auto &Vec = Args[0].asAggregate(); const unsigned Rows = >From 665a5ba0b36eb7ba29b245d7837c18376a49cd15 Mon Sep 17 00:00:00 2001 From: Luke Lau <[email protected]> Date: Thu, 12 Nov 2026 01:27:48 +0800 Subject: [PATCH 2/2] Address review comments --- llvm/tools/llubi/lib/Interpreter.cpp | 39 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/llvm/tools/llubi/lib/Interpreter.cpp b/llvm/tools/llubi/lib/Interpreter.cpp index e22b91e00468a..b7ae00805f5b7 100644 --- a/llvm/tools/llubi/lib/Interpreter.cpp +++ b/llvm/tools/llubi/lib/Interpreter.cpp @@ -986,12 +986,7 @@ class InstExecutor : public InstVisitor<InstExecutor, void>, /// Mode. AnyValue callMaskedLoadStoreIntrinsic(CallBase &CB, const AnyValue &Ptr, const AnyValue &Mask, AnyValue Data, - MaskedAddrMode Mode) { - const bool IsStore = - CB.getIntrinsicID() == Intrinsic::masked_store || - CB.getIntrinsicID() == Intrinsic::masked_scatter || - CB.getIntrinsicID() == Intrinsic::masked_compressstore || - CB.getIntrinsicID() == Intrinsic::vp_store; + MaskedAddrMode Mode, bool IsStore) { StringRef IntrinsicName = Intrinsic::getBaseName(CB.getIntrinsicID()); Type *ElemTy = (IsStore ? CB.getArgOperand(0)->getType() : CB.getType()) ->getScalarType(); @@ -1051,7 +1046,7 @@ class InstExecutor : public InstVisitor<InstExecutor, void>, /// ABI alignment of the vector type. AnyValue callVPLoadStoreIntrinsic(CallBase &CB, AnyValue Ptr, const AnyValue &Mask, const AnyValue &EVL, - AnyValue Data) { + AnyValue Data, bool IsStore) { StringRef IntrinsicName = Intrinsic::getBaseName(CB.getIntrinsicID()); if (EVL.isPoison()) { reportImmediateUB() << IntrinsicName @@ -1062,22 +1057,20 @@ class InstExecutor : public InstVisitor<InstExecutor, void>, const APInt &EVLInt = EVL.asInteger(); if (EVLInt.ugt(EnabledMask.size())) { reportImmediateUB() << IntrinsicName << " with explicit vector length " - << EVLInt.getZExtValue() - << " greater than the number of elements " + << EVLInt << " greater than the number of elements " << EnabledMask.size() << '.'; return AnyValue(); } for (uint64_t I = EVLInt.getZExtValue(); I != EnabledMask.size(); ++I) EnabledMask[I] = AnyValue::boolean(false); - const bool IsStore = CB.getIntrinsicID() == Intrinsic::vp_store; if (!CB.getParamAlign(IsStore ? 1 : 0)) { Type *VecTy = IsStore ? CB.getArgOperand(0)->getType() : CB.getType(); applyAlignAttr(Ptr, DL.getABITypeAlign(VecTy)); } return callMaskedLoadStoreIntrinsic(CB, Ptr, std::move(EnabledMask), std::move(Data), - MaskedAddrMode::Consecutive); + MaskedAddrMode::Consecutive, IsStore); } /// Implements llvm.matrix.column.major.store. Column C of \p Data is stored @@ -2051,27 +2044,35 @@ class InstExecutor : public InstVisitor<InstExecutor, void>, return callSpeculativeLoadIntrinsic(CB, Args[0], Args[2]); case Intrinsic::masked_load: return callMaskedLoadStoreIntrinsic(CB, Args[0], Args[1], Args[2], - MaskedAddrMode::Consecutive); + MaskedAddrMode::Consecutive, + /*IsStore=*/false); case Intrinsic::masked_store: return callMaskedLoadStoreIntrinsic(CB, Args[1], Args[2], Args[0], - MaskedAddrMode::Consecutive); + MaskedAddrMode::Consecutive, + /*IsStore=*/true); case Intrinsic::masked_gather: return callMaskedLoadStoreIntrinsic(CB, Args[0], Args[1], Args[2], - MaskedAddrMode::PerLane); + MaskedAddrMode::PerLane, + /*IsStore=*/false); case Intrinsic::masked_scatter: return callMaskedLoadStoreIntrinsic(CB, Args[1], Args[2], Args[0], - MaskedAddrMode::PerLane); + MaskedAddrMode::PerLane, + /*IsStore=*/true); case Intrinsic::masked_expandload: return callMaskedLoadStoreIntrinsic(CB, Args[0], Args[1], Args[2], - MaskedAddrMode::Compressed); + MaskedAddrMode::Compressed, + /*IsStore=*/false); case Intrinsic::masked_compressstore: return callMaskedLoadStoreIntrinsic(CB, Args[1], Args[2], Args[0], - MaskedAddrMode::Compressed); + MaskedAddrMode::Compressed, + /*IsStore=*/true); case Intrinsic::vp_load: return callVPLoadStoreIntrinsic(CB, Args[0], Args[1], Args[2], - AnyValue::getPoisonValue(Ctx, RetTy)); + AnyValue::getPoisonValue(Ctx, RetTy), + /*IsStore=*/false); case Intrinsic::vp_store: - return callVPLoadStoreIntrinsic(CB, Args[1], Args[2], Args[3], Args[0]); + return callVPLoadStoreIntrinsic(CB, Args[1], Args[2], Args[3], Args[0], + /*IsStore=*/true); case Intrinsic::matrix_transpose: { const auto &Vec = Args[0].asAggregate(); const unsigned Rows = _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
