Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11111,13 +11111,13 @@ bool ScalarEvolution::isKnownNonZero(const SCEV *S) {

bool ScalarEvolution::isKnownToBeAPowerOfTwo(const SCEV *S, bool OrZero,
bool OrNegative) {
auto NonRecursive = [this, OrNegative](const SCEV *S) {
auto NonRecursive = [OrNegative](const SCEV *S) {
if (auto *C = dyn_cast<SCEVConstant>(S))
return C->getAPInt().isPowerOf2() ||
(OrNegative && C->getAPInt().isNegatedPowerOf2());

// The vscale_range indicates vscale is a power-of-two.
return isa<SCEVVScale>(S) && F.hasFnAttribute(Attribute::VScaleRange);
// vscale is a power-of-two.
return isa<SCEVVScale>(S);
};

if (NonRecursive(S))
Expand Down
34 changes: 34 additions & 0 deletions llvm/test/Analysis/ScalarEvolution/trip-count-scalable-stride.ll
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,37 @@ for.body: ; preds = %entry, %for.body
for.end: ; preds = %for.body, %entry
ret void
}

define void @vscale_ult_no_vscale_range(ptr nocapture %A) mustprogress {
; CHECK-LABEL: 'vscale_ult_no_vscale_range'
; CHECK-NEXT: Classifying expressions for: @vscale_ult_no_vscale_range
; CHECK-NEXT: %vscale = call i32 @llvm.vscale.i32()
; CHECK-NEXT: --> vscale U: [1,0) S: [1,0)
; CHECK-NEXT: %i.05 = phi i32 [ %add, %for.body ], [ 0, %entry ]
; CHECK-NEXT: --> {0,+,vscale}<%for.body> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.body: Computable }
; CHECK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.05
; CHECK-NEXT: --> {%A,+,(4 * vscale)}<%for.body> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.body: Computable }
; CHECK-NEXT: %add = add i32 %i.05, %vscale
; CHECK-NEXT: --> {vscale,+,vscale}<nw><%for.body> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.body: Computable }
; CHECK-NEXT: Determining loop execution counts for: @vscale_ult_no_vscale_range
; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
;
entry:
%vscale = call i32 @llvm.vscale.i32()
br label %for.body

for.body: ; preds = %entry, %for.body
%i.05 = phi i32 [ %add, %for.body ], [ 0, %entry ]
%arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.05
%0 = load <vscale x 4 x i32>, ptr %arrayidx, align 4
%inc = add nsw <vscale x 4 x i32> %0, splat (i32 1)
store <vscale x 4 x i32> %inc, ptr %arrayidx, align 4
%add = add i32 %i.05, %vscale
%cmp = icmp ult i32 %add, u0x00010000
br i1 %cmp, label %for.body, label %for.end

for.end: ; preds = %for.body, %entry
ret void
}
Loading