This is an archive of the discontinued LLVM Phabricator instance.

[mlir][complex] Add a `complex.bitcast` operation
ClosedPublic

Authored by rsuderman on Jul 6 2023, 3:32 PM.

Details

Summary

Converting between a complex<f32> to i64 could be useful for handling interop
between the arith and complex dialects.

Diff Detail

Event Timeline

rsuderman created this revision.Jul 6 2023, 3:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 3:32 PM
rsuderman requested review of this revision.Jul 6 2023, 3:32 PM
rsuderman updated this revision to Diff 537909.Jul 6 2023, 3:38 PM

Rebased on main

jpienaar accepted this revision.Jul 6 2023, 3:45 PM
jpienaar added inline comments.
mlir/lib/Dialect/Complex/IR/ComplexOps.cpp
91

Elide trivial braces

95

Why is this allowed vs keeping this purely on complex?

150

So this could result in changing arith Bitcast into a complex one, but only if operand is result of bitcast?

This revision is now accepted and ready to land.Jul 6 2023, 3:45 PM
rsuderman updated this revision to Diff 537922.Jul 6 2023, 4:19 PM
rsuderman marked an inline comment as done.

Updated for jpienaar@ comments. Included adding complex.bitcast -> arith.bitcast canonicalizer.

rsuderman marked 2 inline comments as done.Jul 6 2023, 4:19 PM
rsuderman added inline comments.
mlir/lib/Dialect/Complex/IR/ComplexOps.cpp
95

We want to allow bitcasting between i64 and complex<f32> so both need to be allowed. However we want to avoid complex.bitcast being used between unsupported types (e.g. tensor<complex<f32>>) for now.

150

Essentially yes. If we see a complex.bitcast -> arith.bitcast we merge this into a single complex.bitcast. I would argue its just sucking the arith.bitcast into the complex.bitcast but thats just a minor detail.

I realized I should include a complex.bitcast to arith.bitcast conversion so that if two complex.bitcasts are merged such that they are a valid arith.bitcast, we should just canonocalize to it.

This revision was landed with ongoing or failed builds.Jul 6 2023, 4:23 PM
This revision was automatically updated to reflect the committed changes.
rsuderman marked 2 inline comments as done.