<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp, 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>[mlir][SCF] Fix UB adjustment during `scf.for` loop peeling</title>
<updated>2025-10-20T16:18:08+00:00</updated>
<author>
<name>ddubov100</name>
<email>155631080+ddubov100@users.noreply.github.com</email>
</author>
<published>2025-10-20T16:18:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=af4fbcaed7acb58119f67c0055e80accdd2b70dc'/>
<id>af4fbcaed7acb58119f67c0055e80accdd2b70dc</id>
<content type='text'>
Currently when peeling the first iteration, any mentioning of UB within the loop body is replaced with the new UB in the peeled out first iteration. This introduces a bug in the following scenario: Operations inside of the loop that intentionally use the original UB are incorrectly updated.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently when peeling the first iteration, any mentioning of UB within the loop body is replaced with the new UB in the peeled out first iteration. This introduces a bug in the following scenario: Operations inside of the loop that intentionally use the original UB are incorrectly updated.
</pre>
</div>
</content>
</entry>
<entry>
<title>[MLIR] Fix SCF loop specialization (peeling) to work on scf.for with non-index type (#158707)</title>
<updated>2025-09-16T12:09:07+00:00</updated>
<author>
<name>Mehdi Amini</name>
<email>joker.eph@gmail.com</email>
</author>
<published>2025-09-16T12:09:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=fba26bc1a5cf7cf367474965c144659f62588e7d'/>
<id>fba26bc1a5cf7cf367474965c144659f62588e7d</id>
<content type='text'>
The current code would crash with integer. This is visible on this
modified example (the original with index was incorrect)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The current code would crash with integer. This is visible on this
modified example (the original with index was incorrect)</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][SCF] `scf.for`: Add support for unsigned integer comparison (#153379)</title>
<updated>2025-08-15T08:59:14+00:00</updated>
<author>
<name>Matthias Springer</name>
<email>me@m-sp.org</email>
</author>
<published>2025-08-15T08:59:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=21b607adbeb4326c10f899fb293d057ee1199794'/>
<id>21b607adbeb4326c10f899fb293d057ee1199794</id>
<content type='text'>
Add a new unit attribute to allow for unsigned integer comparison.

Example:
```mlir
scf.for unsigned %iv_32 = %lb_32 to %ub_32 step %step_32 : i32 {
  // body
}
```

Discussion:
https://discourse.llvm.org/t/scf-should-scf-for-support-unsigned-comparison/84655</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a new unit attribute to allow for unsigned integer comparison.

Example:
```mlir
scf.for unsigned %iv_32 = %lb_32 to %ub_32 step %step_32 : i32 {
  // body
}
```

Discussion:
https://discourse.llvm.org/t/scf-should-scf-for-support-unsigned-comparison/84655</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][NFC] update `mlir/Dialect` create APIs (20/n) (#149927)</title>
<updated>2025-07-24T12:09:58+00:00</updated>
<author>
<name>Maksim Levental</name>
<email>maksim.levental@gmail.com</email>
</author>
<published>2025-07-24T12:09:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=588845defd09359a8b87db339b563af848cf45a7'/>
<id>588845defd09359a8b87db339b563af848cf45a7</id>
<content type='text'>
See https://github.com/llvm/llvm-project/pull/147168 for more info.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
See https://github.com/llvm/llvm-project/pull/147168 for more info.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir] Remove unused includes (NFC) (#148769)</title>
<updated>2025-07-15T05:19:23+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2025-07-15T05:19:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c06d3a7b728293cbc53ff91239d6cd87c0982ffb'/>
<id>c06d3a7b728293cbc53ff91239d6cd87c0982ffb</id>
<content type='text'>
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir] Enable decoupling two kinds of greedy behavior. (#104649)</title>
<updated>2024-12-20T16:15:48+00:00</updated>
<author>
<name>Jacques Pienaar</name>
<email>jpienaar@google.com</email>
</author>
<published>2024-12-20T16:15:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=09dfc5713d7e2342bea4c8447d1ed76c85eb8225'/>
<id>09dfc5713d7e2342bea4c8447d1ed76c85eb8225</id>
<content type='text'>
The greedy rewriter is used in many different flows and it has a lot of
convenience (work list management, debugging actions, tracing, etc). But
it combines two kinds of greedy behavior 1) how ops are matched, 2)
folding wherever it can.

These are independent forms of greedy and leads to inefficiency. E.g.,
cases where one need to create different phases in lowering and is
required to applying patterns in specific order split across different
passes. Using the driver one ends up needlessly retrying folding/having
multiple rounds of folding attempts, where one final run would have
sufficed.

Of course folks can locally avoid this behavior by just building their
own, but this is also a common requested feature that folks keep on
working around locally in suboptimal ways.

For downstream users, there should be no behavioral change. Updating
from the deprecated should just be a find and replace (e.g., `find ./
-type f -exec sed -i
's|applyPatternsAndFoldGreedily|applyPatternsGreedily|g' {} \;` variety)
as the API arguments hasn't changed between the two.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The greedy rewriter is used in many different flows and it has a lot of
convenience (work list management, debugging actions, tracing, etc). But
it combines two kinds of greedy behavior 1) how ops are matched, 2)
folding wherever it can.

