This is an archive of the discontinued LLVM Phabricator instance.

[mlir][arith] Add initial files for (runtime) integration tests
ClosedPublic

Authored by kuhar on Sep 15 2022, 7:09 PM.

Details

Summary

The goal is to have a set of runtime tests for further extercise the wide integer emulation pass and its conversion patterns. This was suggested by @Mogball in D133629.

Add a minimal runtime test to demonstrate that printing and pass pipeline works as expected.

Diff Detail

Event Timeline

kuhar created this revision.Sep 15 2022, 7:09 PM
Herald added a project: Restricted Project. · View Herald Transcript
kuhar requested review of this revision.Sep 15 2022, 7:09 PM
Mogball added inline comments.Sep 15 2022, 8:29 PM
mlir/lib/Dialect/Arithmetic/Transforms/EmulateWideInt.cpp
373

Why is this pattern needed?

kuhar added inline comments.Sep 15 2022, 8:35 PM
mlir/lib/Dialect/Arithmetic/Transforms/EmulateWideInt.cpp
373

Without this, vector.print %x : i2N would be considered illegal and the mlir-opt invocation would fail.

The high-level idea behind future integration test is to run the same module with and without emulation, so that we can generate the expected emulated values based on whatever mlir-cpu-runner prints for wide operations without emulation.

As an alternative, I think we might be able to always print vector<2xiN>, but this would require us to bitcast from i2N to vector<2xiN. I don't think that arith.bitcast supports that but llvm.bitcast should. But then I'm not sure if this wouldn't defer the same problem to the missing conversion/legality check for llvm.bitcast.

Mogball accepted this revision.Sep 16 2022, 8:28 AM

Thanks for adding these. Especially with how complicated some of the emulation patterns are, these will add confidence to the implementation.

mlir/lib/Dialect/Arithmetic/Transforms/EmulateWideInt.cpp
373

You're right that arith.bitcast doesn't do vector bitcasting -- it sounds like we need a vector.bitcast op that does that (which also maps to llvm.bitcast). That being said, if this pattern is only needed for testing, I would suggest moving it into a test pass.

But I wouldn't say that this pattern is "test only". It's legalizing vector.print to use wide integer emulation (even though that just means it rewrites the operand types). So I think you can drop the comment about that.

This revision is now accepted and ready to land.Sep 16 2022, 8:28 AM
kuhar marked 2 inline comments as done.Sep 16 2022, 8:43 AM
kuhar added inline comments.
mlir/lib/Dialect/Arithmetic/Transforms/EmulateWideInt.cpp
373

Yeah, the comment was meant to justify the unusual placement of the pattern: I'd expect to see it in a vector transform or dedicated test pass. But in the interest of incremental changes, I added it to the main arith pass for the time being.

This revision was automatically updated to reflect the committed changes.
kuhar marked an inline comment as done.