1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00
llvm-mirror/include/llvm/ADT
Argyrios Kyrtzidis ef5e4688df 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
}

llvm-svn: 169147
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
ArrayRef.h
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
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
EquivalenceClasses.h
FoldingSet.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
GraphTraits.h
Hashing.h
ilist_node.h
ilist.h
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
ImmutableSet.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
IndexedMap.h
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
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
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
SetOperations.h
SetVector.h
SmallBitVector.h Switch LLVM_USE_RVALUE_REFERENCES to LLVM_HAS_RVALUE_REFERENCES. 2012-11-30 11:45:22 +00:00
SmallPtrSet.h
SmallSet.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
SmallString.h
SmallVector.h Switch LLVM_USE_RVALUE_REFERENCES to LLVM_HAS_RVALUE_REFERENCES. 2012-11-30 11:45:22 +00:00
SparseBitVector.h
SparseSet.h Sort the #include lines for the include/... tree with the script. 2012-12-03 17:02:12 +00:00
Statistic.h
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
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
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
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