
Currently it's very difficult to improve the cost model for tail-folded loops because as soon as you add a VPInstruction::computeCost function that adds the costs of instructions such as VPInstruction::ActiveLaneMask and VPInstruction::ExplicitVectorLength the assert in LoopVectorizationPlanner::computeBestVF fails for some tests. This is because the VF chosen by the legacy cost model doesn't match the vplan cost model. See PR #90191. This assert is currently making it difficult to improve the cost model. Hopefully we will be in a position to remove the assert soon, however in order to do that we have to fix up a whole bunch of tests that rely upon the legacy cost model output. I've tried my best to update these tests to use vplan output instead. There is still work needed for the VF=1 case because the vplan cost model is not printed out in this case. I've not attempted to fix those in this patch.
26 lines
828 B
LLVM
26 lines
828 B
LLVM
; RUN: opt -mtriple=x86_64-apple-darwin -mattr=+sse2 -passes=loop-vectorize -debug-only=loop-vectorize -S < %s 2>&1 | FileCheck %s
|
|
; REQUIRES: asserts
|
|
|
|
; CHECK: 'foo'
|
|
; CHECK: LV: Found an estimated cost of 1 for VF 1 For instruction: %shift = ashr i32 %val, %k
|
|
; CHECK: Cost of 2 for VF 2: WIDEN ir<%shift> = ashr ir<%val>, ir<%k>
|
|
; CHECK: Cost of 2 for VF 4: WIDEN ir<%shift> = ashr ir<%val>, ir<%k>
|
|
define void @foo(ptr nocapture %p, i32 %k) local_unnamed_addr #0 {
|
|
entry:
|
|
br label %body
|
|
|
|
body:
|
|
%i = phi i64 [ 0, %entry ], [ %next, %body ]
|
|
%ptr = getelementptr inbounds i32, ptr %p, i64 %i
|
|
%val = load i32, ptr %ptr, align 4
|
|
%shift = ashr i32 %val, %k
|
|
store i32 %shift, ptr %ptr, align 4
|
|
%next = add nuw nsw i64 %i, 1
|
|
%cmp = icmp eq i64 %next, 16
|
|
br i1 %cmp, label %exit, label %body
|
|
|
|
exit:
|
|
ret void
|
|
|
|
}
|