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-11-12 18:09:15 +00:00
2012-12-30 01:28:40 +00:00
2012-10-08 16:39:34 +00:00
2012-07-02 12:47:22 +00:00
2012-07-02 12:47:22 +00:00
2012-07-02 19:09:46 +00:00
2012-07-02 19:09:46 +00:00
2012-07-02 19:09:46 +00:00
2015-01-06 19:02:56 +00:00
2014-09-03 23:03:18 +00:00
2013-07-14 01:42:54 +00:00
2011-11-16 00:52:40 +00:00
2013-07-14 01:42:54 +00:00
2013-07-14 01:42:54 +00:00
2013-07-14 01:42:54 +00:00
2014-06-22 12:22:04 +00:00
2012-03-22 17:09:04 +00:00
2011-11-27 06:54:59 +00:00
2014-12-15 22:50:15 +00:00
2012-12-30 02:33:22 +00:00
2013-07-14 01:42:54 +00:00
2012-03-22 17:09:04 +00:00
2013-07-14 01:42:54 +00:00
2012-07-02 12:47:22 +00:00
2013-07-14 01:42:54 +00:00
2013-07-14 01:42:54 +00:00
2013-07-14 01:42:54 +00:00
2014-01-07 06:59:12 +00:00
2012-11-23 14:51:42 +00:00
2014-01-29 04:40:19 +00:00
2014-09-03 23:03:18 +00:00
2014-11-18 02:20:58 +00:00
2014-09-03 23:03:18 +00:00
2013-10-24 05:29:56 +00:00
2012-07-02 19:09:46 +00:00
2012-07-02 19:09:46 +00:00
2013-11-06 11:55:41 +00:00
2012-07-02 12:47:22 +00:00
2012-07-02 12:47:22 +00:00
2012-07-02 12:47:22 +00:00
2013-11-06 02:08:26 +00:00
2014-09-17 14:10:33 +00:00
2013-12-23 23:31:49 +00:00
2013-03-12 16:27:52 +00:00
2014-05-23 00:06:56 +00:00
2014-09-03 23:03:18 +00:00
2012-03-22 17:09:04 +00:00
2014-12-15 19:07:53 +00:00
2012-07-02 12:47:22 +00:00
2011-11-27 06:54:59 +00:00
2015-01-06 19:02:56 +00:00
2014-01-15 06:42:11 +00:00
2013-07-14 01:42:54 +00:00
2013-07-14 01:42:54 +00:00
2013-07-14 01:42:54 +00:00
2014-12-15 19:07:53 +00:00
2012-03-22 17:09:04 +00:00
2014-09-17 14:10:33 +00:00
2014-11-13 00:00:58 +00:00
2013-07-14 02:50:07 +00:00