forked from OSchip/llvm-project
[SCEV] add no wrap flag for SCEVAddExpr.
Differential Revision: https://reviews.llvm.org/D64868 llvm-svn: 366419
This commit is contained in:
parent
0b03429a91
commit
c38e3efe27
|
@ -4991,7 +4991,7 @@ const SCEV *ScalarEvolution::createSimpleAffineAddRec(PHINode *PN,
|
||||||
// overflow.
|
// overflow.
|
||||||
if (auto *BEInst = dyn_cast<Instruction>(BEValueV))
|
if (auto *BEInst = dyn_cast<Instruction>(BEValueV))
|
||||||
if (isLoopInvariant(Accum, L) && isAddRecNeverPoison(BEInst, L))
|
if (isLoopInvariant(Accum, L) && isAddRecNeverPoison(BEInst, L))
|
||||||
(void)getAddRecExpr(getAddExpr(StartVal, Accum), Accum, L, Flags);
|
(void)getAddRecExpr(getAddExpr(StartVal, Accum, Flags), Accum, L, Flags);
|
||||||
|
|
||||||
return PHISCEV;
|
return PHISCEV;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ define void @test_mul(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f) {
|
||||||
define void @test_sext(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f) {
|
define void @test_sext(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f) {
|
||||||
; CHECK-LABEL: @test_sext
|
; CHECK-LABEL: @test_sext
|
||||||
; CHECK: %se2 = sext i64 %iv2.inc to i128
|
; CHECK: %se2 = sext i64 %iv2.inc to i128
|
||||||
; CHECK-NEXT: --> {(1 + (sext i64 {(sext i32 (1 + %a) to i64),+,1}<nsw><%loop> to i128))<nsw>,+,1}<nsw><%loop2>
|
; CHECK-NEXT: --> {(1 + (sext i64 {(sext i32 (1 + %a)<nsw> to i64),+,1}<nsw><%loop> to i128))<nsw>,+,1}<nsw><%loop2>
|
||||||
entry:
|
entry:
|
||||||
br label %loop
|
br label %loop
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ bb5: ; preds = %bb2
|
||||||
declare void @f(i32)
|
declare void @f(i32)
|
||||||
|
|
||||||
; CHECK-LABEL: nswnowrap
|
; CHECK-LABEL: nswnowrap
|
||||||
; CHECK: --> {(1 + %v)<nsw>,+,1}<nsw><%for.body>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (1 + ((1 + %v)<nsw> smax %v))
|
; CHECK: --> {(1 + %v)<nsw>,+,1}<nsw><%for.body>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (2 + %v)
|
||||||
define void @nswnowrap(i32 %v, i32* %buf) {
|
define void @nswnowrap(i32 %v, i32* %buf) {
|
||||||
entry:
|
entry:
|
||||||
%add = add nsw i32 %v, 1
|
%add = add nsw i32 %v, 1
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
|
; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
|
||||||
|
|
||||||
; CHECK: Determining loop execution counts for: @test
|
; CHECK: Determining loop execution counts for: @test
|
||||||
; CHECK: Loop %for.body: backedge-taken count is ((-2 + %len) /u 2)
|
; CHECK: Loop %for.body: backedge-taken count is ((-2 + %len)<nsw> /u 2)
|
||||||
; CHECK: Loop %for.body: max backedge-taken count is 1073741823
|
; CHECK: Loop %for.body: max backedge-taken count is 1073741823
|
||||||
|
|
||||||
define zeroext i16 @test(i16* nocapture %p, i32 %len) nounwind readonly {
|
define zeroext i16 @test(i16* nocapture %p, i32 %len) nounwind readonly {
|
||||||
|
|
|
@ -179,7 +179,7 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: Determining loop execution counts for: @nsw_startx
|
; CHECK: Determining loop execution counts for: @nsw_startx
|
||||||
; CHECK: Loop %loop: backedge-taken count is (-1 + (-1 * %x) + ((1 + %x) smax %n))
|
; CHECK: Loop %loop: backedge-taken count is (-1 + (-1 * %x) + ((1 + %x)<nsw> smax %n))
|
||||||
; CHECK: Loop %loop: max backedge-taken count is -1
|
; CHECK: Loop %loop: max backedge-taken count is -1
|
||||||
define void @nsw_startx(i4 %n, i4 %x) {
|
define void @nsw_startx(i4 %n, i4 %x) {
|
||||||
entry:
|
entry:
|
||||||
|
@ -195,7 +195,7 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: Determining loop execution counts for: @nsw_startx_step2
|
; CHECK: Determining loop execution counts for: @nsw_startx_step2
|
||||||
; CHECK: Loop %loop: backedge-taken count is ((-1 + (-1 * %x) + ((2 + %x) smax %n)) /u 2)
|
; CHECK: Loop %loop: backedge-taken count is ((-1 + (-1 * %x) + ((2 + %x)<nsw> smax %n)) /u 2)
|
||||||
; CHECK: Loop %loop: max backedge-taken count is 7
|
; CHECK: Loop %loop: max backedge-taken count is 7
|
||||||
define void @nsw_startx_step2(i4 %n, i4 %x) {
|
define void @nsw_startx_step2(i4 %n, i4 %x) {
|
||||||
entry:
|
entry:
|
||||||
|
@ -381,7 +381,7 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: Determining loop execution counts for: @even_nsw_startx
|
; CHECK: Determining loop execution counts for: @even_nsw_startx
|
||||||
; CHECK: Loop %loop: backedge-taken count is (-1 + (-1 * %x) + ((1 + %x) smax (2 * %n)))
|
; CHECK: Loop %loop: backedge-taken count is (-1 + (-1 * %x) + ((1 + %x)<nsw> smax (2 * %n)))
|
||||||
; CHECK: Loop %loop: max backedge-taken count is -2
|
; CHECK: Loop %loop: max backedge-taken count is -2
|
||||||
define void @even_nsw_startx(i4 %n, i4 %x) {
|
define void @even_nsw_startx(i4 %n, i4 %x) {
|
||||||
entry:
|
entry:
|
||||||
|
@ -398,7 +398,7 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: Determining loop execution counts for: @even_nsw_startx_step2
|
; CHECK: Determining loop execution counts for: @even_nsw_startx_step2
|
||||||
; CHECK: Loop %loop: backedge-taken count is ((-1 + (-1 * %x) + ((2 + %x) smax (2 * %n))) /u 2)
|
; CHECK: Loop %loop: backedge-taken count is ((-1 + (-1 * %x) + ((2 + %x)<nsw> smax (2 * %n))) /u 2)
|
||||||
; CHECK: Loop %loop: max backedge-taken count is 7
|
; CHECK: Loop %loop: max backedge-taken count is 7
|
||||||
define void @even_nsw_startx_step2(i4 %n, i4 %x) {
|
define void @even_nsw_startx_step2(i4 %n, i4 %x) {
|
||||||
entry:
|
entry:
|
||||||
|
|
Loading…
Reference in New Issue