diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-01-06 19:02:56 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-01-06 19:02:56 +0000 |
commit | 7c0ce26614af63cf450fecf44c7ed088d7fb3b06 (patch) | |
tree | 7a882cbd0ad8f96c1e3199953368e6cd6d49290c /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | 4e781371d11a1b773ac8e90706129daf9f1f0621 (diff) | |
download | llvm-7c0ce26614af63cf450fecf44c7ed088d7fb3b06.zip llvm-7c0ce26614af63cf450fecf44c7ed088d7fb3b06.tar.gz llvm-7c0ce26614af63cf450fecf44c7ed088d7fb3b06.tar.bz2 |
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
llvm-svn: 225282
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
0 files changed, 0 insertions, 0 deletions