<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/mlir/test/Conversion/ArithToLLVM, 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>Add 'exact' flag to arith.shrui/shrsi/divsi/divui operations (#165923)</title>
<updated>2025-11-17T17:46:39+00:00</updated>
<author>
<name>Jeremy Furtek</name>
<email>jfurtek@nvidia.com</email>
</author>
<published>2025-11-17T17:46:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a770d2b439ec246002cd77ce33e52f6efa577849'/>
<id>a770d2b439ec246002cd77ce33e52f6efa577849</id>
<content type='text'>
This MR adds support for the `exact` flag to the
`arith.shrui/shrsi/divsi/divui` operations. The semantics are identical
to those of the LLVM dialect and the LLVM language reference.

This MR also modifies the mechanism for converting `arith` dialect
**attributes** to corresponding **properties** in the `LLVM` dialect.
(As a specific example, the integer overflow flags `nsw/nuw` are
**properties** in the `LLVM` dialect, as opposed to attributes.)

Previously, attribute converter classes were required to have a specific
method to support integer overflow flags:
```C++
template &lt;typename SourceOp, typename TargetOp&gt;
class AttrConvertPassThrough {
public:
  ...
  LLVM::IntegerOverflowFlags getOverflowFlags() const {
    return LLVM::IntegerOverflowFlags::none;
  }
};
```
This method was required, even for `arith` source operations that did
not use integer overflow flags (e.g. `AttrConvertFastMathToLLVM`).

This MR modifies the interface required by `arith` dialect attribute
converters to instead provide a (possibly NULL) properties attribute:
```C++
template &lt;typename SourceOp, typename TargetOp&gt;
class AttrConvertPassThrough {
public:
  ...
  Attribute getPropAttr() const { return {}; }
};
```
For `arith` operations with attributes that map to `LLVM` dialect
**properties**, the attribute converter can create a `DictionaryAttr`
containing target properties and return that attribute from the
attribute converter's `getPropAttr()` method. The `arith` attribute
conversion framework will set the `propertiesAttr` of an
`OperationState`, and the target operation's `setPropertiesFromAttr()`
method will be invoked to set the properties when the target operation
is created. The `AttrConvertOverflowToLLVM` class in this MR uses the
new approach.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This MR adds support for the `exact` flag to the
`arith.shrui/shrsi/divsi/divui` operations. The semantics are identical
to those of the LLVM dialect and the LLVM language reference.

This MR also modifies the mechanism for converting `arith` dialect
**attributes** to corresponding **properties** in the `LLVM` dialect.
(As a specific example, the integer overflow flags `nsw/nuw` are
**properties** in the `LLVM` dialect, as opposed to attributes.)

Previously, attribute converter classes were required to have a specific
method to support integer overflow flags:
```C++
template &lt;typename SourceOp, typename TargetOp&gt;
class AttrConvertPassThrough {
public:
  ...
  LLVM::IntegerOverflowFlags getOverflowFlags() const {
    return LLVM::IntegerOverflowFlags::none;
  }
};
```
This method was required, even for `arith` source operations that did
not use integer overflow flags (e.g. `AttrConvertFastMathToLLVM`).

This MR modifies the interface required by `arith` dialect attribute
converters to instead provide a (possibly NULL) properties attribute:
```C++
template &lt;typename SourceOp, typename TargetOp&gt;
class AttrConvertPassThrough {
public:
  ...
  Attribute getPropAttr() const { return {}; }
};
```
For `arith` operations with attributes that map to `LLVM` dialect
**properties**, the attribute converter can create a `DictionaryAttr`
containing target properties and return that attribute from the
attribute converter's `getPropAttr()` method. The `arith` attribute
conversion framework will set the `propertiesAttr` of an
`OperationState`, and the target operation's `setPropertiesFromAttr()`
method will be invoked to set the properties when the target operation
is created. The `AttrConvertOverflowToLLVM` class in this MR uses the
new approach.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][arith] Fix `arith.select` lowering after #166513 (#166692)</title>
<updated>2025-11-07T17:59:55+00:00</updated>
<author>
<name>Matthias Springer</name>
<email>me@m-sp.org</email>
</author>
<published>2025-11-07T17:59:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=37403685298bd3a7ba2c482b4d6fc26fa0491e19'/>
<id>37403685298bd3a7ba2c482b4d6fc26fa0491e19</id>
<content type='text'>
#166513 broke the lowering of `arith.select` with unsupported FP4 types.
For this op, it is fine to convert to `i4`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
#166513 broke the lowering of `arith.select` with unsupported FP4 types.
For this op, it is fine to convert to `i4`.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][LLVM] Fix unsupported FP lowering in `VectorConvertToLLVMPattern` (#166513)</title>
<updated>2025-11-05T12:24:59+00:00</updated>
<author>
<name>Matthias Springer</name>
<email>me@m-sp.org</email>
</author>
<published>2025-11-05T12:24:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6c640b86e6e03298385231cb7e77d2f3524bc643'/>
<id>6c640b86e6e03298385231cb7e77d2f3524bc643</id>
<content type='text'>
Fixes a bug in `VectorConvertToLLVMPattern`, which converted operations
with unsupported FP types. E.g., `arith.addf ... : f4E2M1FN` was lowered
to `llvm.fadd ... : i4`, which does not verify. There are a few more
patterns that have the same bug. Those will be fixed in follow-up PRs.

This commit is in preparation of adding an `APFloat`-based lowering for
`arith` operations with unsupported floating-point types.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes a bug in `VectorConvertToLLVMPattern`, which converted operations
with unsupported FP types. E.g., `arith.addf ... : f4E2M1FN` was lowered
to `llvm.fadd ... : i4`, which does not verify. There are a few more
patterns that have the same bug. Those will be fixed in follow-up PRs.

This commit is in preparation of adding an `APFloat`-based lowering for
`arith` operations with unsupported floating-point types.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][LLVM] `ArithToLLVM`: Add 1:N support for `arith.select` lowering (#153944)</title>
<updated>2025-08-18T07:42:37+00:00</updated>
<author>
<name>Matthias Springer</name>
<email>me@m-sp.org</email>
</author>
<published>2025-08-18T07:42:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f7b09ad700f2d8ae9ad230f6fc85de81e3a6565b'/>
<id>f7b09ad700f2d8ae9ad230f6fc85de81e3a6565b</id>
<content type='text'>
Add 1:N support for the `arith.select` lowering. Only cases where the
entire true/false value is selected are supported.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add 1:N support for the `arith.select` lowering. Only cases where the
entire true/false value is selected are supported.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][Transforms] Dialect Conversion Driver without Rollback (#151865)</title>
<updated>2025-08-13T15:40:55+00:00</updated>
<author>
<name>Matthias Springer</name>
<email>me@m-sp.org</email>
</author>
<published>2025-08-13T15:40:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=7e7c9d975ebc482f176314347d12b4007b46d808'/>
<id>7e7c9d975ebc482f176314347d12b4007b46d808</id>
<content type='text'>
This commit improves the `allowPatternRollback` flag handling in the
dialect conversion driver. Previously, this flag was used to merely
detect cases that are incompatible with the new One-Shot Dialect
Conversion driver. This commit implements the driver itself: when the
flag is set to "false", all IR changes are materialized immediately,
bypassing the `IRRewrite` and `ConversionValueMapping` infrastructure.

A few selected test cases now run with both the old and the new driver.

RFC:
https://discourse.llvm.org/t/rfc-a-new-one-shot-dialect-conversion-driver/79083</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit improves the `allowPatternRollback` flag handling in the
dialect conversion driver. Previously, this flag was used to merely
detect cases that are incompatible with the new One-Shot Dialect
Conversion driver. This commit implements the driver itself: when the
flag is set to "false", all IR changes are materialized immediately,
bypassing the `IRRewrite` and `ConversionValueMapping` infrastructure.

A few selected test cases now run with both the old and the new driver.

RFC:
https://discourse.llvm.org/t/rfc-a-new-one-shot-dialect-conversion-driver/79083</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][arith] Add overflow flags to `arith.trunci` (#144863)</title>
<updated>2025-06-19T11:59:22+00:00</updated>
<author>
<name>Matthias Springer</name>
<email>me@m-sp.org</email>
</author>
<published>2025-06-19T11:59:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=e33f13ba4824d807e846e7783a48efd6c0bf58ee'/>
<id>e33f13ba4824d807e846e7783a48efd6c0bf58ee</id>
<content type='text'>
LLVM already supports overflow flags on `llvm.trunc` for a while. This
commit adds support for these flags to `arith.trunci`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
LLVM already supports overflow flags on `llvm.trunc` for a while. This
commit adds support for these flags to `arith.trunci`.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir] [arith] Fix ceildivsi lowering in arith-expand (#133774)</title>
<updated>2025-04-02T16:26:58+00:00</updated>
<author>
<name>Fehr Mathieu</name>
<email>mathieu.fehr@gmail.com</email>
</author>
<published>2025-04-02T16:26:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8b67f362583db5f9ace7238bcc174ec6cd11527f'/>
<id>8b67f362583db5f9ace7238bcc174ec6cd11527f</id>
<content type='text'>
This fixes the current lowering of `arith.ceildivsi` in the arith-expand
pass, which was previously incorrect. The new version is based on the
lowering of `arith.floordivsi`, and will not introduce new undefined
behavior or poison during the lowering. It also replaces one division
with a multiplication.

The previous lowering of `ceildivsi(n, m)` was the following:
```
x = (m &gt; 0) ? -1 : 1
(n*m&gt;0) ? ((n+x) / m) + 1 : - (-n / m)
```

This caused two problems:
* In the case where `n` is INT_MIN and `m` is positive, the result would
be poison instead of an actual value
* In the case where `n` is INT_MAX and `m` is `-1`, this would trigger
undefined behavior, while the original code wouldn't. This is because
`n+x` would be equal to `INT_MIN` (`INT_MAX + 1`), so the `(n+x) / m`
division would overflow and trigger UB.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This fixes the current lowering of `arith.ceildivsi` in the arith-expand
pass, which was previously incorrect. The new version is based on the
lowering of `arith.floordivsi`, and will not introduce new undefined
behavior or poison during the lowering. It also replaces one division
with a multiplication.

The previous lowering of `ceildivsi(n, m)` was the following:
```
x = (m &gt; 0) ? -1 : 1
(n*m&gt;0) ? ((n+x) / m) + 1 : - (-n / m)
```

This caused two problems:
* In the case where `n` is INT_MIN and `m` is positive, the result would
be poison instead of an actual value
* In the case where `n` is INT_MAX and `m` is `-1`, this would trigger
undefined behavior, while the original code wouldn't. This is because
`n+x` would be equal to `INT_MIN` (`INT_MAX + 1`), so the `(n+x) / m`
division would overflow and trigger UB.</pre>
</div>
</content>
</entry>
<entry>
<title>Reland [mlir] ArithToLLVM: fix memref bitcast lowering (#125148) (#126939)</title>
<updated>2025-02-12T17:32:13+00:00</updated>
<author>
<name>Ivan Butygin</name>
<email>ivan.butygin@gmail.com</email>
</author>
<published>2025-02-12T17:32:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=e167c31dc973b0b2c3af96f5e7e28d45736a6c6b'/>
<id>e167c31dc973b0b2c3af96f5e7e28d45736a6c6b</id>
<content type='text'>
Reland https://github.com/llvm/llvm-project/pull/125148

Limiting vector pattern caused issues with `select` of complex lowering,
which wasn't caught as it was missing lit tests. Keep the pattern as is
for now and instead set a higher benefit to `IdentityBitcastLowering` so
it will always run before the vector pattern.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reland https://github.com/llvm/llvm-project/pull/125148

Limiting vector pattern caused issues with `select` of complex lowering,
which wasn't caught as it was missing lit tests. Keep the pattern as is
for now and instead set a higher benefit to `IdentityBitcastLowering` so
it will always run before the vector pattern.</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[mlir] ArithToLLVM: fix memref bitcast lowering" (#126895)</title>
<updated>2025-02-12T11:34:16+00:00</updated>
<author>
<name>Ivan Butygin</name>
<email>ivan.butygin@gmail.com</email>
</author>
<published>2025-02-12T11:34:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0e779ad4998ef65907502101c5b82ede05ddfa4e'/>
<id>0e779ad4998ef65907502101c5b82ede05ddfa4e</id>
<content type='text'>
Reverts llvm/llvm-project#125148

bot failures</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reverts llvm/llvm-project#125148

bot failures</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir] ArithToLLVM: fix memref bitcast lowering (#125148)</title>
<updated>2025-02-12T11:19:13+00:00</updated>
<author>
<name>Ivan Butygin</name>
<email>ivan.butygin@gmail.com</email>
</author>
<published>2025-02-12T11:19:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=79010e2e4d0e27ee87887bfaef2c32e908c92a8e'/>
<id>79010e2e4d0e27ee87887bfaef2c32e908c92a8e</id>
<content type='text'>
`arith.bitcast` is allowed on memrefs and such code can actually be
generated by IREE `ConvertBf16ArithToF32Pass`.
`LLVM::detail::vectorOneToOneRewrite` doesn't properly check its types
and will generate bitcast between structs which is illegal.

With the opaque pointers this is a no-op operation for memref so we can
just add type check in `LLVM::detail::vectorOneToOneRewrite` and add a
separate pattern which removes op if converted types are the same.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`arith.bitcast` is allowed on memrefs and such code can actually be
generated by IREE `ConvertBf16ArithToF32Pass`.
`LLVM::detail::vectorOneToOneRewrite` doesn't properly check its types
and will generate bitcast between structs which is illegal.

With the opaque pointers this is a no-op operation for memref so we can
just add type check in `LLVM::detail::vectorOneToOneRewrite` and add a
separate pattern which removes op if converted types are the same.</pre>
</div>
</content>
</entry>
</feed>
