[PATCH] D101305: [LoopInterchange] Fix legality for triangular loops

Congzhe Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 26 09:45:29 PDT 2021


congzhe created this revision.
congzhe added reviewers: bmahjour, Whitney, fhahn.
congzhe added a project: LLVM.
Herald added a subscriber: hiraditya.
congzhe requested review of this revision.
Herald added a subscriber: llvm-commits.

This is a bug fix in legality check.

When we encounter triangular loops such as the following form:

  for (int i = 0; i < m; i++)
    for (int j = 0; j < i; j++), or
  
  for (int i = 0; i < m; i++)
    for (int j = 0; j*i < n; j++),

we should not perform interchange since the number of executions of the loop body 
will be different before and after interchange, resulting in incorrect results.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101305

Files:
  llvm/lib/Transforms/Scalar/LoopInterchange.cpp
  llvm/test/Transforms/LoopInterchange/inner-indvar-depend-on-outer-indvar.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101305.340566.patch
Type: text/x-patch
Size: 4866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210426/ed17cf98/attachment.bin>


More information about the llvm-commits mailing list