<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/mlir/lib/Dialect/Complex/IR/ComplexOps.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] Remove unused includes (NFC) (#150266)</title>
<updated>2025-07-23T22:18:53+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2025-07-23T22:18:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0925d7572acee311bf596db294bc818536722150'/>
<id>0925d7572acee311bf596db294bc818536722150</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>Switch member calls to `isa/dyn_cast/cast/...` to free function calls. (#89356)</title>
<updated>2024-04-19T13:58:27+00:00</updated>
<author>
<name>Christian Sigg</name>
<email>chsigg@users.noreply.github.com</email>
</author>
<published>2024-04-19T13:58:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a5757c5b65f1894de16f549212b1c37793312703'/>
<id>a5757c5b65f1894de16f549212b1c37793312703</id>
<content type='text'>
This change cleans up call sites. Next step is to mark the member
functions deprecated.

See https://mlir.llvm.org/deprecation and
https://discourse.llvm.org/t/preferred-casting-style-going-forward.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change cleans up call sites. Next step is to mark the member
functions deprecated.

See https://mlir.llvm.org/deprecation and
https://discourse.llvm.org/t/preferred-casting-style-going-forward.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][complex] Canonicalize complex.div by one (#85513)</title>
<updated>2024-03-26T04:50:28+00:00</updated>
<author>
<name>Kai Sasaki</name>
<email>lewuathe@gmail.com</email>
</author>
<published>2024-03-26T04:50:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=08a321e1b7ffdd72154ae808821d20fe511c83b6'/>
<id>08a321e1b7ffdd72154ae808821d20fe511c83b6</id>
<content type='text'>
We can canonicalize the complex.div if the divisor is one (real = 1.0,
imag = 0.0) with the input number itself.

Ref: https://www.cuemath.com/numbers/division-of-complex-numbers/</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We can canonicalize the complex.div if the divisor is one (real = 1.0,
imag = 0.0) with the input number itself.

Ref: https://www.cuemath.com/numbers/division-of-complex-numbers/</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][complex] Allow integer element types in `complex.constant` ops (#74564)</title>
<updated>2023-12-07T02:22:53+00:00</updated>
<author>
<name>Matthias Springer</name>
<email>me@m-sp.org</email>
</author>
<published>2023-12-07T02:22:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=1612993788c3d8049f1e43a6f48ea3264f8a434f'/>
<id>1612993788c3d8049f1e43a6f48ea3264f8a434f</id>
<content type='text'>
The op used to support only float element types. This was inconsistent
with `ConstantOp::isBuildableWith`, which allows integer element types.
The complex type allows any float/integer element type.

Note: The other complex dialect ops do not support non-float element
types yet. The main purpose of this change to fix
`Tensor/canonicalize.mlir`, which is currently failing when verifying
the IR after each pattern application (#74270).

```
within split at mlir/test/Dialect/Tensor/canonicalize.mlir:231 offset :8:15: error: 'complex.constant' op result #0 must be complex type with floating-point elements, but got 'complex&lt;i32&gt;'
  %complex1 = tensor.extract %c1[] : tensor&lt;complex&lt;i32&gt;&gt;
              ^
within split at mlir/test/Dialect/Tensor/canonicalize.mlir:231 offset :8:15: note: see current operation: %0 = "complex.constant"() &lt;{value = [1 : i32, 2 : i32]}&gt; : () -&gt; complex&lt;i32&gt;
"func.func"() &lt;{function_type = () -&gt; tensor&lt;3xcomplex&lt;i32&gt;&gt;, sym_name = "extract_from_elements_complex_i"}&gt; ({
  %0 = "complex.constant"() &lt;{value = [1 : i32, 2 : i32]}&gt; : () -&gt; complex&lt;i32&gt;
  %1 = "arith.constant"() &lt;{value = dense&lt;(3,2)&gt; : tensor&lt;complex&lt;i32&gt;&gt;}&gt; : () -&gt; tensor&lt;complex&lt;i32&gt;&gt;
  %2 = "arith.constant"() &lt;{value = dense&lt;(1,2)&gt; : tensor&lt;complex&lt;i32&gt;&gt;}&gt; : () -&gt; tensor&lt;complex&lt;i32&gt;&gt;
  %3 = "tensor.extract"(%1) : (tensor&lt;complex&lt;i32&gt;&gt;) -&gt; complex&lt;i32&gt;
  %4 = "tensor.from_elements"(%0, %3, %0) : (complex&lt;i32&gt;, complex&lt;i32&gt;, complex&lt;i32&gt;) -&gt; tensor&lt;3xcomplex&lt;i32&gt;&gt;
  "func.return"(%4) : (tensor&lt;3xcomplex&lt;i32&gt;&gt;) -&gt; ()
}) : () -&gt; ()
```</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The op used to support only float element types. This was inconsistent
with `ConstantOp::isBuildableWith`, which allows integer element types.
The complex type allows any float/integer element type.

Note: The other complex dialect ops do not support non-float element
types yet. The main purpose of this change to fix
`Tensor/canonicalize.mlir`, which is currently failing when verifying
the IR after each pattern application (#74270).

```
within split at mlir/test/Dialect/Tensor/canonicalize.mlir:231 offset :8:15: error: 'complex.constant' op result #0 must be complex type with floating-point elements, but got 'complex&lt;i32&gt;'
  %complex1 = tensor.extract %c1[] : tensor&lt;complex&lt;i32&gt;&gt;
              ^
within split at mlir/test/Dialect/Tensor/canonicalize.mlir:231 offset :8:15: note: see current operation: %0 = "complex.constant"() &lt;{value = [1 : i32, 2 : i32]}&gt; : () -&gt; complex&lt;i32&gt;
"func.func"() &lt;{function_type = () -&gt; tensor&lt;3xcomplex&lt;i32&gt;&gt;, sym_name = "extract_from_elements_complex_i"}&gt; ({
  %0 = "complex.constant"() &lt;{value = [1 : i32, 2 : i32]}&gt; : () -&gt; complex&lt;i32&gt;
  %1 = "arith.constant"() &lt;{value = dense&lt;(3,2)&gt; : tensor&lt;complex&lt;i32&gt;&gt;}&gt; : () -&gt; tensor&lt;complex&lt;i32&gt;&gt;
  %2 = "arith.constant"() &lt;{value = dense&lt;(1,2)&gt; : tensor&lt;complex&lt;i32&gt;&gt;}&gt; : () -&gt; tensor&lt;complex&lt;i32&gt;&gt;
  %3 = "tensor.extract"(%1) : (tensor&lt;complex&lt;i32&gt;&gt;) -&gt; complex&lt;i32&gt;
  %4 = "tensor.from_elements"(%0, %3, %0) : (complex&lt;i32&gt;, complex&lt;i32&gt;, complex&lt;i32&gt;) -&gt; tensor&lt;3xcomplex&lt;i32&gt;&gt;
  "func.return"(%4) : (tensor&lt;3xcomplex&lt;i32&gt;&gt;) -&gt; ()
}) : () -&gt; ()
```</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][Complex] Fix bug in `MergeComplexBitcast` (#74271)</title>
<updated>2023-12-05T01:25:19+00:00</updated>
<author>
<name>Matthias Springer</name>
<email>me@m-sp.org</email>
</author>
<published>2023-12-05T01:25:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=192439db6e3fcccf98c850bda1b970a11c590bbb'/>
<id>192439db6e3fcccf98c850bda1b970a11c590bbb</id>
<content type='text'>
When two `complex.bitcast` ops are folded and the resulting bitcast is a
non-complex -&gt; non-complex bitcast, an `arith.bitcast` should be
generated. Otherwise, the generated `complex.bitcast` op is invalid.

Also remove a pattern that convertes non-complex -&gt; non-complex
`complex.bitcast` ops to `arith.bitcast`. Such `complex.bitcast` ops are
invalid and should not appear in the input.

Note: This bug can only be triggered by running with `-debug` (which
will should intermediate IR that does not verify) or with
`MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS` (#74270).</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When two `complex.bitcast` ops are folded and the resulting bitcast is a
non-complex -&gt; non-complex bitcast, an `arith.bitcast` should be
generated. Otherwise, the generated `complex.bitcast` op is invalid.

Also remove a pattern that convertes non-complex -&gt; non-complex
`complex.bitcast` ops to `arith.bitcast`. Such `complex.bitcast` ops are
invalid and should not appear in the input.

Note: This bug can only be triggered by running with `-debug` (which
will should intermediate IR that does not verify) or with
`MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS` (#74270).</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][complex] Add a `complex.bitcast` operation</title>
<updated>2023-07-06T23:21:57+00:00</updated>
<author>
<name>Rob Suderman</name>
<email>suderman@google.com</email>
</author>
<published>2023-07-06T23:19:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a8df21f433d2f7cd267ac6e5581163f15501918b'/>
<id>a8df21f433d2f7cd267ac6e5581163f15501918b</id>
<content type='text'>
Converting between a complex&lt;f32&gt; to i64 could be useful for handling interop
between the `arith` and `complex` dialects.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D154663
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Converting between a complex&lt;f32&gt; to i64 could be useful for handling interop
between the `arith` and `complex` dialects.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D154663
</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][complex] Canonicalize complex.mul with 1 and 0</title>
<updated>2023-06-28T07:28:26+00:00</updated>
<author>
<name>Kai Sasaki</name>
<email>lewuathe@gmail.com</email>
</author>
<published>2023-06-28T05:55:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8d175b3577cb5ef0655a5d83bd3e277fde5c8852'/>
<id>8d175b3577cb5ef0655a5d83bd3e277fde5c8852</id>
<content type='text'>
We can fold the complex.mul if the right value is obvious 1 or 0.

Differential Revision: https://reviews.llvm.org/D153606
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We can fold the complex.mul if the right value is obvious 1 or 0.

Differential Revision: https://reviews.llvm.org/D153606
</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][complex] Canonicalize re/im(neg(create))</title>
<updated>2023-05-30T00:52:48+00:00</updated>
<author>
<name>Lei Zhang</name>
<email>antiagainst@gmail.com</email>
</author>
<published>2023-05-29T20:17:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a1e78615fb331484e07c2201433ba1e683348c47'/>
<id>a1e78615fb331484e07c2201433ba1e683348c47</id>
<content type='text'>
When can just convert this to arith.negf.

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D151633
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When can just convert this to arith.negf.

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D151633
</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir] Move casting calls from methods to function calls</title>
<updated>2023-05-26T08:29:55+00:00</updated>
<author>
<name>Tres Popp</name>
<email>tpopp@google.com</email>
</author>
<published>2023-05-26T08:17:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=68f58812e3e99e31d77c0c23b6298489444dc0be'/>
<id>68f58812e3e99e31d77c0c23b6298489444dc0be</id>
<content type='text'>
The MLIR classes Type/Attribute/Operation/Op/Value support
cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast
functionality in addition to defining methods with the same name.
This change begins the migration of uses of the method to the
corresponding function call as has been decided as more consistent.

Note that there still exist classes that only define methods directly,
such as AffineExpr, and this does not include work currently to support
a functional cast/isa call.

Context:
- https://mlir.llvm.org/deprecation/ at "Use the free function variants
  for dyn_cast/cast/isa/…"
- Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443

Implementation:
This patch updates all remaining uses of the deprecated functionality in
mlir/. This was done with clang-tidy as described below and further
modifications to GPUBase.td and OpenMPOpsInterfaces.td.

Steps are described per line, as comments are removed by git:
0. Retrieve the change from the following to build clang-tidy with an
   additional check:
   main...tpopp:llvm-project:tidy-cast-check
1. Build clang-tidy
2. Run clang-tidy over your entire codebase while disabling all checks
   and enabling the one relevant one. Run on all header files also.
3. Delete .inc files that were also modified, so the next build rebuilds
   them to a pure state.

```
ninja -C $BUILD_DIR clang-tidy

run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\
               -header-filter=mlir/ mlir/* -fix

rm -rf $BUILD_DIR/tools/mlir/**/*.inc
```

Differential Revision: https://reviews.llvm.org/D151542
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The MLIR classes Type/Attribute/Operation/Op/Value support
cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast
functionality in addition to defining methods with the same name.
This change begins the migration of uses of the method to the
corresponding function call as has been decided as more consistent.

Note that there still exist classes that only define methods directly,
such as AffineExpr, and this does not include work currently to support
a functional cast/isa call.

Context:
- https://mlir.llvm.org/deprecation/ at "Use the free function variants
  for dyn_cast/cast/isa/…"
- Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443

Implementation:
This patch updates all remaining uses of the deprecated functionality in
mlir/. This was done with clang-tidy as described below and further
modifications to GPUBase.td and OpenMPOpsInterfaces.td.

Steps are described per line, as comments are removed by git:
0. Retrieve the change from the following to build clang-tidy with an
   additional check:
   main...tpopp:llvm-project:tidy-cast-check
1. Build clang-tidy
2. Run clang-tidy over your entire codebase while disabling all checks
   and enabling the one relevant one. Run on all header files also.
3. Delete .inc files that were also modified, so the next build rebuilds
   them to a pure state.

```
ninja -C $BUILD_DIR clang-tidy

run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\
               -header-filter=mlir/ mlir/* -fix

rm -rf $BUILD_DIR/tools/mlir/**/*.inc
```

Differential Revision: https://reviews.llvm.org/D151542
</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir] Update method cast calls to function calls</title>
<updated>2023-05-12T09:21:30+00:00</updated>
<author>
<name>Tres Popp</name>
<email>tpopp@google.com</email>
</author>
<published>2023-05-11T09:10:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c1fa60b4cde512964544ab66404dea79dbc5dcb4'/>
<id>c1fa60b4cde512964544ab66404dea79dbc5dcb4</id>
<content type='text'>
The MLIR classes Type/Attribute/Operation/Op/Value support
cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast
functionality in addition to defining methods with the same name.
This change begins the migration of uses of the method to the
corresponding function call as has been decided as more consistent.

Note that there still exist classes that only define methods directly,
such as AffineExpr, and this does not include work currently to support
a functional cast/isa call.

Context:

* https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…"
* Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443

Implementation:
This follows a previous patch that updated calls
`op.cast&lt;T&gt;()-&gt; cast&lt;T&gt;(op)`. However some cases could not handle an
unprefixed `cast` call due to occurrences of variables named cast, or
occurring inside of class definitions which would resolve to the method.
All C++ files that did not work automatically with `cast&lt;T&gt;()` are
updated here to `llvm::cast` and similar with the intention that they
can be easily updated after the methods are removed through a
find-replace.

See https://github.com/llvm/llvm-project/compare/main...tpopp:llvm-project:tidy-cast-check
for the clang-tidy check that is used and then update printed
occurrences of the function to include `llvm::` before.

One can then run the following:
```
ninja -C $BUILD_DIR clang-tidy

run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\
                 -export-fixes /tmp/cast/casts.yaml mlir/*\
                 -header-filter=mlir/ -fix

rm -rf $BUILD_DIR/tools/mlir/**/*.inc
```

Differential Revision: https://reviews.llvm.org/D150348
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The MLIR classes Type/Attribute/Operation/Op/Value support
cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast
functionality in addition to defining methods with the same name.
This change begins the migration of uses of the method to the
corresponding function call as has been decided as more consistent.

Note that there still exist classes that only define methods directly,
such as AffineExpr, and this does not include work currently to support
a functional cast/isa call.

Context:

* https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…"
* Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443

Implementation:
This follows a previous patch that updated calls
`op.cast&lt;T&gt;()-&gt; cast&lt;T&gt;(op)`. However some cases could not handle an
unprefixed `cast` call due to occurrences of variables named cast, or
occurring inside of class definitions which would resolve to the method.
All C++ files that did not work automatically with `cast&lt;T&gt;()` are
updated here to `llvm::cast` and similar with the intention that they
can be easily updated after the methods are removed through a
find-replace.

See https://github.com/llvm/llvm-project/compare/main...tpopp:llvm-project:tidy-cast-check
for the clang-tidy check that is used and then update printed
occurrences of the function to include `llvm::` before.

One can then run the following:
```
ninja -C $BUILD_DIR clang-tidy

run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\
                 -export-fixes /tmp/cast/casts.yaml mlir/*\
                 -header-filter=mlir/ -fix

rm -rf $BUILD_DIR/tools/mlir/**/*.inc
```

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