diff options
author | Evgeny Stupachenko <evstupac@gmail.com> | 2016-04-27 03:04:54 +0000 |
---|---|---|
committer | Evgeny Stupachenko <evstupac@gmail.com> | 2016-04-27 03:04:54 +0000 |
commit | 23ce61b66334b78ce7a0dd48c24fbf407ca12d8b (patch) | |
tree | efea78cc6444d7653d38307f6734f96e4b3f412f /llvm/test/Transforms/LoopUnroll/tripcount-overflow.ll | |
parent | c67651dd70b740765cdb809aa0c87236a7eedc1a (diff) | |
download | bcm5719-llvm-23ce61b66334b78ce7a0dd48c24fbf407ca12d8b.tar.gz bcm5719-llvm-23ce61b66334b78ce7a0dd48c24fbf407ca12d8b.zip |
The patch fixes PR27392.
Summary:
It is incorrect to compare TripCount (which is BECount + 1)
with extraiters (or Count) to check if we should enter unrolled
loop or not, because TripCount can potentially overflow
(when BECount is max unsigned integer).
While comparing BECount with (Count - 1) is overflow safe and
therefore correct.
Reviewer: hfinkel
Differential Revision: http://reviews.llvm.org/D19256
From: Evgeny Stupachenko <evstupac@gmail.com>
llvm-svn: 267662
Diffstat (limited to 'llvm/test/Transforms/LoopUnroll/tripcount-overflow.ll')
-rw-r--r-- | llvm/test/Transforms/LoopUnroll/tripcount-overflow.ll | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/llvm/test/Transforms/LoopUnroll/tripcount-overflow.ll b/llvm/test/Transforms/LoopUnroll/tripcount-overflow.ll index 5c250933af5..7156629af6d 100644 --- a/llvm/test/Transforms/LoopUnroll/tripcount-overflow.ll +++ b/llvm/test/Transforms/LoopUnroll/tripcount-overflow.ll @@ -1,4 +1,5 @@ -; RUN: opt < %s -S -unroll-runtime -unroll-count=2 -loop-unroll | FileCheck %s +; RUN: opt < %s -S -unroll-runtime -unroll-count=2 -loop-unroll | FileCheck %s -check-prefix=EPILOG +; RUN: opt < %s -S -unroll-runtime -unroll-count=2 -loop-unroll -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" ; This test case documents how runtime loop unrolling handles the case @@ -9,17 +10,28 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" ; is divisible by 2. The prologue then branches to the unrolled loop ; and executes the 2^32 iterations there, in groups of 2. +; EPILOG: entry: -; CHECK: entry: -; CHECK-NEXT: %0 = add i32 %N, 1 -; CHECK-NEXT: %xtraiter = and i32 %0, 1 -; CHECK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, %0 -; CHECK-NEXT: br i1 %lcmp.mod, label %entry.new, label %while.end.unr-lcssa +; EPILOG-NEXT: %0 = add i32 %N, 1 +; EPILOG-NEXT: %xtraiter = and i32 %0, 1 +; EPILOG-NEXT: %1 = icmp ult i32 %N, 1 +; EPILOG-NEXT: br i1 %1, label %while.end.unr-lcssa, label %entry.new +; EPILOG: while.body: -; CHECK: while.body.epil: -; CHECK: br label %while.end.epilog-lcssa +; EPILOG: %lcmp.mod = icmp ne i32 %xtraiter, 0 +; EPILOG-NEXT: br i1 %lcmp.mod, label %while.body.epil.preheader, label %while.end +; EPILOG: while.body.epil: -; CHECK: while.end.epilog-lcssa: +; PROLOG: entry: +; PROLOG-NEXT: %0 = add i32 %N, 1 +; PROLOG-NEXT: %xtraiter = and i32 %0, 1 +; PROLOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0 +; PROLOG-NEXT: br i1 %lcmp.mod, label %while.body.prol.preheader, label %while.body.prol.loopexit +; PROLOG: while.body.prol: + +; PROLOG: %1 = icmp ult i32 %N, 1 +; PROLOG-NEXT: br i1 %1, label %while.end, label %entry.new +; PROLOG: while.body: ; Function Attrs: nounwind readnone ssp uwtable define i32 @foo(i32 %N) { |