These are independent forms of greedy and leads to inefficiency. E.g.,
cases where one need to create different phases in lowering and is
required to applying patterns in specific order split across different
passes. Using the driver one ends up needlessly retrying folding/having
multiple rounds of folding attempts, where one final run would have
sufficed.

Of course folks can locally avoid this behavior by just building their
own, but this is also a common requested feature that folks keep on
working around locally in suboptimal ways.

For downstream users, there should be no behavioral change. Updating
from the deprecated should just be a find and replace (e.g., `find ./
-type f -exec sed -i
's|applyPatternsAndFoldGreedily|applyPatternsGreedily|g' {} \;` variety)
as the API arguments hasn't changed between the two.</pre>
</div>
</content>
</entry>
<entry>
<title>[MLIR][SCF] Fix LoopPeelOp documentation (NFC) (#113179)</title>
<updated>2024-10-29T15:47:13+00:00</updated>
<author>
<name>Hugo Trachino</name>
<email>hugo.trachino@huawei.com</email>
</author>
<published>2024-10-29T15:47:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a9c417c28a25c153aa0fdbe2eb5453a93820a3b1'/>
<id>a9c417c28a25c153aa0fdbe2eb5453a93820a3b1</id>
<content type='text'>
As an example, I added annotations to the peel_front unit test.

```
func.func @loop_peel_first_iter_op() {
  // CHECK: %[[C0:.+]] = arith.constant 0
  // CHECK: %[[C41:.+]] = arith.constant 41
  // CHECK: %[[C5:.+]] = arith.constant 5
  // CHECK: %[[C5_0:.+]] = arith.constant 5
  // CHECK: scf.for %{{.+}} = %[[C0]] to %[[C5_0]] step %[[C5]]
  // CHECK:   arith.addi
  // CHECK: scf.for %{{.+}} = %[[C5_0]] to %[[C41]] step %[[C5]]
  // CHECK:   arith.addi
  %0 = arith.constant 0 : index
  %1 = arith.constant 41 : index
  %2 = arith.constant 5 : index
  scf.for %i = %0 to %1 step %2 {
    arith.addi %i, %i : index
  }
  return
}

module attributes {transform.with_named_sequence} {
  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
    %0 = transform.structured.match ops{["arith.addi"]} in %arg1 : (!transform.any_op) -&gt; !transform.any_op
    %1 = transform.get_parent_op %0 {op_name = "scf.for"} : (!transform.any_op) -&gt; !transform.op&lt;"scf.for"&gt;
    %main_loop, %remainder = transform.loop.peel %1 {peel_front = true} : (!transform.op&lt;"scf.for"&gt;) -&gt; (!transform.op&lt;"scf.for"&gt;, !transform.op&lt;"scf.for"&gt;)
    transform.annotate %main_loop "main_loop" : !transform.op&lt;"scf.for"&gt;
    transform.annotate %remainder "remainder" : !transform.op&lt;"scf.for"&gt;
    transform.yield
  }
}
```
Gives :
```
  func.func @loop_peel_first_iter_op() {
    %c0 = arith.constant 0 : index
    %c41 = arith.constant 41 : index
    %c5 = arith.constant 5 : index
    %c5_0 = arith.constant 5 : index
    scf.for %arg0 = %c0 to %c5_0 step %c5 {
      %0 = arith.addi %arg0, %arg0 : index
    } {remainder}  // The first iteration loop (second result) has been annotated remainder
    scf.for %arg0 = %c5_0 to %c41 step %c5 {
      %0 = arith.addi %arg0, %arg0 : index
    } {main_loop} // The main loop (first result) has been annotated main_loop
    return
  }
```

---------

Co-authored-by: Andrzej Warzyński &lt;andrzej.warzynski@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As an example, I added annotations to the peel_front unit test.

```
func.func @loop_peel_first_iter_op() {
  // CHECK: %[[C0:.+]] = arith.constant 0
  // CHECK: %[[C41:.+]] = arith.constant 41
  // CHECK: %[[C5:.+]] = arith.constant 5
  // CHECK: %[[C5_0:.+]] = arith.constant 5
  // CHECK: scf.for %{{.+}} = %[[C0]] to %[[C5_0]] step %[[C5]]
  // CHECK:   arith.addi
  // CHECK: scf.for %{{.+}} = %[[C5_0]] to %[[C41]] step %[[C5]]
  // CHECK:   arith.addi
  %0 = arith.constant 0 : index
  %1 = arith.constant 41 : index
  %2 = arith.constant 5 : index
  scf.for %i = %0 to %1 step %2 {
    arith.addi %i, %i : index
  }
  return
}

module attributes {transform.with_named_sequence} {
  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
    %0 = transform.structured.match ops{["arith.addi"]} in %arg1 : (!transform.any_op) -&gt; !transform.any_op
    %1 = transform.get_parent_op %0 {op_name = "scf.for"} : (!transform.any_op) -&gt; !transform.op&lt;"scf.for"&gt;
    %main_loop, %remainder = transform.loop.peel %1 {peel_front = true} : (!transform.op&lt;"scf.for"&gt;) -&gt; (!transform.op&lt;"scf.for"&gt;, !transform.op&lt;"scf.for"&gt;)
    transform.annotate %main_loop "main_loop" : !transform.op&lt;"scf.for"&gt;
    transform.annotate %remainder "remainder" : !transform.op&lt;"scf.for"&gt;
    transform.yield
  }
}
```
Gives :
```
  func.func @loop_peel_first_iter_op() {
    %c0 = arith.constant 0 : index
    %c41 = arith.constant 41 : index
    %c5 = arith.constant 5 : index
    %c5_0 = arith.constant 5 : index
    scf.for %arg0 = %c0 to %c5_0 step %c5 {
      %0 = arith.addi %arg0, %arg0 : index
    } {remainder}  // The first iteration loop (second result) has been annotated remainder
    scf.for %arg0 = %c5_0 to %c41 step %c5 {
      %0 = arith.addi %arg0, %arg0 : index
    } {main_loop} // The main loop (first result) has been annotated main_loop
    return
  }
```

---------

Co-authored-by: Andrzej Warzyński &lt;andrzej.warzynski@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Fix the condition for peeling the first iteration (#86350)</title>
<updated>2024-03-25T16:53:57+00:00</updated>
<author>
<name>Vivian</name>
<email>zhyuhang88@gmail.com</email>
</author>
<published>2024-03-25T16:53:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a9d1fead961440d415f931bc22c160dec88e03fd'/>
<id>a9d1fead961440d415f931bc22c160dec88e03fd</id>
<content type='text'>
This PR fixes the condition used in loop peeling of the first iteration.
Using ceilDiv instead of floorDiv when calculating the loop counts, so
that the first iteration gets peeled as needed.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR fixes the condition used in loop peeling of the first iteration.
Using ceilDiv instead of floorDiv when calculating the loop counts, so
that the first iteration gets peeled as needed.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][IR] Rename "update root" to "modify op" in rewriter API (#78260)</title>
<updated>2024-01-17T10:08:59+00:00</updated>
<author>
<name>Matthias Springer</name>
<email>me@m-sp.org</email>
</author>
<published>2024-01-17T10:08:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=5fcf907b34355980f77d7665a175b05fea7a6b7b'/>
<id>5fcf907b34355980f77d7665a175b05fea7a6b7b</id>
<content type='text'>
This commit renames 4 pattern rewriter API functions:
* `updateRootInPlace` -&gt; `modifyOpInPlace`
* `startRootUpdate` -&gt; `startOpModification`
* `finalizeRootUpdate` -&gt; `finalizeOpModification`
* `cancelRootUpdate` -&gt; `cancelOpModification`

The term "root" is a misnomer. The root is the op that a rewrite pattern
matches against
(https://mlir.llvm.org/docs/PatternRewriter/#root-operation-name-optional).
A rewriter must be notified of all in-place op modifications, not just
in-place modifications of the root
(https://mlir.llvm.org/docs/PatternRewriter/#pattern-rewriter). The old
function names were confusing and have contributed to various broken
rewrite patterns.

Note: The new function names use the term "modify" instead of "update"
for consistency with the `RewriterBase::Listener` terminology
(`notifyOperationModified`).</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit renames 4 pattern rewriter API functions:
* `updateRootInPlace` -&gt; `modifyOpInPlace`
* `startRootUpdate` -&gt; `startOpModification`
* `finalizeRootUpdate` -&gt; `finalizeOpModification`
* `cancelRootUpdate` -&gt; `cancelOpModification`

The term "root" is a misnomer. The root is the op that a rewrite pattern
matches against
(https://mlir.llvm.org/docs/PatternRewriter/#root-operation-name-optional).
A rewriter must be notified of all in-place op modifications, not just
in-place modifications of the root
(https://mlir.llvm.org/docs/PatternRewriter/#pattern-rewriter). The old
function names were confusing and have contributed to various broken
rewrite patterns.

Note: The new function names use the term "modify" instead of "update"
for consistency with the `RewriterBase::Listener` terminology
(`notifyOperationModified`).</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][scf] Fix `for-loop-peeling` crash (#77697)</title>
<updated>2024-01-12T18:08:16+00:00</updated>
<author>
<name>Felix Schneider</name>
<email>fx.schn@gmail.com</email>
</author>
<published>2024-01-12T18:08:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f6f1ab9d90252f9b943e77a64e30a3d26ef7cbbb'/>
<id>f6f1ab9d90252f9b943e77a64e30a3d26ef7cbbb</id>
<content type='text'>
Before applying the peeling patterns, it can happen that the `ForOp`
gets a step of zero during folding. This leads to a division-by-zero
down the line.

This patch adds an additional check for a constant-zero step and a
 test.

Fix https://github.com/llvm/llvm-project/issues/75758</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Before applying the peeling patterns, it can happen that the `ForOp`
gets a step of zero during folding. This leads to a division-by-zero
down the line.

This patch adds an additional check for a constant-zero step and a
 test.

Fix https://github.com/llvm/llvm-project/issues/75758</pre>
</div>
</content>
</entry>
</feed>
