llvm-6502/test/Analysis/ScalarEvolution/pr22641.ll
Sanjoy Das edf1700d33 Fix bug 22641
The bug was a result of getPreStartForExtend interpreting nsw/nuw
flags on an add recurrence more strongly than is legal.  {S,+,X}<nsw>
implies S+X is nsw only if the backedge of the loop is taken at least
once.

NOTE: I had accidentally committed an unrelated change with the commit
message of this change in r230275 (r230275 was reverted in r230279).
This is the correct change for this commit message.

Differential Revision: http://reviews.llvm.org/D7808



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230291 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-24 01:02:42 +00:00

26 lines
606 B
LLVM

; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s
define i1 @main(i16 %a) {
; CHECK-LABEL: Classifying expressions for: @main
entry:
br label %body
body:
%dec2 = phi i16 [ %a, %entry ], [ %dec, %cond ]
%dec = add i16 %dec2, -1
%conv2 = zext i16 %dec2 to i32
%conv = zext i16 %dec to i32
; CHECK: %conv = zext i16 %dec to i32
; CHECK-NEXT: --> {(zext i16 (-1 + %a) to i32),+,65535}<nuw><%body>
; CHECK-NOT: --> {(65535 + (zext i16 %a to i32)),+,65535}<nuw><%body>
br label %cond
cond:
br i1 false, label %body, label %exit
exit:
%ret = icmp ne i32 %conv, 0
ret i1 %ret
}