[PATCH] D106852: [SCEV] Fix getAddExpr for adding loop invariants into start of some AddRec

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 27 00:29:31 PDT 2021


skatkov created this revision.
skatkov added reviewers: reames, nikic, efriedma, fhahn, mkazantsev.
Herald added a subscriber: hiraditya.
skatkov requested review of this revision.
Herald added a project: LLVM.

getAddExpr utility uses computed flags from AddRec plus loop invariants
in AddRec.Start + loop invariants basing on the an assumption that
0th iteration of the loop exists. However the loop might be dead
(runtime or compile time), in this case the propagation of the flag becomes
invalid.

To fix the bug we need to ensure that 0th iteration happens or use less
strict set of flags.
The patch uses the check for dominating all latches from used loops to ensure
that 0th iteration exists.


https://reviews.llvm.org/D106852

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/nuw-add-nested-loops.ll
  llvm/test/Analysis/ScalarEvolution/nuw-add-sibling-loops.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106852.361923.patch
Type: text/x-patch
Size: 6517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210727/f00a25fa/attachment.bin>


More information about the llvm-commits mailing list