[PATCH] D140255: [LoopUnrollAndJam] Visit phi operand dependencies in post-order

Joshua Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 17:56:15 PST 2022


caojoshua created this revision.
Herald added subscribers: zzheng, hiraditya.
Herald added a project: All.
caojoshua edited the summary of this revision.
caojoshua edited the summary of this revision.
caojoshua added reviewers: dmgreen, fhahn.
caojoshua published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fixes https://github.com/llvm/llvm-project/issues/58565

The previous implementation visits operands in pre-order, but this does
not guarantee an instruction is visited before its uses. This can cause
instructions to be copied in the incorrect order. For example:

  a = ...
  b = add a, 1
  c = add a, b
  d = add b, a

Pre-order visits does not guarantee the order in which `a` and `b` are
visited. LoopUnrollAndJam may incorrectly insert `b` before `a`.

This patch implements post-order visits. By visiting dependencies first,
we guarantee that an instruction's dependencies are visited first.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140255

Files:
  llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
  llvm/test/Transforms/LoopUnrollAndJam/dependencies_visit_order.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140255.483699.patch
Type: text/x-patch
Size: 7809 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221217/8bbd0ae2/attachment.bin>


More information about the llvm-commits mailing list