[PATCH] D99354: [SimpleLoopUnswitch] Port partially invariant unswitch from LoopUnswitch to SimpleLoopUnswitch

JinGu Kang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 17 03:45:45 PDT 2021


jaykang10 updated this revision to Diff 345815.
jaykang10 added a comment.

The below bugs are fixed.
https://bugs.llvm.org/show_bug.cgi?id=50279
https://bugs.llvm.org/show_bug.cgi?id=50302

Even if this patch does not add the processed loop to loop pass manager again, the later loop transformations create loop with the header, which has partially invariant instructions, and add it to loop pass manager again. The loop pass manager runs SimpleLoopUnswitchPass with the loop again and it sometimes causes endless unswitch with some CFGs.

In order to avoid the endless unswitch, the new change removes the partially invariant instruction from header as below.

  //    +--------------------+
  //    |     preheader      |
  //    |  %a = load %ptr    |
  //    +--------------------+
  //             |     /----------------\
  //    +--------v----v------+          |
  //    |      header        |---\      |
  //    | %c = phi %a, %b    |   |      |
  //    | %cond = cmp %c, .. |   |      |
  //    | br %cond           |   |      |
  //    +--------------------+   |      |
  //             |               |      |
  //    +--------v-----------+   |      |
  //    |  store %ptr        |   |      |
  //    +--------------------+   |      |
  //             |               |      |
  //    +--------v-----------<---/      |
  //    |       latch        >----------/
  //    |  %b = load %ptr    |
  //    +--------------------+


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99354/new/

https://reviews.llvm.org/D99354

Files:
  llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
  llvm/test/Transforms/SimpleLoopUnswitch/endless-unswitch.ll
  llvm/test/Transforms/SimpleLoopUnswitch/partial-unswitch-mssa-threshold.ll
  llvm/test/Transforms/SimpleLoopUnswitch/partial-unswitch-update-memoryssa.ll
  llvm/test/Transforms/SimpleLoopUnswitch/partial-unswitch.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99354.345815.patch
Type: text/x-patch
Size: 57462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210517/bb63d10c/attachment-0001.bin>


More information about the llvm-commits mailing list