Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vmvx] Relax requirement on fptosi lowering #11553

Merged
merged 4 commits into from
Dec 14, 2022
Merged

Conversation

jpienaar
Copy link
Member

@jpienaar jpienaar commented Dec 14, 2022

The consumption of si of small width is already handled successfully by
consumers of this op (at least in limited trial). This was not true for the ui version ---although I suspect consumer op there, but keeping it more restricted until
checked.

@jpienaar jpienaar requested a review from benvanik as a code owner December 14, 2022 18:51
@jpienaar jpienaar requested review from ScottTodd and removed request for benvanik December 14, 2022 18:59
@ScottTodd ScottTodd added the codegen/vmvx VMVX (IREE VM) code generation compiler backend label Dec 14, 2022
hanhanW
hanhanW previously approved these changes Dec 14, 2022
auto resultType = getTypeConverter()->convertType(dstType);
// This uses the resultType rather than dstType as any truncation
// required will be handled via interpretation by consumer.
if (resultType.isSignlessInteger(32) || resultType.isSignedInteger(32)) {
rewriter.replaceOpWithNewOp<IREE::VM::CastF32SI32Op>(
srcOp, resultType, adaptor.getOperands()[0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you're touching the code around this area, could you also update adaptor.getOperands()[0] to adaptor.getIn()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring l.935, but it's still good that you fix the other part..

@hanhanW hanhanW dismissed their stale review December 14, 2022 19:10

clicked approval by accident..

auto resultType = getTypeConverter()->convertType(dstType);
// This uses the resultType rather than dstType as any truncation
// required will be handled via interpretation by consumer.
if (resultType.isSignlessInteger(32) || resultType.isSignedInteger(32)) {
rewriter.replaceOpWithNewOp<IREE::VM::CastF32SI32Op>(
srcOp, resultType, adaptor.getOperands()[0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring l.935, but it's still good that you fix the other part..

Comment on lines +80 to 82
// CHECK: vm.cast.f32.si32 %[[ARG0]] : f32 -> i32
%1 = arith.fptosi %arg0 : f32 to i8
return %1 : i8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there other IRs that truncate i32 to i8? If so, should we check it as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We checked the integer ones yesterday (8a3d270). At least for those individually the result wrt llvm and vmvx was the same.

The consumption of si of small width is already handled successfully by
consumers of this op. This was not true for the ui version - although I
suspect consumer op there, but keeping it more restricted until
checked.
Copy link
Contributor

@hanhanW hanhanW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@jpienaar jpienaar merged commit cee9b3c into iree-org:main Dec 14, 2022
pzread pushed a commit to pzread/iree that referenced this pull request Jan 4, 2023
pzread pushed a commit to pzread/iree that referenced this pull request Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen/vmvx VMVX (IREE VM) code generation compiler backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants