llvm-project/llvm/lib
Chris Lattner 98457101fc Enhance the "compare with shift" and "compare with div"
optimizations to be much more aggressive in the face of
exact/nsw/nuw div and shifts.  For example, these (which
are the same except the first is 'exact' sdiv:

define i1 @sdiv_icmp4_exact(i64 %X) nounwind {
  %A = sdiv exact i64 %X, -5   ; X/-5 == 0 --> x == 0
  %B = icmp eq i64 %A, 0
  ret i1 %B
}

define i1 @sdiv_icmp4(i64 %X) nounwind {
  %A = sdiv i64 %X, -5   ; X/-5 == 0 --> x == 0
  %B = icmp eq i64 %A, 0
  ret i1 %B
}

compile down to:

define i1 @sdiv_icmp4_exact(i64 %X) nounwind {
  %1 = icmp eq i64 %X, 0
  ret i1 %1
}

define i1 @sdiv_icmp4(i64 %X) nounwind {
  %X.off = add i64 %X, 4
  %1 = icmp ult i64 %X.off, 9
  ret i1 %1
}

This happens when you do something like:
  (ptr1-ptr2) == 42

where the pointers are pointers to non-unit types.

llvm-svn: 125266
2011-02-10 05:23:05 +00:00
..
Analysis Formatting and comment tweaks. 2011-02-09 17:45:03 +00:00
Archive Archive: Fix temp path names. 2011-01-17 16:43:30 +00:00
AsmParser implement .ll and .bc support for nsw/nuw on shl and exact on lshr/ashr. 2011-02-07 16:40:21 +00:00
Bitcode implement .ll and .bc support for nsw/nuw on shl and exact on lshr/ashr. 2011-02-07 16:40:21 +00:00
CodeGen After 3-addressifying a two-address instruction, update the register maps; add a missing check when considering whether it's profitable to commute. rdar://8977508. 2011-02-10 02:20:55 +00:00
CompilerDriver Support/Path: Deprecate PathV1::exists and replace all uses with PathV2::fs::exists. 2011-01-10 02:34:23 +00:00
ExecutionEngine Fix libffi usage when it is on a custom path. 2011-01-28 16:49:05 +00:00
Linker Correctly merge available_externally and regular definitions when they have 2011-02-01 05:33:52 +00:00
MC Fix comparator used for looking up previously instantiated EDDisassemblers. 2011-02-09 21:03:19 +00:00
Object Object: Fix type punned pointer issues by making DataRefImpl a union and using intptr_t. 2011-01-21 02:27:02 +00:00
Support Rip out realpath() support. It's expensive, and often a bad idea, and 2011-02-09 23:33:15 +00:00
Target [AVX] Implement 256-bit vector lowering for INSERT_VECTOR_ELT. 2011-02-09 15:32:06 +00:00
Transforms Enhance the "compare with shift" and "compare with div" 2011-02-10 05:23:05 +00:00
VMCore refactor ConstantExpr interfaces a bit around "exactness". 2011-02-09 16:43:07 +00:00
Makefile Add LLVMObject Library. 2010-11-15 03:21:41 +00:00