<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/test/Transforms/DFAJumpThreading/dfa-jump-threading-analysis.ll, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[DFAJumpThreading] Try harder to avoid cycles in paths. (#169151)</title>
<updated>2025-11-22T18:59:27+00:00</updated>
<author>
<name>Usman Nadeem</name>
<email>mnadeem@qti.qualcomm.com</email>
</author>
<published>2025-11-22T18:59:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8baa5bf499e6bf2f43ec7fddf9601524159ec5ea'/>
<id>8baa5bf499e6bf2f43ec7fddf9601524159ec5ea</id>
<content type='text'>
If a threading path has cycles within it then the transformation is not
correct. This patch fixes a couple of cases that create such cycles.

Fixes https://github.com/llvm/llvm-project/issues/166868</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If a threading path has cycles within it then the transformation is not
correct. This patch fixes a couple of cases that create such cycles.

Fixes https://github.com/llvm/llvm-project/issues/166868</pre>
</div>
</content>
</entry>
<entry>
<title>[DFAJumpThreading] Verify dominator tree by option (#163334)</title>
<updated>2025-10-14T11:52:16+00:00</updated>
<author>
<name>Hongyu Chen</name>
<email>xxs_chy@outlook.com</email>
</author>
<published>2025-10-14T11:52:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=90cbc37905665151216a8b9074ac5e9a411e22c7'/>
<id>90cbc37905665151216a8b9074ac5e9a411e22c7</id>
<content type='text'>
Note that the test coverage misses the dominator tree verification. This
patch controls verification by option, instead of using the
EXPENSIVE_CHECKS macro.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Note that the test coverage misses the dominator tree verification. This
patch controls verification by option, instead of using the
EXPENSIVE_CHECKS macro.</pre>
</div>
</content>
</entry>
<entry>
<title>[DFAJumpThreading] Pretty print anonymous blocks (#162607)</title>
<updated>2025-10-09T08:29:36+00:00</updated>
<author>
<name>Hongyu Chen</name>
<email>xxs_chy@outlook.com</email>
</author>
<published>2025-10-09T08:29:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=daf81a6c0849c797cb28a505826ec22c8c7e4db6'/>
<id>daf81a6c0849c797cb28a505826ec22c8c7e4db6</id>
<content type='text'>
We previously printed the address of anonymous blocks, which makes no
sense for debugging. This patch ensures consistency with the IR printer.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We previously printed the address of anonymous blocks, which makes no
sense for debugging. This patch ensures consistency with the IR printer.</pre>
</div>
</content>
</entry>
<entry>
<title>[DFAJT][profcheck] Propagate `select` -&gt; `br` profile metadata (#162213)</title>
<updated>2025-10-07T16:28:04+00:00</updated>
<author>
<name>Mircea Trofin</name>
<email>mtrofin@google.com</email>
</author>
<published>2025-10-07T16:28:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=278a99e8e9f0baf17b99f4989d2bfa3777fa4d6f'/>
<id>278a99e8e9f0baf17b99f4989d2bfa3777fa4d6f</id>
<content type='text'>
Issue #147390</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Issue #147390</pre>
</div>
</content>
</entry>
<entry>
<title>[DFAJumpThreading] Rewrite the way paths are enumerated (#96127)</title>
<updated>2024-08-10T19:13:53+00:00</updated>
<author>
<name>Usman Nadeem</name>
<email>mnadeem@quicinc.com</email>
</author>
<published>2024-08-10T19:13:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b167ada89631fc18e073c2b6295b10e3085b8c88'/>
<id>b167ada89631fc18e073c2b6295b10e3085b8c88</id>
<content type='text'>
I tried to add a limit to number of blocks visited in the paths()
function but even with a very high limit the transformation coverage was
being reduced.

After looking at the code it seemed that the function was trying to
create paths of the form
`SwitchBB...DeterminatorBB...SwitchPredecessor`. This is inefficient
because a lot of nodes in those paths (nodes before DeterminatorBB)
would be irrelevant to the optimization. We only care about paths of the
form `DeterminatorBB_Pred DeterminatorBB...SwitchBB`. This weeds out a
lot of visited nodes.

In this patch I have added a hard limit to the number of nodes visited
and changed the algorithm for path calculation. Primarily I am
traversing the use-def chain for the PHI nodes that define the state. If
we have a hole in the use-def chain (no immediate predecessors) then I
call the paths() function.

I also had to the change the select instruction unfolding code to insert
redundant one input PHIs to allow the use of the use-def chain in
calculating the paths.

The test suite coverage with this patch (including a limit on nodes
visited) is as follows:

    Geomean diff:
      dfa-jump-threading.NumTransforms: +13.4%
      dfa-jump-threading.NumCloned: +34.1%
      dfa-jump-threading.NumPaths: -80.7%

Compile time effect vs baseline (pass enabled by default) is mostly
positive:
https://llvm-compile-time-tracker.com/compare.php?from=ad8705fda25f64dcfeb6264ac4d6bac36bee91ab&amp;to=5a3af6ce7e852f0736f706b4a8663efad5bce6ea&amp;stat=instructions:u

Change-Id: I0fba9e0f8aa079706f633089a8ccd4ecf57547ed</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I tried to add a limit to number of blocks visited in the paths()
function but even with a very high limit the transformation coverage was
being reduced.

After looking at the code it seemed that the function was trying to
create paths of the form
`SwitchBB...DeterminatorBB...SwitchPredecessor`. This is inefficient
because a lot of nodes in those paths (nodes before DeterminatorBB)
would be irrelevant to the optimization. We only care about paths of the
form `DeterminatorBB_Pred DeterminatorBB...SwitchBB`. This weeds out a
lot of visited nodes.

In this patch I have added a hard limit to the number of nodes visited
and changed the algorithm for path calculation. Primarily I am
traversing the use-def chain for the PHI nodes that define the state. If
we have a hole in the use-def chain (no immediate predecessors) then I
call the paths() function.

I also had to the change the select instruction unfolding code to insert
redundant one input PHIs to allow the use of the use-def chain in
calculating the paths.

The test suite coverage with this patch (including a limit on nodes
visited) is as follows:

    Geomean diff:
      dfa-jump-threading.NumTransforms: +13.4%
      dfa-jump-threading.NumCloned: +34.1%
      dfa-jump-threading.NumPaths: -80.7%

Compile time effect vs baseline (pass enabled by default) is mostly
positive:
https://llvm-compile-time-tracker.com/compare.php?from=ad8705fda25f64dcfeb6264ac4d6bac36bee91ab&amp;to=5a3af6ce7e852f0736f706b4a8663efad5bce6ea&amp;stat=instructions:u

Change-Id: I0fba9e0f8aa079706f633089a8ccd4ecf57547ed</pre>
</div>
</content>
</entry>
<entry>
<title>[Transforms] Convert some tests to opaque pointers (NFC)</title>
<updated>2023-01-05T11:43:45+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2023-01-05T11:35:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=055fb7795aa219a3d274d280ec9129784f169f56'/>
<id>055fb7795aa219a3d274d280ec9129784f169f56</id>
<content type='text'>
These are all tests where conversion worked automatically, and
required no manual fixup.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These are all tests where conversion worked automatically, and
required no manual fixup.
</pre>
</div>
</content>
</entry>
<entry>
<title>[NFC] Port all DFAJumpThreading tests to `-passes=` syntax</title>
<updated>2022-12-07T23:38:41+00:00</updated>
<author>
<name>Roman Lebedev</name>
<email>lebedev.ri@gmail.com</email>
</author>
<published>2022-12-07T23:27:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=641a684fa0930074b32f17672e69486943a80c81'/>
<id>641a684fa0930074b32f17672e69486943a80c81</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[DFAJumpThreading] Relax analysis to handle unpredictable initial values</title>
<updated>2022-05-26T15:29:54+00:00</updated>
<author>
<name>Alex Zhikhartsev</name>
<email>alex.zhi@huawei.com</email>
</author>
<published>2022-05-25T23:10:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8b0d7634743965948234b666c77393d4dd8535d7'/>
<id>8b0d7634743965948234b666c77393d4dd8535d7</id>
<content type='text'>
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 a path will be an initial switch value,
which can be safely ignored.

Differential Revision: https://reviews.llvm.org/D124394
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 a path will be an initial switch value,
which can be safely ignored.

Differential Revision: https://reviews.llvm.org/D124394
</pre>
</div>
</content>
</entry>
<entry>
<title>[DFAJumpThreading] Determinator BB should precede switch-defining BB</title>
<updated>2021-12-24T15:27:03+00:00</updated>
<author>
<name>Alexey Zhikhartsev</name>
<email>alex.zhi@huawei.com</email>
</author>
<published>2021-12-15T17:14:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d5dc3964a7417a34fe581d93ff9642923f8a634d'/>
<id>d5dc3964a7417a34fe581d93ff9642923f8a634d</id>
<content type='text'>
Otherwise, it is possible that the state defined in the determinator
block defines the state for the next iteration of the loop, rather than
for the current one.

Fixes llvm-test-suite's
SingleSource/Regression/C/gcc-c-torture/execute/pr80421.c

Differential Revision: https://reviews.llvm.org/D115832
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Otherwise, it is possible that the state defined in the determinator
block defines the state for the next iteration of the loop, rather than
for the current one.

Fixes llvm-test-suite's
SingleSource/Regression/C/gcc-c-torture/execute/pr80421.c

Differential Revision: https://reviews.llvm.org/D115832
</pre>
</div>
</content>
</entry>
<entry>
<title>Add jump-threading optimization for deterministic finite automata</title>
<updated>2021-07-27T18:34:04+00:00</updated>
<author>
<name>Alexey Zhikhartsev</name>
<email>alex.zhi@huawei.com</email>
</author>
<published>2021-07-27T18:26:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=02077da7e7a8ff76c0576bb33adb462c337013f5'/>
<id>02077da7e7a8ff76c0576bb33adb462c337013f5</id>
<content type='text'>
The current JumpThreading pass does not jump thread loops since it can
result in irreducible control flow that harms other optimizations. This
prevents switch statements inside a loop from being optimized to use
unconditional branches.

This code pattern occurs in the core_state_transition function of
Coremark. The state machine can be implemented manually with goto
statements resulting in a large runtime improvement, and this transform
makes the switch implementation match the goto version in performance.

This patch specifically targets switch statements inside a loop that
have the opportunity to be threaded. Once it identifies an opportunity,
it creates new paths that branch directly to the correct code block.
For example, the left CFG could be transformed to the right CFG:

```
          sw.bb                        sw.bb
        /   |   \                    /   |   \
   case1  case2  case3          case1  case2  case3
        \   |   /                /       |       \
        latch.bb             latch.2  latch.3  latch.1
         br sw.bb              /         |         \
                           sw.bb.2     sw.bb.3     sw.bb.1
                            br case2    br case3    br case1
```

Co-author: Justin Kreiner @jkreiner
Co-author: Ehsan Amiri @amehsan

Reviewed By: SjoerdMeijer

Differential Revision: https://reviews.llvm.org/D99205
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The current JumpThreading pass does not jump thread loops since it can
result in irreducible control flow that harms other optimizations. This
prevents switch statements inside a loop from being optimized to use
unconditional branches.

This code pattern occurs in the core_state_transition function of
Coremark. The state machine can be implemented manually with goto
statements resulting in a large runtime improvement, and this transform
makes the switch implementation match the goto version in performance.

This patch specifically targets switch statements inside a loop that
have the opportunity to be threaded. Once it identifies an opportunity,
it creates new paths that branch directly to the correct code block.
For example, the left CFG could be transformed to the right CFG:

```
          sw.bb                        sw.bb
        /   |   \                    /   |   \
   case1  case2  case3          case1  case2  case3
        \   |   /                /       |       \
        latch.bb             latch.2  latch.3  latch.1
         br sw.bb              /         |         \
                           sw.bb.2     sw.bb.3     sw.bb.1
                            br case2    br case3    br case1
```

Co-author: Justin Kreiner @jkreiner
Co-author: Ehsan Amiri @amehsan

Reviewed By: SjoerdMeijer

Differential Revision: https://reviews.llvm.org/D99205
</pre>
</div>
</content>
</entry>
</feed>
