[llvm-bugs] [Bug 50028] New: SCEV ignores nuw/nsw when computing MaxBackedgeTakenCount
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Apr 19 10:54:48 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50028
Bug ID: 50028
Summary: SCEV ignores nuw/nsw when computing
MaxBackedgeTakenCount
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Global Analyses
Assignee: unassignedbugs at nondot.org
Reporter: suc-daniil at yandex.ru
CC: llvm-bugs at lists.llvm.org
define void @foo(i32 %n) {
entry:
br label %loop
loop:
%i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
%i.next = add nuw nsw i32 %i, 1
%innercmp = icmp ult i32 %i, %n
br i1 %innercmp, label %loop, label %exit
exit:
ret void
}
Running opt -passes='print<scalar-evolution>' gives us the following result:
Printing analysis 'Scalar Evolution Analysis' for function 'foo':
Classifying expressions for: @foo
%i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
--> {0,+,1}<nuw><nsw><%loop> U: [0,-2147483648) S: [0,-2147483648)
Exits: %n LoopDispositions: { %loop: Computable }
%i.next = add nuw nsw i32 %i, 1
--> {1,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: (1 + %n)
LoopDispositions: { %loop: Computable }
Determining loop execution counts for: @foo
Loop %loop: backedge-taken count is %n
Loop %loop: max backedge-taken count is -1
Loop %loop: Predicated backedge-taken count is %n
Predicates:
Loop %loop: Trip multiple is 1
SCEV understands that %i won't exceed 2^31, but says that the backedge can be
taken up to 2^32-1 times. Since it's an upper-bound estimate, it's correct, yet
suboptimal.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210419/a5afd78c/attachment.html>
More information about the llvm-bugs
mailing list