2014-01-09 12:26:12 +00:00
|
|
|
; RUN: opt -loop-reduce -S < %s | FileCheck %s
|
|
|
|
; PR18000
|
|
|
|
|
|
|
|
target datalayout = "e-i64:64-f80:128-s:64-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
|
|
|
|
@a = global i32 0, align 4
|
|
|
|
@b = common global i32 0, align 4
|
|
|
|
@e = common global i8 0, align 1
|
|
|
|
@d = common global i32 0, align 4
|
|
|
|
@c = common global i32 0, align 4
|
|
|
|
@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
|
|
|
|
|
|
|
; Function Attrs: nounwind optsize uwtable
|
|
|
|
; CHECK-LABEL: foo
|
|
|
|
define i32 @foo() {
|
|
|
|
entry:
|
2015-02-27 21:17:42 +00:00
|
|
|
%.pr = load i32, i32* @b, align 4
|
2014-01-09 12:26:12 +00:00
|
|
|
%cmp10 = icmp slt i32 %.pr, 1
|
|
|
|
br i1 %cmp10, label %for.cond1.preheader.lr.ph, label %entry.for.end9_crit_edge
|
|
|
|
|
|
|
|
entry.for.end9_crit_edge: ; preds = %entry
|
2015-02-27 21:17:42 +00:00
|
|
|
%.pre = load i32, i32* @c, align 4
|
2014-01-09 12:26:12 +00:00
|
|
|
br label %for.end9
|
|
|
|
|
|
|
|
for.cond1.preheader.lr.ph: ; preds = %entry
|
2015-02-27 21:17:42 +00:00
|
|
|
%0 = load i32, i32* @a, align 4
|
2014-01-09 12:26:12 +00:00
|
|
|
%tobool = icmp eq i32 %0, 0
|
|
|
|
br i1 %tobool, label %for.cond1.preheader.for.cond1.preheader.split_crit_edge, label %return.loopexit.split
|
|
|
|
|
|
|
|
for.cond1.preheader.for.cond1.preheader.split_crit_edge: ; preds = %for.cond1.preheader.lr.ph, %for.inc8
|
|
|
|
%1 = phi i32 [ %inc, %for.inc8 ], [ %.pr, %for.cond1.preheader.lr.ph ]
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
; CHECK-LABEL: if.end
|
|
|
|
if.end: ; preds = %if.end, %for.cond1.preheader.for.cond1.preheader.split_crit_edge
|
|
|
|
|
|
|
|
; CHECK: %lsr.iv = phi i32 [ %lsr.iv.next, %if.end ], [ 258, %for.cond1.preheader.for.cond1.preheader.split_crit_edge ]
|
|
|
|
%indvars.iv = phi i32 [ 1, %for.cond1.preheader.for.cond1.preheader.split_crit_edge ], [ %indvars.iv.next, %if.end ]
|
|
|
|
|
|
|
|
%2 = phi i8 [ 1, %for.cond1.preheader.for.cond1.preheader.split_crit_edge ], [ %dec, %if.end ]
|
|
|
|
%conv7 = mul i32 %indvars.iv, 258
|
|
|
|
%shl = and i32 %conv7, 510
|
|
|
|
store i32 %shl, i32* @c, align 4
|
|
|
|
|
Bugfix: SCEVExpander incorrectly marks increment operations as no-wrap
(The change was landed in r230280 and caused the regression PR22674.
This version contains a fix and a test-case for PR22674).
When emitting the increment operation, SCEVExpander marks the
operation as nuw or nsw based on the flags on the preincrement SCEV.
This is incorrect because, for instance, it is possible that {-6,+,1}
is <nuw> while {-6,+,1}+1 = {-5,+,1} is not.
This change teaches SCEV to mark the increment as nuw/nsw only if it
can explicitly prove that the increment operation won't overflow.
Apart from the attached test case, another (more realistic)
manifestation of the bug can be seen in
Transforms/IndVarSimplify/pr20680.ll.
Differential Revision: http://reviews.llvm.org/D7778
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230533 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-25 20:02:59 +00:00
|
|
|
; CHECK: %lsr.iv.next = add nsw i32 %lsr.iv, -258
|
2014-01-09 12:26:12 +00:00
|
|
|
%dec = add i8 %2, -1
|
|
|
|
|
|
|
|
%cmp2 = icmp sgt i8 %dec, -1
|
|
|
|
%indvars.iv.next = add i32 %indvars.iv, -1
|
|
|
|
br i1 %cmp2, label %if.end, label %for.inc8
|
|
|
|
|
|
|
|
for.inc8: ; preds = %if.end
|
|
|
|
store i32 0, i32* @d, align 4
|
|
|
|
%inc = add nsw i32 %1, 1
|
|
|
|
store i32 %inc, i32* @b, align 4
|
|
|
|
%cmp = icmp slt i32 %1, 0
|
|
|
|
br i1 %cmp, label %for.cond1.preheader.for.cond1.preheader.split_crit_edge, label %for.cond.for.end9_crit_edge
|
|
|
|
|
|
|
|
for.cond.for.end9_crit_edge: ; preds = %for.inc8
|
|
|
|
store i8 %dec, i8* @e, align 1
|
|
|
|
br label %for.end9
|
|
|
|
|
|
|
|
for.end9: ; preds = %entry.for.end9_crit_edge, %for.cond.for.end9_crit_edge
|
|
|
|
%3 = phi i32 [ %.pre, %entry.for.end9_crit_edge ], [ %shl, %for.cond.for.end9_crit_edge ]
|
2015-03-13 18:20:45 +00:00
|
|
|
%call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3) #2
|
2014-01-09 12:26:12 +00:00
|
|
|
br label %return
|
|
|
|
|
|
|
|
return.loopexit.split: ; preds = %for.cond1.preheader.lr.ph
|
|
|
|
store i8 1, i8* @e, align 1
|
|
|
|
store i32 0, i32* @d, align 4
|
|
|
|
br label %return
|
|
|
|
|
|
|
|
return: ; preds = %return.loopexit.split, %for.end9
|
|
|
|
%retval.0 = phi i32 [ 0, %for.end9 ], [ 1, %return.loopexit.split ]
|
|
|
|
ret i32 %retval.0
|
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind optsize
|
|
|
|
declare i32 @printf(i8* nocapture readonly, ...)
|
|
|
|
|