[PATCH] D25075: [JumpThreading] Allow threading over loop headers when creating single block loops

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 3 09:01:32 PDT 2016


jmolloy updated this revision to Diff 73285.
jmolloy added a comment.

Hi Philip,

Thanks for your review. Based on that I was able to go back and re-look with fresh eyes at the problem.

As you mentioned, in the motivating testcase we should have been able to prove that the value of the incremented PHI was always greater than or equal to 3. You were right that this exposed an underlying problem - in fact there were several things I needed to fix:

- LazyValueInfo gets confused by trivial loops. I have added a couple of special cases that I think are very common:
  1. A PHI incoming value that is the PHI itself (%x = phi %x, %y) can be ignored, because it cannot contribute usefully to its own range.
  2. A PHI incoming value that can be trivially proved monotonically increasing (an induction variable for instance) can have its range more precisely calculated.
- JumpThreading should consider all candidates for threading and not just the most profitable one.
  - If the most profitable candidate fails legality checks, it should try others and not simply bail.
- JumpThreading should invalidate LVI when unfolding switches
  - The unfolding changes the CFG and creates new edges that can now have more specific values than before.

Mixed in there is also a change to make JumpThreading use and keep up to date LoopInfo.

This patch is obviously too large, has conflated several concerns and needs to be split apart. However I just wanted to get your input on the direction - is there anything particularly objectionable, before I go split it all out into subpatches?

Cheers,

James


Repository:
  rL LLVM

https://reviews.llvm.org/D25075

Files:
  include/llvm/Transforms/Scalar/JumpThreading.h
  include/llvm/Transforms/Utils/Local.h
  lib/Analysis/LazyValueInfo.cpp
  lib/Transforms/Scalar/JumpThreading.cpp
  lib/Transforms/Utils/BasicBlockUtils.cpp
  lib/Transforms/Utils/Local.cpp
  test/Transforms/JumpThreading/phi-known.ll
  test/Transforms/JumpThreading/singleblock-loop.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25075.73285.patch
Type: text/x-patch
Size: 17374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161003/328893e7/attachment.bin>


More information about the llvm-commits mailing list