[PATCH] D12107: Replace overflow check in loop vectorization with minimum loop iterations check

Adam Nemet via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 18 13:08:37 PDT 2015


anemet added inline comments.

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2538-2540
@@ -2527,16 +2537,5 @@
 
-  // We need to test whether the backedge-taken count is uint##_max. Adding one
-  // to it will cause overflow and an incorrect loop trip count in the vector
-  // body. In case of overflow we want to directly jump to the scalar remainder
-  // loop.
-  Value *BackedgeCount =
-      Exp.expandCodeFor(BackedgeTakeCount, BackedgeTakeCount->getType(),
-                        VectorPH->getTerminator());
-  if (BackedgeCount->getType()->isPointerTy())
-    BackedgeCount = CastInst::CreatePointerCast(BackedgeCount, IdxTy,
-                                                "backedge.ptrcnt.to.int",
-                                                VectorPH->getTerminator());
-  Instruction *CheckBCOverflow =
-      CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ, BackedgeCount,
-                      Constant::getAllOnesValue(BackedgeCount->getType()),
-                      "backedge.overflow", VectorPH->getTerminator());
+  // We test the iteration number and if it is less than MaxVectorSize we want
+  // to directly jump to the scalar remainder loop.
+  Value *ExitCountValue = Exp.expandCodeFor(ExitCount, ExitCount->getType(),
+                                            VectorPH->getTerminator());
----------------
Please don't remove the explanation for the need of checking overflow.

I like your explanation in the review description.  Please include an appropriate variant of that here as a comment.


Repository:
  rL LLVM

http://reviews.llvm.org/D12107





More information about the llvm-commits mailing list