[PATCH] D124394: [DFAJumpThreading] Relax analysis to handle unpredictable initial values

Alexey Zhikhartsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 08:31:00 PDT 2022


alexey.zhikhar created this revision.
alexey.zhikhar added reviewers: amehsan, SjoerdMeijer, nikic, ollef.
Herald added subscribers: JDevlieghere, hiraditya.
Herald added a project: All.
alexey.zhikhar requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Responding to a feature request from the Rust community:

https://github.com/rust-lang/rust/issues/80630

  void foo(X) {
    for (...)
      switch (X)
        case A
          X = B
        case B
          X = C
  }

Even though the initial switch value is non-constant, the switch statement can still be threaded:
the initial value will hit the switch statement but the rest of the state changes will proceed by
jumping unconditionally.

The early predictability check is relaxed to allow unpredictable values anywhere, but later,
after the paths through the switch statement have been enumerated, no non-constant state
values are allowed along the paths. Any state value not along will be an initial switch value,
which can be safely ignored.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124394

Files:
  llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
  llvm/test/Transforms/DFAJumpThreading/dfa-jump-threading-analysis.ll
  llvm/test/Transforms/DFAJumpThreading/negative.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124394.424915.patch
Type: text/x-patch
Size: 10787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220425/94ec5c6c/attachment.bin>


More information about the llvm-commits mailing list