llvm-6502/include/llvm/ADT
Argyrios Kyrtzidis acb8d9fbe3 Eliminate redundant bitwise operations when using a llvm/ADT/PointerUnion.
For comparison, with this code sample:

PointerUnion<int *, char *> Data;
PointerUnion<int *, char *> foo1() {
	Data = new int;
	return new int;
}
PointerUnion<int *, char *> foo2() {
	Data = new char;
	return new char;
}

Before this patch we would get:

define i64 @_Z4foo1v() uwtable ssp {
  %1 = tail call noalias i8* @_Znwm(i64 4)
  %2 = ptrtoint i8* %1 to i64
  %3 = load i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %4 = and i64 %3, 1
  %.masked.i = and i64 %2, -3
  %5 = or i64 %4, %.masked.i
  store i64 %5, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %6 = tail call noalias i8* @_Znwm(i64 4)
  %7 = ptrtoint i8* %6 to i64
  %8 = and i64 %7, -3
  ret i64 %8
}

define i64 @_Z4foo2v() uwtable ssp {
  %1 = tail call noalias i8* @_Znwm(i64 1)
  %2 = ptrtoint i8* %1 to i64
  %3 = load i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %4 = and i64 %3, 1
  %5 = or i64 %2, %4
  %6 = or i64 %5, 2
  store i64 %6, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %7 = tail call noalias i8* @_Znwm(i64 1)
  %8 = ptrtoint i8* %7 to i64
  %9 = or i64 %8, 2
  ret i64 %9
}

After the patch:

define i64 @_Z4foo1v() uwtable ssp {
  %1 = tail call noalias i8* @_Znwm(i64 4)
  %2 = ptrtoint i8* %1 to i64
  store i64 %2, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %3 = tail call noalias i8* @_Znwm(i64 4)
  %4 = ptrtoint i8* %3 to i64
  ret i64 %4
}

declare noalias i8* @_Znwm(i64)

