Sanjoy Das
31123d4529
This patch teaches IndVarSimplify to add nuw and nsw to certain kinds
of operations that provably don't overflow. For example, we can prove
%civ.inc below does not sign-overflow. With this change,
IndVarSimplify changes %civ.inc to an add nsw.
define i32 @foo(i32* %array, i32* %length_ptr, i32 %init) {
entry:
%length = load i32* %length_ptr, !range !0
%len.sub.1 = sub i32 %length, 1
%upper = icmp slt i32 %init, %len.sub.1
br i1 %upper, label %loop, label %exit
loop:
%civ = phi i32 [ %init, %entry ], [ %civ.inc, %latch ]
%civ.inc = add i32 %civ, 1
%cmp = icmp slt i32 %civ.inc, %length
br i1 %cmp, label %latch, label %break
latch:
store i32 0, i32* %array
%check = icmp slt i32 %civ.inc, %len.sub.1
br i1 %check, label %loop, label %break
break:
ret i32 %civ.inc
exit:
ret i32 42
}
Differential Revision: http://reviews.llvm.org/D6748
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225282 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-06 19:02:56 +00:00
..
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2015-01-06 19:02:56 +00:00
2014-11-12 22:16:55 +00:00
2014-11-25 17:23:05 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2014-11-18 17:46:32 +00:00
2014-11-03 18:19:26 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2015-01-06 19:02:56 +00:00
2014-12-15 19:07:53 +00:00
2015-01-06 15:50:59 +00:00
2014-12-17 08:12:59 +00:00
2014-12-20 03:04:38 +00:00
2015-01-04 07:06:53 +00:00
2014-12-22 22:35:46 +00:00
2014-12-29 23:00:57 +00:00
2014-11-03 23:19:16 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2015-01-05 12:34:01 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2014-11-19 23:21:20 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2014-12-15 19:07:53 +00:00
2014-11-07 08:54:19 +00:00
2014-10-25 18:34:03 +00:00
2014-12-23 08:26:55 +00:00
2014-12-17 10:34:27 +00:00
2015-01-05 04:17:53 +00:00
2014-12-15 19:07:53 +00:00
2014-12-03 04:28:32 +00:00
2014-11-19 13:32:51 +00:00
2014-12-02 18:31:53 +00:00