[llvm-commits] [llvm] r122790 - /llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp

Chris Lattner sabre at nondot.org
Mon Jan 3 16:06:55 PST 2011


Author: lattner
Date: Mon Jan  3 18:06:55 2011
New Revision: 122790

URL: http://llvm.org/viewvc/llvm-project?rev=122790&view=rev
Log:
use the very-handy getTruncateOrZeroExtend helper function, and
stop setting NSW: signed overflow is possible.  Thanks to Dan
for pointing these out.


Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp?rev=122790&r1=122789&r2=122790&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp Mon Jan  3 18:06:55 2011
@@ -349,17 +349,13 @@
   // The # stored bytes is (BECount+1)*Size.  Expand the trip count out to
   // pointer size if it isn't already.
   const Type *IntPtr = TD->getIntPtrType(SI->getContext());
-  unsigned BESize = SE->getTypeSizeInBits(BECount->getType());
-  if (BESize < TD->getPointerSizeInBits())
-    BECount = SE->getZeroExtendExpr(BECount, IntPtr);
-  else if (BESize > TD->getPointerSizeInBits())
-    BECount = SE->getTruncateExpr(BECount, IntPtr);
+  BECount = SE->getTruncateOrZeroExtend(BECount, IntPtr);
   
   const SCEV *NumBytesS = SE->getAddExpr(BECount, SE->getConstant(IntPtr, 1),
-                                         true, true /*nooverflow*/);
+                                         true /*no unsigned overflow*/);
   if (StoreSize != 1)
     NumBytesS = SE->getMulExpr(NumBytesS, SE->getConstant(IntPtr, StoreSize),
-                               true, true /*nooverflow*/);
+                               true /*no unsigned overflow*/);
   
   Value *NumBytes = 
     Expander.expandCodeFor(NumBytesS, IntPtr, Preheader->getTerminator());
@@ -426,17 +422,13 @@
   // The # stored bytes is (BECount+1)*Size.  Expand the trip count out to
   // pointer size if it isn't already.
   const Type *IntPtr = TD->getIntPtrType(SI->getContext());
-  unsigned BESize = SE->getTypeSizeInBits(BECount->getType());
-  if (BESize < TD->getPointerSizeInBits())
-    BECount = SE->getZeroExtendExpr(BECount, IntPtr);
-  else if (BESize > TD->getPointerSizeInBits())
-    BECount = SE->getTruncateExpr(BECount, IntPtr);
+  BECount = SE->getTruncateOrZeroExtend(BECount, IntPtr);
   
   const SCEV *NumBytesS = SE->getAddExpr(BECount, SE->getConstant(IntPtr, 1),
-                                         true, true /*nooverflow*/);
+                                         true /*no unsigned overflow*/);
   if (StoreSize != 1)
     NumBytesS = SE->getMulExpr(NumBytesS, SE->getConstant(IntPtr, StoreSize),
-                               true, true /*nooverflow*/);
+                               true /*no unsigned overflow*/);
   
   Value *NumBytes =
     Expander.expandCodeFor(NumBytesS, IntPtr, Preheader->getTerminator());





More information about the llvm-commits mailing list