[PATCH] D93764: [LoopUnswitch] Implement first version of partial unswitching.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 1 07:12:26 PST 2021


fhahn updated this revision to Diff 314219.
fhahn added a comment.

In D93764#2473944 <https://reviews.llvm.org/D93764#2473944>, @jdoerfert wrote:

> Overall, I think this is the right place for such logic. Some initial code comments.

Thanks for taking a look!

> TBH, I think it would be nicer to "search for the paths" instead. Though, a TODO might be sufficient for the start.

Do you mean not using MemorySSA initially? In a way, the current approach first collects all blocks on a path and then walks MemorySSA downwards to check all potential clobbers in blocks on the path. Instead of that, we could just iterate over all instructions in the blocks and bail out if any has side-effects, as in the original version.

The main advantage of the MemorySSA version is that it allows us to just check the potentially clobbering instructions, so this is mostly an optimization. If it makes things easier, that could be done as a separate patch?

> What I think would be nice if we do not only deal with the conditional in the header, still thinking of `*l && *r`.

IIUC there are 2 things that could be improved: currently the condition must be an `icmp`, but this is mostly an artificial initial restriction that is easy to lift subsequently, e.g. to allow `OR/AND` instructions as conditions.

And we could also look for conditional branches in other blocks than the header. There very likely will be cases where this helps, but I am not sure how frequently it will trigger compared to the additional compile-time spent. Certainly something to explore further though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93764

Files:
  llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
  llvm/test/Transforms/LoopUnswitch/partial-unswitch.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93764.314219.patch
Type: text/x-patch
Size: 33864 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210101/8782ab9a/attachment.bin>


More information about the llvm-commits mailing list