This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel: Restrict narrow scalar for fptoui/fptosi results
ClosedPublic

Authored by arsenm on Mar 28 2021, 8:14 AM.

Details

Summary

This practically only works for the f16 case AMDGPU uses, not wider
types.

Fixes bug 49710 by failing legalization.

Diff Detail

Event Timeline

arsenm created this revision.Mar 28 2021, 8:14 AM
arsenm requested review of this revision.Mar 28 2021, 8:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2021, 8:14 AM
Herald added a subscriber: wdng. · View Herald Transcript
nikic added inline comments.Mar 28 2021, 8:20 AM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
4721

Shouldn't this check the NarrowTy, rather than the old DstTy?

foad added a subscriber: foad.Mar 29 2021, 3:37 AM
arsenm updated this revision to Diff 333958.Mar 29 2021, 12:19 PM
arsenm marked an inline comment as done.

Check new result type

foad added a comment.Mar 30 2021, 12:27 AM

The code change looks fine to me. The added tests aren't actually testing any behaviour that has changed, are they? Is there any reasonable way to add tests for the unable-to-legalize case?

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
4714

There's no need to introduce NarrowDstTy, just use NarrowTy throughout.

4719

Could invert the condition and early-out here but it doesn't really matter.

arsenm updated this revision to Diff 334321.Mar 30 2021, 7:01 PM

Style changes

Amanieu added a subscriber: Amanieu.Apr 2 2021, 1:34 AM
nikic added a comment.Apr 10 2021, 3:51 AM

Reverse ping, I believe @foad's comment regarding the test is still open.

The code change looks fine to me. The added tests aren't actually testing any behaviour that has changed, are they? Is there any reasonable way to add tests for the unable-to-legalize case?

That is what's tested here. The no-ops in the new tests demonstrate they weren't legalized.

nikic accepted this revision.Apr 11 2021, 7:44 AM

LGTM

(Just to be sure, I checked that the added tests did fail previously.)

This revision is now accepted and ready to land.Apr 11 2021, 7:44 AM