[PATCH] D76669: [LoopVectorize] Fix crash on "getNoopOrZeroExtend cannot truncate!" (PR45259)

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 23 22:49:41 PDT 2020


vsk created this revision.
vsk added reviewers: fhahn, nemanjai.
Herald added subscribers: javed.absar, hiraditya.

In `InnerLoopVectorizer::getOrCreateTripCount`, when the backedge taken
count is a SCEV add expression, its type is defined by the type of the
last operand of the add expression.

In the test case from PR45259, this last operand happens to be a
pointer, which (according to llvm::Type) does not have a primitive size
in bits. In this case, LoopVectorize fails to truncate the SCEV and
crashes as a result.

ISTM that the truncation really is needed, and that using
`ScalarEvolution::getTypeSizeInBits` makes the truncation work as
expected. As I'm not really familiar with this code, I'm not sure
whether this is an appropriate or sufficient fix -- any advice
appreciated.

https://bugs.llvm.org/show_bug.cgi?id=45259


https://reviews.llvm.org/D76669

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/pr45259.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76669.252221.patch
Type: text/x-patch
Size: 10346 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200324/a5b327e2/attachment.bin>


More information about the llvm-commits mailing list