This is an archive of the discontinued LLVM Phabricator instance.

[mlir][StandardToSPIRV] Add support for lowering uitofp to SPIR-V
ClosedPublic

Authored by hanchung on Jan 21 2021, 12:48 AM.

Details

Summary
  • Extend spirv::ConstantOp::getZero/One to handle float, vector of int, and vector of float.
  • Refactor ZeroExtendI1Pattern to use getZero/One methods.
  • Add one more test for lowering std.zexti which extends vector<4xi1> to vector<4xi64>.

Diff Detail

Event Timeline

hanchung created this revision.Jan 21 2021, 12:48 AM
hanchung requested review of this revision.Jan 21 2021, 12:48 AM
antiagainst requested changes to this revision.Jan 21 2021, 5:44 AM
antiagainst added inline comments.
mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp
527

We should generate spv.constant here?

Actually for spirv::ConstantOp we have utility methods getZero and getOne, but now it only supports scalar integer. Could you extend those methods to support float and vectors? So we don't need to have this logic duplicated in all patterns needing zero/one (which is quite common).

This revision now requires changes to proceed.Jan 21 2021, 5:44 AM
hanchung updated this revision to Diff 318185.Jan 21 2021, 6:57 AM

Extend getZero and getOne to support floating-point, vector of int/float.

hanchung edited the summary of this revision. (Show Details)Jan 21 2021, 7:00 AM

I found that we have special handling for boolean, but I couldn't test it with vector<i1>. I think I can add another pattern to truncate a vector of integer to vector<*xi1> (which is missing) and cover the test there.

antiagainst accepted this revision.Jan 21 2021, 2:10 PM
This revision is now accepted and ready to land.Jan 21 2021, 2:10 PM
hanchung updated this revision to Diff 318416.Jan 21 2021, 10:00 PM

do not use 'else' after 'return'

This revision was landed with ongoing or failed builds.Jan 21 2021, 10:21 PM
This revision was automatically updated to reflect the committed changes.