The previous differential test timed out executing the transformed vp.strided.store intrinsic, but static inspection of opt output proves a real semantic mismatch: original stores to offsets 14,12,10,8,6,4,2,0; optimized emits a single vp.strided.store from base %ps+8 with positive stride 2 and EVL 8, which stores to offsets 8,10,12,14,16,18,20,22. Therefore offsets 0,2,4,6 are no longer written and offsets 16..22 are newly written. This is independent of data values and is a real miscompile for the reversed-address strided store with data reorder mutation.
@pl = global [16 x i8] c"\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F", align 1
@ps = global [32 x i8] zeroinitializer, align 1
define void @reversed_addr_data_reorder(ptr %pl, ptr %ps) {
%l0 = getelementptr i8, ptr %pl, i64 0
%l1 = getelementptr i8, ptr %pl, i64 1
%l2 = getelementptr i8, ptr %pl, i64 2
%l3 = getelementptr i8, ptr %pl, i64 3
%l4 = getelementptr i8, ptr %pl, i64 4
%l5 = getelementptr i8, ptr %pl, i64 5
%l6 = getelementptr i8, ptr %pl, i64 6
%l7 = getelementptr i8, ptr %pl, i64 7
%v0 = load i8, ptr %l0, align 1
%v1 = load i8, ptr %l1, align 1
%v2 = load i8, ptr %l2, align 1
%v3 = load i8, ptr %l3, align 1
%v4 = load i8, ptr %l4, align 1
%v5 = load i8, ptr %l5, align 1
%v6 = load i8, ptr %l6, align 1
%v7 = load i8, ptr %l7, align 1
%s0 = getelementptr i8, ptr %ps, i64 14
%s1 = getelementptr i8, ptr %ps, i64 12
%s2 = getelementptr i8, ptr %ps, i64 10
%s3 = getelementptr i8, ptr %ps, i64 8
%s4 = getelementptr i8, ptr %ps, i64 6
%s5 = getelementptr i8, ptr %ps, i64 4
%s6 = getelementptr i8, ptr %ps, i64 2
%s7 = getelementptr i8, ptr %ps, i64 0
store i8 %v0, ptr %s0, align 1
store i8 %v3, ptr %s1, align 1
store i8 %v1, ptr %s2, align 1
store i8 %v6, ptr %s3, align 1
store i8 %v2, ptr %s4, align 1
store i8 %v7, ptr %s5, align 1
store i8 %v5, ptr %s6, align 1
store i8 %v4, ptr %s7, align 1
ret void
}
define void @main(i32 %argc, ptr %argv) {
entry:
call void @reversed_addr_data_reorder(ptr @pl, ptr @ps)
ret void
}
; ModuleID = '/data/tmp/tmp0nsxem15/orig.ll'
source_filename = "/data/tmp/tmp0nsxem15/orig.ll"
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "riscv64"
@pl = global [16 x i8] c"\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F", align 1
@ps = global [32 x i8] zeroinitializer, align 1
define void @reversed_addr_data_reorder(ptr %pl, ptr %ps) #0 {
%l0 = getelementptr i8, ptr %pl, i64 0
%s3 = getelementptr i8, ptr %ps, i64 8
%1 = load <8 x i8>, ptr %l0, align 1
%2 = shufflevector <8 x i8> %1, <8 x i8> poison, <8 x i32> <i32 4, i32 5, i32 7, i32 2, i32 6, i32 1, i32 3, i32 0>
call void @llvm.experimental.vp.strided.store.v8i8.p0.i64(<8 x i8> %2, ptr align 1 %s3, i64 2, <8 x i1> splat (i1 true), i32 8)
ret void
}
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: write)
declare void @llvm.experimental.vp.strided.store.v8i8.p0.i64(<8 x i8>, ptr captures(none), i64, <8 x i1>, i32) #1
attributes #0 = { "target-features"="+m,+v" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: write) }
define void @main(i32 %argc, ptr %argv) {
entry:
call void @reversed_addr_data_reorder(ptr @pl, ptr @ps)
ret void
}
Confirmed as bug by agent.
Original Output: {'timed_out': False, 'return_code': 0, 'stdout': '', 'stderr': '', 'executor': 'llubi'}
Transformed Output: {'timed_out': True, 'return_code': None, 'stdout': '', 'stderr': '', 'executor': 'llubi'}
Bug Triggering Analysis:
This mutation targets the patch's explicit exception for (E->State == TreeEntry::StridedVectorize && IsReverseOrder). The scalar program stores to a descending strided address sequence: %ps+14, +12, +10, +8, +6, +4, +2, +0, while the stored values are independently permuted (v0,v3,v1,v6,v2,v7,v5,v4). Running opt with -mtriple=riscv64 -mattr=+m,+v -passes=slp-vectorizer -S -slp-enable-strided-stores transforms it to:
%s3 = getelementptr i8, ptr %ps, i64 8
%1 = load <8 x i8>, ptr %l0, align 1
%2 = shufflevector <8 x i8> %1, poison, <8 x i32> <i32 4, i32 5, i32 7, i32 2, i32 6, i32 1, i32 3, i32 0>
call void @llvm.experimental.vp.strided.store.v8i8.p0.i64(<8 x i8> %2, ptr align 1 %s3, i64 2, <8 x i1> splat (i1 true), i32 8)By the LangRef, llvm.experimental.vp.strided.store stores lanes at base + i * stride bytes. The optimized code therefore writes offsets 8,10,12,14,16,18,20,22. The original program wrote offsets 14,12,10,8,6,4,2,0. Thus offsets 0,2,4,6 are dropped and offsets 16,18,20,22 are newly written. This is a clear memory-effect mismatch independent of lane values.
Verification Notes:
Alive2 could not complete verification for the target-specific experimental VP strided-store intrinsic. Differential execution with llubi timed out on the transformed intrinsic, but the transformed IR from trans and the intrinsic's specified address semantics are sufficient to confirm the bug. The difftest result was confirmed as a real bug based on this static semantic mismatch.
Fix Weakness Analysis:
The patch corrected non-reverse strided stores by treating store ReorderIndices as a direct shuffle mask. However, it preserves the reverse-order fast path before the store-specific branch:
if ((E->State == TreeEntry::StridedVectorize && IsReverseOrder) || ...)
addOrdered(V, {});
else if (Store && (Vectorize || StridedVectorize))
add(V, ReorderIndices);This assumes reverse-order strided stores require no store-specific reorder handling and that base/stride selection elsewhere fully accounts for reversal. The test violates that assumption by combining reversed memory order with independent data reorder. The resulting base pointer is neither the low address nor a correct high-address base with negative stride; it starts at %ps+8 and uses positive stride, producing an incorrect address set. Therefore the fix leaves an edge case in the reversed strided-store path.