This is an archive of the discontinued LLVM Phabricator instance.

OpConvertSToF support operands with different bitwidth, close SameBitWidth check in verifier.
ClosedPublic

Authored by XinWangIntel on Sep 7 2020, 9:39 PM.

Details

Diff Detail

Event Timeline

XinWangIntel created this revision.Sep 7 2020, 9:39 PM
XinWangIntel requested review of this revision.Sep 7 2020, 9:39 PM

Spec does not show bitwidth limit. From https://github.com/KhronosGroup/SPIRV-Tools/blob/master/test/val/val_conversion_test.cpp#L372 can get a cast to convert s64 to f32; And std.SIToFPOp dose not has the limit too. May be same issues with other cast ops

ConvertSToF shall support operands with same bitwidth and different bitwidth. The check of component number shall be done by another way.

Why is this only for SToFP op? We should keep it consistent for the different converts. Also you need to add test(s).

Just to keep minimal changes as i need this op support now. Will check other castOp and add tests soon, thanks.

SPV_ConvertFToSOp, SPV_ConvertFToUOp, SPV_ConvertSToFOp, SPV_ConvertUToFOp can support same && different bit widths of their operand type and result type. As The type definition limits the type and ODS checks the shape, skip bit widths check for those CastOps are enough now.

ThomasRaoux requested changes to this revision.Sep 8 2020, 10:46 PM
ThomasRaoux added inline comments.
mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
310–312

This seem to skip more than just the bitwidth check. I don't think we can skip the check that the shape are different. Why can't we just set requireSameBitWidth to false?

This revision now requires changes to proceed.Sep 8 2020, 10:46 PM
XinWangIntel added inline comments.Sep 8 2020, 10:55 PM
mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
310–312

When we just set requireSameBitWidth to false, it will report error when the bit widths of operand and result type are same(The 344 line check this), all the codes below just get element type and check bit widths, and either request same or different, no other choice, so just ignore. For shape issue, the CastOp definition use SameOperandsAndResultShape trait to check this, no check here.

ThomasRaoux accepted this revision.Sep 8 2020, 11:47 PM
ThomasRaoux added inline comments.
mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
310–312

You're right, my bad.

This revision is now accepted and ready to land.Sep 8 2020, 11:47 PM

I don't have commit access as a new contributor,if everything is fine, can anyone help me push the changes? Really thanks.

Do i need some changes? or anyone can help push the patch?