llvm-project/llvm/lib
Sanjoy Das 7c0ce26614 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
2015-01-06 19:02:56 +00:00
..
Analysis [PM] Add a utility pass template that synthesizes the invalidation of 2015-01-06 04:49:44 +00:00
AsmParser IR: Make metadata typeless in assembly 2014-12-15 19:07:53 +00:00
Bitcode [PM] Switch the new pass manager to use a reference-based API for IR 2015-01-05 02:47:05 +00:00
CodeGen SelectionDAGBuilder: move constant initialization out of loop 2015-01-06 18:20:04 +00:00
DebugInfo Implement a very basic colored syntax highlighting for llvm-dwarfdump. 2015-01-06 16:50:25 +00:00
ExecutionEngine RTDyldMemoryManager.cpp: Make the reference to __morestack weak. 2014-12-30 22:52:33 +00:00
IR [PM] Add a utility pass template that synthesizes the invalidation of 2015-01-06 04:49:44 +00:00
IRReader Remove unused variable. NFC. 2014-11-06 23:16:57 +00:00
LTO LTO: Lazy-load LTOModule in local contexts 2014-12-17 22:05:42 +00:00
LineEditor
Linker Finish removing DestroySource. 2014-12-23 19:16:45 +00:00
MC Revert r225048: It broke ObjC on AArch64. 2015-01-06 00:54:32 +00:00
Object Don't loop endlessly for MachO files with 0 ncmds 2015-01-06 17:08:26 +00:00
Option Add an overload of getLastArgNoClaim taking two OptSpecifiers. 2014-09-12 19:42:53 +00:00
ProfileData llvm-cov: Sink some reporting logic into CoverageMapping 2014-11-14 01:50:32 +00:00
Support Triple: Add amdgcn triple 2015-01-06 18:00:00 +00:00
TableGen Clean up static analyzer warnings. 2014-12-12 21:48:03 +00:00
Target [Hexagon] Adding encoding information for absolute address loads. 2015-01-06 18:38:26 +00:00
Transforms This patch teaches IndVarSimplify to add nuw and nsw to certain kinds 2015-01-06 19:02:56 +00:00
CMakeLists.txt ProfileData: Introduce the InstrProfReader interface and a text reader 2014-03-21 17:24:48 +00:00
LLVMBuild.txt ProfileData: Introduce the InstrProfReader interface and a text reader 2014-03-21 17:24:48 +00:00
Makefile ProfileData: Introduce the InstrProfReader interface and a text reader 2014-03-21 17:24:48 +00:00