<div dir="ltr"><div>LGTM.</div><div><br></div><div>-Eli</div><div><br></div>On Thu, Sep 12, 2013 at 9:15 PM, Matt Arsenault <span dir="ltr"><<a href="mailto:Matthew.Arsenault@amd.com" target="_blank">Matthew.Arsenault@amd.com</a>></span> wrote:<br>
<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If there are no legal integers, assume 1 byte.<br>
<br>
This makes more sense than using the pointer size as<br>
a guess for the maximum GPR width.<br>
<br>
It is conceivable to want to use some 64-bit pointers<br>
on a target where 64-bit integers aren't legal.<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D1669" target="_blank">http://llvm-reviews.chandlerc.com/D1669</a><br>
<br>
Files:<br>
include/llvm/IR/DataLayout.h<br>
lib/IR/DataLayout.cpp<br>
lib/Transforms/Scalar/MemCpyOptimizer.cpp<br>
<br>
Index: include/llvm/IR/DataLayout.h<br>
===================================================================<br>
--- include/llvm/IR/DataLayout.h<br>
+++ include/llvm/IR/DataLayout.h<br>
@@ -381,6 +381,17 @@<br>
/// least as big as Width bits.<br>
Type *getSmallestLegalIntType(LLVMContext &C, unsigned Width = 0) const;<br>
<br>
+ /// getLargestLegalIntType - Return the largest legal integer type, or null if<br>
+ /// none are set.<br>
+ Type *getLargestLegalIntType(LLVMContext &C) const {<br>
+ unsigned LargestSize = getLargestLegalIntTypeSize();<br>
+ return (LargestSize == 0) ? 0 : Type::getIntNTy(C, LargestSize);<br>
+ }<br>
+<br>
+ /// getLargestLegalIntType - Return the size of largest legal integer type<br>
+ /// size, or 0 if none are set.<br>
+ unsigned getLargestLegalIntTypeSize() const;<br>
+<br>
/// getIndexedOffset - return the offset from the beginning of the type for<br>
/// the specified indices. This is used to implement getelementptr.<br>
uint64_t getIndexedOffset(Type *Ty, ArrayRef<Value *> Indices) const;<br>
Index: lib/IR/DataLayout.cpp<br>
===================================================================<br>
--- lib/IR/DataLayout.cpp<br>
+++ lib/IR/DataLayout.cpp<br>
@@ -629,6 +629,13 @@<br>
return 0;<br>
}<br>
<br>
+unsigned DataLayout::getLargestLegalIntTypeSize() const {<br>
+ unsigned MaxWidth = 0;<br>
+ for (unsigned i = 0, e = (unsigned)LegalIntWidths.size(); i != e; ++i)<br>
+ MaxWidth = std::max<unsigned>(MaxWidth, LegalIntWidths[i]);<br>
+ return MaxWidth;<br>
+}<br>
+<br>
uint64_t DataLayout::getIndexedOffset(Type *ptrTy,<br>
ArrayRef<Value *> Indices) const {<br>
Type *Ty = ptrTy;<br>
Index: lib/Transforms/Scalar/MemCpyOptimizer.cpp<br>
===================================================================<br>
--- lib/Transforms/Scalar/MemCpyOptimizer.cpp<br>
+++ lib/Transforms/Scalar/MemCpyOptimizer.cpp<br>
@@ -170,14 +170,17 @@<br>
// pessimize the llvm optimizer.<br>
//<br>
// Since we don't have perfect knowledge here, make some assumptions: assume<br>
- // the maximum GPR width is the same size as the pointer size and assume that<br>
- // this width can be stored. If so, check to see whether we will end up<br>
- // actually reducing the number of stores used.<br>
+ // the maximum GPR width is the same size as the largest legal integer<br>
+ // size. If so, check to see whether we will end up actually reducing the<br>
+ // number of stores used.<br>
unsigned Bytes = unsigned(End-Start);<br>
- unsigned NumPointerStores = Bytes/TD.getPointerSize();<br>
+ unsigned MaxIntSize = TD.getLargestLegalIntTypeSize();<br>
+ if (MaxIntSize == 0)<br>
+ MaxIntSize = 1;<br>
+ unsigned NumPointerStores = Bytes / MaxIntSize;<br>
<br>
// Assume the remaining bytes if any are done a byte at a time.<br>
- unsigned NumByteStores = Bytes - NumPointerStores*TD.getPointerSize();<br>
+ unsigned NumByteStores = Bytes - NumPointerStores * MaxIntSize;<br>
<br>
// If we will reduce the # stores (according to this heuristic), do the<br>
// transformation. This encourages merging 4 x i8 -> i32 and 2 x i16 -> i32<br>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>