[PATCH] D62110: [LV] prevent potential divide by zero. NFC

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 19 16:59:33 PDT 2019


nickdesaulniers created this revision.
nickdesaulniers added a reviewer: rengolin.
Herald added subscribers: llvm-commits, rkruppe, hiraditya.
Herald added a project: LLVM.

scan-build flags a long chain where if LoopCost is 0, then a division by
zero might occur. Add a quick check after its final assignment before
use.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62110

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp


Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5000,6 +5000,8 @@
   // then we calculate the cost of VF here.
   if (LoopCost == 0)
     LoopCost = expectedCost(VF).first;
+  if (LoopCost == 0)
+    return 1;
 
   // Clamp the calculated IC to be between the 1 and the max interleave count
   // that the target allows.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62110.200187.patch
Type: text/x-patch
Size: 504 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190519/a93247f3/attachment.bin>


More information about the llvm-commits mailing list