Assertion fails on llvm::InnerLoopVectorizer::vectorizeInterleaveGroup
reproducer: https://godbolt.org/z/463rz7sKd
Taking a look.
Reduced IR reproducer:
https://llvm.godbolt.org/z/qb34j6oeG
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx13.0.0"
define void @test(ptr %l_out, i64 %wide.trip.count) #0 {
entry:
br label %for.body9
for.cond.cleanup8.loopexit: ; preds = %for.body9
ret void
for.body9: ; preds = %for.body9, %entry
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body9 ]
%0 = mul nuw i64 %indvars.iv, 6
%1 = load i8, ptr null, align 1, !llvm.access.group !0
store i8 %1, ptr null, align 1, !llvm.access.group !0
%arrayidx77 = getelementptr i8, ptr %l_out, i64 %0
store i8 0, ptr %arrayidx77, align 1, !llvm.access.group !0
%2 = add i64 %0, 2
%arrayidx97 = getelementptr i8, ptr %l_out, i64 %2
store i8 0, ptr %arrayidx97, align 1, !llvm.access.group !0
%indvars.iv.next = add i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv, %wide.trip.count
br i1 %exitcond.not, label %for.cond.cleanup8.loopexit, label %for.body9, !llvm.loop !1
}
attributes #0 = { "target-cpu"="skx" }
!0 = distinct !{}
!1 = distinct !{!1, !2, !3, !4, !5, !6}
!2 = !{!"llvm.loop.mustprogress"}
!3 = !{!"llvm.loop.parallel_accesses", !0}
!4 = !{!"llvm.loop.vectorize.width", i32 8}
!5 = !{!"llvm.loop.vectorize.scalable.enable", i1 false}
!6 = !{!"llvm.loop.vectorize.enable", i1 true}
Seems like ILV::vectorizeInterleaveGroup() should retrieve from StoredValues using a separate index, because its packed?
- Value *StoredVec = State.get(StoredValues[i], Part);
+ Value *StoredVec = State.get(StoredValues[j++], Part);
Seems like ILV::vectorizeInterleaveGroup() should retrieve from StoredValues using a separate index, because its packed?
- Value *StoredVec = State.get(StoredValues[i], Part); + Value *StoredVec = State.get(StoredValues[j++], Part);
Yep, that looks like it was the issue. I pushed a fix in ed2fdace89425148dbf37cd7f0473671ca698e09
(it was a bit surprising that we were missing test coverage for that scenario)
(it was a bit surprising that we were missing test coverage for that scenario)
Yeah, this seems to date back to D104750... having enableMaskedInterleavedAccessVectorization() turned off in TTI probably contributes to lack of general coverage of this feature.