This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Use a VTSDNode to store the saturation width for FP_TO_SINT_SAT/FP_TO_UINT_SAT
ClosedPublic

Authored by craig.topper on Apr 25 2021, 11:27 AM.

Details

Summary

Previously we used an i32 constant to store the saturation width, but i32 isn't
legal on RISCV64. This wasn't a big deal to fix, but it is extra work for the
type legalizer.

This patch uses a VTSDNode to store the type similar to SEXT_INREG. This makes
it opaque to the type legalizer.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 25 2021, 11:27 AM
craig.topper requested review of this revision.Apr 25 2021, 11:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2021, 11:27 AM
Herald added a subscriber: aheejin. · View Herald Transcript

This is what I did in my original patch -- I think this got switched to a simple integer because it made legalization simpler. Shouldn't this require some changes to the vector legalizer at least? E.g. SplitVector would also have to split the VTSD.

-Use scalar type to avoid vector type legalization changes and changes to UnrollVectorOp.
-Add code to getNode to check the rules.

bjope added a comment.Apr 26 2021, 8:44 AM

Haven't tried it yet (on our downstream code base), but this looks good to me.

Should probably let @nikic confirm if the worries about vector legalization was solved by the latest update.

@nikic Any more comments?

nikic accepted this revision.Apr 27 2021, 10:15 AM

LGTM

This revision is now accepted and ready to land.Apr 27 2021, 10:15 AM