define i64 @_Z4foo2v() uwtable ssp {
  %1 = tail call noalias i8* @_Znwm(i64 1)
  %2 = ptrtoint i8* %1 to i64
  %3 = or i64 %2, 2
  store i64 %3, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8
  %4 = tail call noalias i8* @_Znwm(i64 1)
  %5 = ptrtoint i8* %4 to i64
  %6 = or i64 %5, 2
  ret i64 %6
}

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169147 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 19:59:23 +00:00
..
APFloat.h Add extra declarations of hash_value needed to build llvm with xlc 12.1. 2012-10-31 00:46:18 +00:00
APInt.h Switch LLVM_USE_RVALUE_REFERENCES to LLVM_HAS_RVALUE_REFERENCES. 2012-11-30 11:45:22 +00:00
APSInt.h Add operator== to APSInt. This will compare the signed bit before doing 2012-07-23 20:24:23 +00:00
ArrayRef.h Reduce alignment of SmallVector<T> to the required amount, rather than forcing 16-byte alignment. This fixes misaligned SmallVector accesses via ExtractValueInst's SmallVector data member. 2012-08-22 00:11:07 +00:00
BitVector.h Switch LLVM_USE_RVALUE_REFERENCES to LLVM_HAS_RVALUE_REFERENCES. 2012-11-30 11:45:22 +00:00
DAGDeltaAlgorithm.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
DeltaAlgorithm.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
DenseMap.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
DenseMapInfo.h Fix integer undefined behavior due to signed left shift overflow in LLVM. 2012-08-24 23:29:28 +00:00
DenseSet.h
DepthFirstIterator.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
edit_distance.h Add function for computing the edit distance of two arrays. 2012-02-15 22:13:07 +00:00
EquivalenceClasses.h Fix Doxygen issues: wrap code examples in \code and use \p to refer to 2012-09-15 20:22:05 +00:00
FoldingSet.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
GraphTraits.h Change the Dominators recalculate() function to only rely on GraphTraits 2011-12-05 19:17:04 +00:00
Hashing.h Fix typo in comment. 2012-09-13 07:01:25 +00:00
ilist_node.h
ilist.h Mark unimplemented copy constructors and copy assignment operators as LLVM_DELETED_FUNCTION. 2012-09-17 06:31:17 +00:00
ImmutableIntervalMap.h
ImmutableList.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
ImmutableMap.h Mark unimplemented copy constructors and copy assignment operators as LLVM_DELETED_FUNCTION. 2012-09-17 06:31:17 +00:00
ImmutableSet.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
IndexedMap.h SparseSet: Add support for key-derived indexes and arbitrary key types. 2012-04-20 20:05:28 +00:00
InMemoryStruct.h
IntEqClasses.h
IntervalMap.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
IntrusiveRefCntPtr.h Switch LLVM_USE_RVALUE_REFERENCES to LLVM_HAS_RVALUE_REFERENCES. 2012-11-30 11:45:22 +00:00
MapVector.h Fix indeterminism in MI scheduler DAG construction. 2012-11-15 17:45:50 +00:00
NullablePtr.h
Optional.h Switch LLVM_USE_RVALUE_REFERENCES to LLVM_HAS_RVALUE_REFERENCES. 2012-11-30 11:45:22 +00:00
OwningPtr.h Switch LLVM_USE_RVALUE_REFERENCES to LLVM_HAS_RVALUE_REFERENCES. 2012-11-30 11:45:22 +00:00
PackedVector.h PackedVector: Make the BitVector implementation configurable. 2012-09-28 16:40:29 +00:00
PointerIntPair.h Eliminate redundant bitwise operations when using a llvm/ADT/PointerUnion. 2012-12-03 19:59:23 +00:00
PointerUnion.h Eliminate redundant bitwise operations when using a llvm/ADT/PointerUnion. 2012-12-03 19:59:23 +00:00
PostOrderIterator.h Fix broken ipo_ext_iterator constructors. 2012-07-17 17:57:25 +00:00
PriorityQueue.h
SCCIterator.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
ScopedHashTable.h Mark unimplemented copy constructors and copy assignment operators as LLVM_DELETED_FUNCTION. 2012-09-17 06:31:17 +00:00
SetOperations.h
SetVector.h Third try at fixing this. ;] Go back to using std::remove_if, which has 2012-10-03 01:04:07 +00:00
SmallBitVector.h Switch LLVM_USE_RVALUE_REFERENCES to LLVM_HAS_RVALUE_REFERENCES. 2012-11-30 11:45:22 +00:00
SmallPtrSet.h Use LLVM_DELETED_FUNCTION for copy constructors and copy assignment operators that aren't implemented. 2012-09-16 21:37:56 +00:00
SmallSet.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
SmallString.h Fix Doxygen issues: 2012-09-13 12:34:29 +00:00
SmallVector.h Switch LLVM_USE_RVALUE_REFERENCES to LLVM_HAS_RVALUE_REFERENCES. 2012-11-30 11:45:22 +00:00
SparseBitVector.h Provide malloc-free sentinels for the SparseBitVector internals. 2012-09-28 15:36:41 +00:00
SparseSet.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
Statistic.h Silence tsan false-positives (tsan can't track things which are only safe due to 2011-12-05 23:07:05 +00:00
STLExtras.h typo 2012-11-16 21:33:35 +00:00
StringExtras.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
StringMap.h Make StringMap's copy ctor non-explicit. 2012-04-14 09:04:57 +00:00
StringRef.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
StringSet.h [Support/StringSet] Fix memory leak when inserted key already exists. 2012-10-23 22:55:54 +00:00
StringSwitch.h Fix shadowed variable warning 2012-08-01 01:43:10 +00:00
TinyPtrVector.h Switch LLVM_USE_RVALUE_REFERENCES to LLVM_HAS_RVALUE_REFERENCES. 2012-11-30 11:45:22 +00:00
Triple.h Add support for SPIR64 target - the 64bit counterpart of SPIR. 2012-11-15 10:35:47 +00:00
Twine.h Fix Doxygen issues: 2012-09-13 12:34:29 +00:00
UniqueVector.h
ValueMap.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
VariadicFunction.h Fix a typo in VariadicFunction.h that leads to invalid code in macro expansion. 2012-08-15 18:48:14 +00:00